Tuesday, December 18, 2012

VirtualBox: Using SATA disk on Win2000/XP/2003

You still have plenty of Windows 2000, XP and Server 2003 VMs in your VirtualBox list, you say? Me too. One of the reasons we do virtualization in the first place, is because we need to test stuff on different operating systems.

VirtualBox defaults to IDE disk controllers when we choose to install Windows 2000, XP or Windows Server 2003. VirtualBox also offers several other disk controllers, including LSI Logic and BusLogic SCSI controllers, LSI Logic SAS controller, and last but not least, SATA, which emulates an Intel 82801HBM AHCI Controller.

The VirtualBox manual tells us that they support SCSI "primarily for compatibility with other virtualization software". The same manual also says that "VirtualBox's virtual SATA controller operates faster and also consumes fewer CPU resources than the virtual IDE controller.". These last words sounds good to a systems administrator. We want to use SATA instead of IDE whenever we can. Should we use SCSI? Well, there might be situations where you would, but not for performance reasons. Go run a test if you think I'm wrong here.

The default disk controller choice of IDE, for Windows OSs before Vista, is because none of these OSs supported AHCI out of the box. You cannot install Windows XP to an AHCI disk without supplying a driver during install (the F6 procedure), or prepare your installation media with the driver before you start. Now, this is not so hard to do in VirtualBox, you could create a floppy image with the drivers and provide them to the VM during installation.

There is another easy method I wanted to show, that also makes it possible for you to change from IDE to AHCI on your existing VMs.

Install to IDE, change to SATA

Use the default disk configuration in VirtualBox for Windows 2000, XP or Server 2003, and you get an IDE controller.


Install your OS normally, and you end up with these devices:


Shut down your VM, add a SATA controller, and create a temporary disk that you add to this controller:


Boot your VM, and Windows will find a new device and ask you for the drivers. The VirtualBox manual states that "VirtualBox recommends the Intel Matrix Storage drivers", so download and install. You end up with these devices:


Now you can shut down your machine and remove the temporary disk you created (delete it from Virtual Media Manager if you want to get it deleted from your disk without doing it manually). Then, remove your system disk, and add it again on the SATA controller. Leave the CDROM on your IDE controller. The default setup for VMs that support SATA, also has the CDROM on an IDE controller, probably for a reason. If I try to move the CDROM to SATA and remove the IDE controller, my VM will not boot.
Also change the SATA port of your system disk to port 0, previously occupied by your temporary disk.


That's it. Your Windows 2000, XP or 2003 Server will now happily boot on your system disk created on an IDE controller, now attached to the SATA controller.

Using SATA disks as multi-attach disks

If you create a multi-attach master disk intended for new VMs, and install the SATA drivers as described, remember that VirtualBox will always put the disk on an IDE controller when you create the new VM. Before you start your new VM for the first time, you probably want to move the disk to a SATA controller. This is not as straight forward as it might seem.

First, you remove the disk from your IDE controller as described above. But when you want to add it to the SATA controller, you should not browse to the multi-attach disk itself, since that will sometimes give you an error, that it cannot create a differencing disk because it already exists. Instead, browse to the differencing disk that was created with your new VM. This disk file resides under the "Snapshot" folder inside the folder for your current VM. When you choose the differencing disk, you will notice that VirtualBox correctly list the disk with the name of the master disk. If the differencing disk for some reason is not there, you can safely choose the master disk file, and a new differencing disk will be created.

The error mentioned does not always occur, although I haven't been able to pinpoint exactly when it happens. It's VirtualBox, there are a few shortcomings, so stuff like this I just learn to accept, and use the workaround.