Triple Boot, Part 4: Windows via VirtualBox
By Gregg Sporar on Jul 21, 2008
<< Back to Part 3, Install OpenSolaris
After setting up my triple-boot system, I was not content. I want access to Windows Vista and Ubuntu 8.04 without having to restart my system. I mostly run OpenSolaris and rebooting to switch to Vista or Ubuntu is a disruption. If I need to do some sort of benchmarking or a lengthy task on Vista or Ubuntu then it is worth the time to reboot. But there are several use cases where I just want to do something quickly and then go back to what I was doing in OpenSolaris.
With Vista, typically I just want to edit an OpenOffice document, usually a presentation. I frequently edit presentations that were originally created by someone who was running OpenOffice on Windows. Since OpenOffice does not embed the actual fonts in the document, editing a document created on Windows while running OpenOffice on a non-Windows operating system can cause problems. Even with fonts such as Arial - Arial on Windows is not exactly the same as Arial on OpenSolaris, Ubuntu, etc. As a result, items in the documents frequently do not align correctly.
So I need the ability to quickly and easily run Windows Vista for just a few minutes without having to shutdown OpenSolaris, boot Vista, and then shutdown Vista and restart OpenSolaris. There is an easy solution: VirtualBox.
Installing VirtualBox is painless, just be sure to download the correct version for OpenSolaris: 32 or 64 bit. On my system, which has an Intel Core 2 Duo chip, OpenSolaris runs in 64-bit mode, as confirmed by the isainfo command:
firstname.lastname@example.org:~$ isainfo -k amd64
VirtualBox is a small download and it installs quickly. It is very easy to use - I did not need the documentation until I started doing advanced configuration type stuff.
In VirtualBox I created a virtual machine for Windows Vista and then I had to make a choice:
- Use the existing Vista installation that was already on my hard disk. In other words, configure the virtual machine to use the NTFS partition on my hard drive and let it boot Windows Vista from the same installation that boots from the bare metal.
- Create a virtual disk image (.vdi) file and configure the virtual machine to use it. The .vdi file would be empty, so this would require getting a Vista DVD so that I could run the Windows installer, etc.
I ultimately decided to go with option 2 because of complications with option 1:
- There are some Windows configuration and activation issues. There is a very detailed tutorial available that describes how to accomplish option 1 with Ubuntu as the host operating system and Windows XP as the guest operating system that is running in the virtual machine. I assume the same basic approach would work with OpenSolaris as the host and Vista as the guest, but I am not very knowledgeable about the differences between XP and Vista, especially in the all-important area of hardware profiles (which are key to making option 1 work).
- VirtualBox has a nice feature that I like to use called "guest additions." These are device drivers that get added to the guest operating system to enable full screen mode, seamless mode, better mouse integration, etc. According to that tutorial, if you choose option 1 then installing the guest additions is a bad idea because after the guest additions are installed, Windows will no longer boot from the bare metal.
Option 2 was easy to setup and then I was able to run the installer for Windows Vista from a DVD. I added the VirtualBox guest additions and everything worked great.
There was just one problem: when running Vista in that VirtualMachine, I have no access to all that data on my hard drive's NTFS partition. It should be noted, this is not a limitation of VirtualBox - it is possible to configure "shared folders" that allow the installation of Vista that is running in a virtual machine to read/write any directory that OpenSolaris can access.
The problem is that OpenSolaris 2008.05 cannot access my NTFS partition because it does not include any support for NTFS partitions. You can add some packages to it in order to get read-only support for NTFS (see this entry from Pradhap for details), but I would like to be able to write files to the NTFS partition as well.
Once again, VirtualBox provides a solution.
VirtualBox supports raw access by a virtual machine to the host operating system's disk drives. The details are provided in section 9.9 of the VirtualBox 1.6.2 User Guide, which you will need to study before attempting this on your own system. Section 9.9 includes this important warning:
of an outdated configuration can lead to total loss of data on the physical
disk. Most importantly, do not attempt to boot the partition with the cur-
rently running host operating system in a guest. This will lead to severe data
I wanted to provide access to the NTFS partition only, so I attempted to follow the instructions in section 9.9.2 of the documentation. Unfortunately, the VBoxManage command described in section 9.9.2 does not work in VirtualBox 1.6.2 when run on OpenSolaris - the bug is documented here.
Luckily, I have other operating systems installed on this machine. :-) I booted up Ubuntu and used the VBoxManage in my installation of VirtualBox on Ubuntu to find out the partition numbers used by VirtualBox:
gs145266@gs145266-laptop-ubu-804:~$ sudo VBoxManage internalcommands listpartitions -rawdisk /dev/sda [sudo] password for gs145266: VirtualBox Command Line Management Interface Version 1.6.2 (C) 2005-2008 Sun Microsystems, Inc. All rights reserved. Number Type StartCHS EndCHS Size (MiB) Start (Sect) 1 0x27 0 /32 /33 888 /172/52 6970 2048 2 0x07 888 /172/53 1023/254/63 63415 14276608 3 0xbf 1023/254/63 1023/254/63 72927 144151245 5 0x83 1023/254/63 1023/254/63 972 293507613 6 0x82 1023/254/63 1023/254/63 3827 295499673 7 0x83 1023/254/63 1023/254/63 42667 303339393
Partition 2 is the NTFS partition, so I created the files described by section 9.9.2 by using this command:
gs145266@gs145266-laptop-ubu-804:~$ sudo VBoxManage internalcommands createrawvmdk -filename /home/gs145266/part2Access.vmdk -rawdisk /dev/sda -partitions 2 VirtualBox Command Line Management Interface Version 1.6.2 (C) 2005-2008 Sun Microsystems, Inc. All rights reserved. RAW host disk access VMDK file /home/gs145266/part2Access.vmdk created successfully.
In addition to part2Access.vmdk, VBoxManage also created part2Access-pt.vmdk. I copied both files to a USB drive and then rebooted the system in order to bring up OpenSolaris.
The content of part2Access.vmdk was:
# Disk DescriptorFile version=1 CID=4920ffa0 parentCID=ffffffff createType="partitionedDevice" # Extent description RW 63 FLAT "part2Access-pt.vmdk" RW 1985 ZERO RW 14274560 ZERO RW 129874637 FLAT "/dev/sda" 14276608 RW 149356367 ZERO RW 1 FLAT "part2Access-pt.vmdk" 63 RW 1991997 ZERO RW 63 FLAT "part2Access-pt.vmdk" 64 RW 7839657 ZERO RW 63 FLAT "part2Access-pt.vmdk" 127 RW 87382575 ZERO # The disk Data Base #DDB ddb.virtualHWVersion = "4" ddb.adapterType="ide" ddb.geometry.cylinders="16383" ddb.geometry.heads="16" ddb.geometry.sectors="63" ddb.uuid.image="840529aa-1989-46ce-c09e-7d3bbec98243" ddb.uuid.parent="00000000-0000-0000-0000-000000000000" ddb.uuid.modification="00000000-0000-0000-0000-000000000000" ddb.uuid.parentmodification="00000000-0000-0000-0000-000000000000"
Note the value in bold: /dev/sda, which of course is the device name for my hard disk in Linux. I changed it to the value that OpenSolaris would expect on my system: /dev/dsk/c5d0p0 and then saved the file.
The final step was to make it available to the virtual machine. In order for this to work, VirtualBox has to be run with enough privileges to get raw access to the disk drive. So I modified the GNOME menu entry for VirtualBox so that it is started by pfexec:
After starting VirtualBox, I added part2Access.vmdk as a virtual disk by using File > Virtual Disk Manager > Add. Then I was able to add it as the IDE Primary Slave device for my Vista virtual machine:
And now when I run Vista in that virtual machine, it sees my NTFS partition on my hard disk as drive E: