Skip to content

Instantly share code, notes, and snippets.

@ssokolow
Last active January 16, 2022 00:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ssokolow/a69af19dc452105ec0fb to your computer and use it in GitHub Desktop.
Save ssokolow/a69af19dc452105ec0fb to your computer and use it in GitHub Desktop.
Using a Linux VM to Isolate Icewind Dale 2 From Crash-Inducing OS Weirdness

Using a Linux VM to Isolate Icewind Dale 2 From Crash-Inducing OS Weirdness

  • Estimated Completion Time: approximately 30 minutes
  • Required Experience: If you can install your own games, you can follow these instructions.
  • Optional Changes: You can try replacing Linux+Wine with a real Windows 95/98 install CD if you own one.
  • Reassurances:
    • These instructions use the terminal because it's easier to instruct reliably, not because it's required.
    • I've worked hard to split the instructions and explanations apart. If you just want the steps to follow, ignore the indented points unless instructed otherwise.

Step 1: Install the Virtual Machine

  1. Install VirtualBox (a free, open-source competitor to VMWare).
    • If you're on Windows, you want ... for Windows hosts under VirtualBox platform packages
  2. Go to the Lubuntu Linux website and Download lubuntu (Intel x86) desktop CD.
    • I tested with the Lubuntu 15.04 ISO because it was current at the time this was written (July 2015).
    • I chose Lubuntu because it's Ubuntu-based, so it's easy to install, and it's small and lightweight, which we want since we don't plan on running a full desktop.
    • You want the 32-bit version because we'll be using a 32-bit Wine setup for maximum compatibility and a 64-bit desktop would waste memory doing only that.
  3. Launch VirtualBox, click New in the toolbar, and use the wizard with the following noteworthy settings:
    1. Select Linux and Ubuntu (32-bit) from the Type and Version drop-downs.
    2. Choose VDI (VirtualBox Disk Image) and Dynamically allocated from the hard drive section of the wizard.
      • This is so the disk image won't take up its full size on disk until the first time you actually fill it.
  4. Select the new VM and click Start in the toolbar.
  5. Use the wizard to select the Lubuntu CD ISO.
    • The Select start-up disk wizard appears only the first time you boot a new VM. It's intended to streamline inserting an OS install disc into the virtual PC.
  6. Use the arrow keys to choose Install Lubuntu from the CD's boot menu.
    • You may see some error messages during startup. They're harmless "We tried to enable optional hardware that VirtualBox doesn't fake" errors.
    • It's also safe to use Try Lubuntu without installing. It'll boot off the CD and the installer will be available as a desktop shortcut.
  7. Work your way through the Lubuntu install wizard as follows:
    1. I left Download updates while installing and Install this third-party software unchecked since the packages on the disc are enough to run PlayOnLinux and it saves time.
    2. Choose Erase disk and install Lubuntu (It's talking about the virtual hard drive)
    3. Choose Log in automatically on the Who are you? page of the wizard
    4. Wait for it to download security-critical updates and complete the install. (maybe 5 minutes)
    5. Choose to restart. (The CD's auto-eject doesn't always get along with VirtualBox, so you may get stuck at some errors and have to choose Machine > Reset from the menus)
  8. It should now boot into a Lubuntu desktop similar to Windows XP and earlier.
    • You may encounter error messages during the boot process. These should be Lubuntu harmlessly complaining that VirtualBox's virtual CPU doesn't implement features like performance counters.
    • Within a minute of the boot process completing, you should receive an updates dialogue. It's your choice whether you apply them. I just used the Settings button to set Automatically check for updates and Notify me of a new Ubuntu version to Never. (It's a VM. By default, it's behind a second layer of NAT and we're only running one game on it.)

Step 2: Enable Clipboard Integration and Shared Folders

  1. Open up a terminal window (System Tools > LXTerminal in the "start menu") and run the following command:

    sudo apt-get install virtualbox-guest-dkms virtualbox-guest-x11 -y

    (It will ask for the password you set during the Lubuntu install in order to gain adiminstrator privileges)

  2. Once the prompt (username@hostname:~$) returns, run the following to grant yourself shared folders permissions:

    sudo gpasswd -a "$USER" vboxsf
    
  3. choose Devices > Shared Clipboard > Bidirectional from the VirtualBox menus.

  4. From the "start menu", choose Logout and pick Shutdown

