Posted by & filed under AWS/Linux/Unix/Devops stuff.

As of Virtualbox 3.2 the default disk controller has been changed from IDE to SATA. If you had setup a Virtualbox disk in a previous version, unless you opted for using the SATA (or SCSI, SAS) controller, chances are you are using IDE. You can confirm this by putting your mouse over the disk icon in the lower status bar of a VM window, which should reveal the controller type being used for the current disk.

If you are using the IDE controller, with a small amount of work you can switch to the faster SATA controller without having to reinstall the entire OS and recreate your images. You can also switch to the SATA controller if you are using the SCSI, and presumably the SAS controller as well. Here is how…

As of Virtualbox 3.2 the default disk controller has been changed from IDE to SATA. If you had setup a Virtualbox disk in a previous version, unless you opted for using the SATA (or SCSI, SAS) controller, chances are you are using IDE. You can confirm this by putting your mouse over the disk icon in the lower status bar of a VM window, which should reveal the controller type being used for the current disk.

If you are using the IDE controller, with a small amount of work you can switch to the faster SATA controller without having to reinstall the entire OS and recreate your images. You can also switch to the SATA controller if you are using the SCSI, and presumably the SAS controller as well, although in this case I can’t promise an increase of speed for you unless you had several VMs running that were making aggressive use of your I/O on SATA disks (I haven’t tested this yet I suspect that using these faster controllers I/O usage might be a little too aggressive for SATA disks).

Keep in mind that what we are doing here is change the disk type being presented to the OS, and not the disks themselves, so none of the actual data on your VM images needs any modifications providing the guest OS supports SATA disks. About the only notable OS that apparently doesn’t support SATA drives out-of-the-box is Windows XP, the following instructions detail the install of the AHCI controller needed to support SATA disks in XP. All of this being said, it is never a bad idea to have a backup handy anyway, to operate on a test VM, or to be wise otherwise along these same lines :)

In Windows

I used these instructions to get a Windows 7 VM using the SATA controller. I have not tested the instructions provided on an XP VM (yet), so while the instructions for installing the AHCI driver included within the linked article look straight-forward enough, you’re on your own there! I’ve also only tested migrating from IDE to SATA, not SCSI or SAS to SATA, although I’d imagine the instructions for making this switchover would be similar.

I did have a little problem with these instructions though, but found that the following works:

  1. Make sure that both a SATA and your current controller are being presented to Windows. The SATA controller doesn’t need to have any disks attached to it. Once you have done so boot up Windows.
  2. Remove the IDE controller as described in the above URL. Shutdown Windows from inside the guest.
  3. Move the image over to the SATA controller by removing it from your current controller and adding it to the SATA controller
  4. Boot up Windows again and it should boot into Windows, detect the changes and prompt you to restart when done as per the above instructions

It is important to note that Windows adds new device drivers upon login, and not at boot time. Therefore, for a device such as the disk controller which is required to be present for booting, it is important to present this to Windows while using your existing controller. Otherwise, you’ll get blue screens at boot and be locked out of our VM.

FreeBSD

In FreeBSD all I had to do was update my /etc/fstab file to modify the devices to begin with /dev/ad4. Recent versions of FreeBSD should support AHCI out-of-the-box. I’ve tested this migrating from both IDE and SCSI, this was super easy! So:

  1. Make the changes to your /etc/fstab
  2. Power down, update your VM settings so that your image is attached to the SATA controller
  3. Power on the guest

Linux + LVM

In Linux all you have to do is make sure that the AHCI driver is running. To do this, I ran:

mkinitrd -v -f --with=ahci /boot/initrd-2.6.18-92.1.22.el5.img 2.6.18-92.1.22.el5

Modify this to use the kernel version you are running. I have only tested this moving from SCSI to SATA, there might be wrinkles if your physical volume name starts with something other than /dev/sda. If you are not using LVM I suspect that you’ll only need to change your /etc/fstab entries to start with /dev/sda. Most modern Linux distros use LVM by default, you can verify this with a “df” – LVM managed volumes will start with “/dev/mapper”.

I’ll fill in this section with more Linux information if I get any helpful comments or end up doing more Linux testing.

  • http://www.netmusician.org joe

    I just added a little paragraph to the bottom of the Windows section explaining the basic technique for switching disk controllers without locking yourself out of your VM…

  • Pingback: How To: Switch a VirtualBox Windows Guest Hard Drive from IDE to SATA Mode | r3dux.org

  • Per

    With regards to Win 7 IDE to SATA conversion, I found it to be unnecessary to remove the IDE controller.

    Instead, what worked for me was:

    1) Attach SATA controller with no drive in VB
    2) Boot into Win 7
    3) Shutdown Win 7
    4) Move your drive from the IDE to the SATA controller. Now, boot into Win 7.

    Seems that Win 7 just wants to see the SATA controller before successfully booting from a SATA disk.

    Thanks for your post and enabling me to finally mount my drive on the SATA controller!