Hacking, Coding and Gaming | @[email protected]

I've recently build a rather large VM collection of different operating systems (mostly versions of Windows) using Virtual Box, and here are a few things I learnt along the way. Admittedly these are more aimed at running Windows as your host machine.****

1. Shrinking disk images:

While ".vmdk" disk image files may be more compatible with other virtualization software (eg: VMWare), using ".vdi" files can be shrunk to reduce the space used on your host drive. After regular use, or system upgrades, your dynamically expanding disk can end up using more space than necessary, so here's how to reduce it:

  1. Windows:

    1. Boot the VM
    2. Defrag the drive
    3. Download "SDelete" from http://technet.microsoft.com/en-us/sysinternals/bb897443.aspx
    4. Extract "SDelete" and navigate to it's folder in a command prompt
    5. Run "sdelete -z c:" (or other drive letter) - this will the free space on the drive with zeros
    6. Shutdown the VM
    7. Open a command prompt on your host machine and navigate to your VirtualBox folder (probably "C:\Program Files\Oracle\VirtualBox" on Windows)
    8. Run "VBoxManage modifyhd <path_to_vm's_vdi_file> -compact" to shrink the disk image size
  2. Linux (Ubuntu variants):

    1. Boot the VM
    2. Install zerofree: "sudo aptitude install zerofree"
    3. Reboot, select "recovery mode" (should be achievable by holding down "shift" during boot, or via the GRUB menu) then "Drop to root shell prompt"
    4. Run "df" and look for the biggest mounting point to determine your main partition (eg: "/dev/sda1")
    5. Stop background services: "service rsyslog stop", "service network-manager stop", "killall dhclient"
    6. Mount the partition: "mount -n -o remount,ro -t ext3 /dev/sda1 /"
    7. Run zero free on it: "zerofree -v /dev/sda1"
    8. Shutdown the VM: "shutdown -h now"
    9. Open a command prompt on your host machine and navigate to your VirtualBox folder (probably "C:\Program Files\Oracle\VirtualBox" on Windows)
    10. Run "VBoxManage modifyhd <path_to_vm's_vdi_file> -compact" to shrink the disk image size

2. Getting files in to a VM that doesn't have network, internet, or VirtualBox Additions support:

There's a useful (Windows) tool called "Folder2ISO", available at http://www.trustfm.net/divx/SoftwareFolder2Iso.php, which does exactly what the name suggests - makes a ".iso" file from a folder. Simply put the files you want to give them VM access to in a folder, run this tool on it, and attach the ISO to the VM (assuming the OS supports a cd drive).

3. Windows 95/98 Graphics drivers:

Option #1: There's an application called "SciTech Display Doctor" which provides graphic support to Windows 95 and 98. The company and product seem to no longer officially be available, but it can be downloaded from http://scitechdd.wordpress.com/ or http://www.vogonsdrivers.com/getfile.php?fileid=346. After installing the software, go to advanced Display Properties and change the adapter, There should be a "SciTech" adapter listed, select it and when prompted for the drivers/disk point to "C:\Program Files\SciTech Display Doctor\disk" and it should find the drivers. After a restart, you will probably need to change the monitor type (also in advanced Display Properties) to get a higher resolution.

Option #2: There's a "VBEMP 9x Project" which provides a custom driver for Windows 95/98 at http://bearwindows.boot-land.net/vbe9x.htm. It's said to have some graphical issues (I think mainly in Windows 95), but the project seems to be actively maintained and I didn't notice any on my Windows 98 VM. Boot in to Windows, go to advanced Display Properties and choose to change your display adapter, choosing "have disk" and point it to the VBEMP files you downloaded (I went with the "32Mb" folder). As above, you'll probably need to change your monitor type to get higher resolution.