Step 2.5: Give the Virtual GPU More VRAM

  1. With the VM shut down, choose Settings from the toolbar in the main VirtualBox window
  2. Choose Display and drag the Video Memory slider to 128 MB
    • 128MiB is the most you can ask for without enabling 3D acceleration and I can't enable 3D acceleration at the moment due to a messed up VirtualBox install.
  3. Click OK.
  4. Start the VM back up

Step 3: Install PlayOnLinux to Run Older Win16/Win32 Games

  1. Open up a terminal window (See Step 2) and copy-paste the following commands (one at a time because "sudo" will trigger a password prompt):

    sudo add-apt-repository ppa:ubuntu-wine/ppa -y
    sudo apt-get update
    sudo apt-get install wine -y
  2. Accept the TrueType core fonts for the Web EULA using Tab and Enter. (OK and Yes)

  3. When the username@hostname:~$ prompt returns, open Firefox in Lubuntu and go to Download PlayOnLinux.

    • The version of PlayOnLinux included with Lubuntu is usually out of date.
  4. Click Ubuntu under Packages and then click the link under Deb files

    • .deb is like .msi for Debian/Ubuntu/Mint Linux
  5. Choose Open with: GDebi Package Installer and click OK

  6. In GDebi, close the An older version is available in a software channel warning and click Install Package.

  7. It will ask for your password to grant the install process administrator privileges.

  8. When it says Installation finished, close that dialog, the Package Installer window, and Firefox.

  9. From the "start menu", choose Games > PlayOnLinux.

  10. Answer the Can we gather anonymous stats? dialog however you want.

  11. When the PlayOnLinux window appears, wait for Refreshing PlayOnLinux to go away at the bottom of the window.

  12. Close PlayOnLinux.

    • Right now, what we wanted was for it to write default config files to your user profile.

Step 3.5: (Optional) Trim Lubuntu Down as Much as Possible

  1. Open up a terminal window and copy-paste the following to remove all unneeded desktop apps:

    sudo apt-get purge  -y pidgin* sylpheed* transmission* abiword* gnumeric* guvcview* audacious* gnome-mplayer xfburn xpad mtpaint simple-scan libsane gpicview galculator gnome-disk-utility
    sudo apt-get autoremove -y
  2. Copy-paste this command to clear out cached .deb packages

    sudo apt-get clean -y
  3. Select your preferred icon and cursor themes via Preferences > Customize Look and Feel

  4. Open System Tools > Synaptic Package Manager and use the search feature to find and remove themes you don't want

  5. If you're comfortable working in cmd.exe, you can google for instructions on shrinking the VDI file (I didn't bother)

    • Shrinking the VDI file releases the freed space back to your OS.
    • If the instructions are written for Linux, you'll need to replace VBoxManage with C:\Program Files\Oracle\VirtualBox\VBoxManage.exe and so on.

Step 4: Make a Snapshot So You Can Revert to This Clean State

  1. Choose Logout and Shutdown.
  2. Once the virtual machine is shut down, select it in the main VirtualBox window and click Snapshots in the top-right corner
  3. Click the Camera (Take Snapshot) in the lower toolbar and give it a name like Base OS.
  4. Start the virtual machine back up

Step 5: Install Icewind Dale 2

Option 1: Downloading from GOG

  1. Just use Firefox in the VM to download your installer from GOG like normal

Option 2: Using a local installer

  1. Choose Devices > Shared Folder Settings from the VirtualBox menu
  2. Click the Add Share toolbar button on the right side (a folder with a plus sign)
  3. Browse to find the place you saved Icewind Dale 2's installer.
  4. Make sure you choose "Auto-mount", then Click OK on both windows.
    • Manual mounting is currently a hassle under Lubuntu
  5. Choose Logout and Reboot to apply the auto-mount
    • ...but don't power the VM off if you didn't also check Permanent
  6. If you open the file manager, you should be able to find the shared folder in /media
    • Linux uses / instead of \ in paths. In fact, everything does except Windows, which is stuck with \ because, in the days when DOS used only floppy disks and didn't support folders, they chose to use syntax like /? instead of -h for passing options to commands.
    • On Linux, there's no C: and D:. All of your drives are part of one big virtual drive so that, if you want to move your growing games folder to its own drive, you just move your stuff over and then "mount" your new drive at the old location. Your programs don't even know anything changed.

