Importing Solaris VMDK image into Virtual Box
By user12611852 on May 15, 2008
Virtual Box 1.6 has been released and is no longer in beta for MacOS X. One of the advertised features is the ability to import VMDK image files from VMware into Virtual Box. Being the eternal optimist, I decided to try it. How long could it take? A few minutes maybe? I have quite a few different VMs in Fusion and did this with Solaris 10 08/07.
Virtual Box is:
- a type 2 hypervisor
- Open Source
- supported on a variety of host OSes (Windows, Linux, Macintosh and OpenSolaris)
- capable of running a variety of guest OSes
- now owned and being developed by Sun Microsystems as part of the open source xVM family of virtualization products
The first part was easy. Extract the VMDK file and import it into Virtual Box
- Right click on your chosen VM. Choose "Show Package Contents"
- Find a file with a .vmdk suffix. Click once to select
- Command-D (duplicate it) Wait a few minutes while Mac OS copies the multi-GB file
- Drag the copied file to another location
- Start Virtual Box
- File > Virtual Disk Manager
- Click Add. Locate and select the copied .vmdk file. Click OK.
- Create a New VM as usual using the added vmdk file
- Boot the VM
That should have been it, right? Unfortunately, after seeing the grub screen and attempting to boot Solaris, I entered an infinite loop of rebooting OS. Obviously, it's mostly working but something is still wrong. Luckily, inside of Sun, we archive our mail aliases and Rudolf Kutina had already posted a solution to the problem.
The rebooting sequence resulted from the fact that VMware Fusion emulates SCSI disks (c0t0d0s0) while VBox emulates IDE disks (c0d0s0). Because of this, the Solaris device trees and vfstab mount entries are not correct. Rudolf's solution is not for the weak of heart but DOES work. After all, it's all just a virtual machine and if I screw it up, I just make another copy. What have you got to lose?
- Boot into Solaris Safeboot mode. You can get access at the Grub menu, usually is the 2nd or 3rd option.
- Mount the found Solaris partition on /a , Safeboot will usually find the slice on the disk with Solaris and ask if you want it to mount on /a. Select Yes.
- Move /a/dev, /a/devices, and /a/etc/path_to_inst to another name (I just append .orig) and then create new directories, (mkdir) /a/dev and /a/devices, and touch file /a/etc/path_to_inst.
- Run "devfsadm -r /a" to rebuild the device tree
- set TERM so we can use 'vi', TERM=vt100; export TERM
- Now we need to fix boot disk patch changes Edit /a/boot/solaris/bootenv.rc and fix the line with "setprop bootpath '/pci@0,0....' to match the path you'll find mounted for /a (i.e. run a 'df -k' command, and you should see /a mounted from /dev/dsk/c1d0s0 or something, then run 'ls -l /dev/dsk/c1d0s0' or whatever your device listed was, and you should see the actual link point to ../../devices/pci@0,0/...ide..)
- Fix also disk naming in /a/etc/vfstab to match IDE "c0d0sx" scheme. Change each instance of c1t0d0s0 to c0d0s0 etc.
- Recreate archive "bootadm update-archive -v -R /a" to rebuild the boot-archive on /a
- Force to reconfigure on next boot with 'touch /a/reconfigure'
- Delete /etc/dhcp.e1000g0 /etc/hostname.e1000g0 create /etc/dhcp.pcn0.
- Run "cd /; sync; sync; sync; umount /a"
- reboot with 'init 6'
Enjoy your new Virtual Box machine.
Instructions are also available for importing a Windows XP .vmdk file to Virtual Box.