...and then, for both options...

  1. Open PlayOnLinux (Games > PlayOnLinux in the "start menu")
  2. Click Install in the toolbar and then Games along the top
  3. Choose GOG.com - Icewind Dale II Complete from the list and click Install
  4. Follow the install wizard's instructions and select your setup_icewind_dale_2.exe when prompted.
    • Note: The version of Wine the PlayOnLinux guys chose causes minor visual glitches in the GOG installer but it's harmless.
  5. When it says Your installation is complete! click Exit Installer
    • PlayOnLinux needs to make some configuration adjustments after the install but before you run the game
  6. When PlayOnLinux asks How much memory does your graphics board have?, choose 128
    • It's the virtual GPU that it's asking about
  7. When the install process completes, try launching Icewind Dale
    • Note: On my system, there were hiccups during the opening videos but that could just be the game trusting my audio system to be a reliable timing source when it's actually glitchy. (I really need to reinstall this system)
    • If you do get glitches on the intro videos, just click through them.

IMPORTANT: There are some gotchas to installing Bigg's Widescreen Mod into Icewind Dale 2 under Wine and, if you don't work around them, your Icewind Dale 2 install will crash on startup and you'll have to delete it (either via the PlayOnLinux manager or by rolling back to your snapshot) and redo Step 5 to get it back into working order. I didn't have time to also write and test step-by-step instructions to work around those gotchas so my advice is to not mod Icewind Dale 2 while running it this way.

Step 6: Set the VM to Boot Directly Into Icewind Dale 2

  1. Run the following in a terminal window

    sudo apt-get install ratpoison
    • Unlike Windows, Linux has many different "window managers" to choose from. Ratpoison is a window manager which fullscreens one window at once rather than drawing a titlebar and letting you drag and resize things.
  2. Using the Run dialog (Alt-F2), run gksudo leafpad /usr/share/xsessions/iwd2.desktop and copy paste this in:

    [Desktop Entry]
    Name=Icewind Dale 2
    Comment=Start straight into Icewind Dale 2
    Exec=/bin/sh /usr/bin/iwd2-session
    Type=Application
    • This adds a new entry to the login screen's desktop type selector.
    • We use this because, since you chose Log in automatically while installing Lubuntu, it will boot straight into whatever you logged into last.
  3. Repeat the previous step with gksudo leafpad /usr/bin/iwd2-session and the following:

    xsetroot -solid black &
    /usr/bin/ratpoison &
    /usr/share/playonlinux/playonlinux --run "Icewind Dale II"
    • Desktop sessions are defined by a script like this which launches all of the bits and pieces (eg. taskbar, desktop, window manager, etc.) and then waits for them to exit. When the script quits, you return to the login screen.
    • This script defines our custom desktop as "set the background to pure black, launch ratpoison to handle window fullscreening, and then launch Icewind Dale 2."
    • The & at the end of the first two lines means "run in the background" (ie. Don't wait for it to exit before continuing to the next line) so this desktop session will wait for Icewind Dale 2 to exit and then return to the login screen.
    • If you want to do this with another game, you can get the last line from the Preferences dialogs for the desktop launcher icons PlayOnLinux creates.
  4. Repeat the previous step with leafpad .ratpoisonrc

    set border 0
    startup_message off
    echo Starting Icewind Dale II...
    • The first line removes the one-pixel border Ratpoison normally draws around windows.
    • The other two lines replace the default Welcome to Ratpoison. For help, type... message.
  5. Choose Logout from the "start menu" and then click Logout

  6. Click the leftmost icon in the top-right corner of the login screen and choose Icewind Dale 2

    • If it's not present, then the display manager (the thing which draws the login screen) didn't notice your changes. The easiest fix is to the power icon in the top-right corner to reboot the VM and then re-logout.
  7. Log back in

  8. The auto-login will now go directly to Icewind Dale 2

Step 7: Bypassing the Oracle VM VirtualBox Manager Window For a More Native Experience

  1. Right-click the VM in the main VirtualBox window and choose Create Shortcut on Desktop
  2. Right-click the resulting icon and use the preferences dialog to change the icon
    • I didn't have time to give instructions for copying the icon from the Lubuntu VM. Sorry.

Note: You could add a "halt" line to the end of /usr/bin/iwd2-session to shutdown the VM rather than returning to the login screen (making shutdown behave like a native app too), but then you'd need some skill to access the desktop if something breaks. Instead, just use Machine > Close > Save the machine state to shut down so you get "suspend and resume from any point" behaviour similar to emulators on Android.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment