I’m interested in customizing the excellent clonezilla, so that we can simplify our imaging operations. The easiest way to do that is to create a bootable and customizable USB thumb drive. I was then hoping to test the thumb drive customizations using VirtualBox running on my Mac. Booting Virtualbox from a USB key is something of a chore.
Here are the steps that I went through – I’m writing them down just in case I need the information again in the future.
- Follow the instructions on how to create a bootable clonezilla thumbdrive.
- Customize the thumbdrive to do whatever it is you need it to do.
- Create a new guest machine in Virtualbox for testing. Configure this with a normal OS, etc. Next, you’re going to create a special VMDK disk file that points at the thumb drive. This means that you are going to leverage VB’s ability to use an entire physical disk as a virtual disk on a virtual machine.
- Shutdown the guest OS and Virtualbox.
- You need to know the name of the disk file that will become the raw hard disk for the VB guest machine. Insert your thumbdrive. Allow it to mount. Open a terminal window. Type the command “diskutil list” at the command prompt. Figure out the device name of the thumb drive. This is a classic “measure twice, cut once” situation. If you mess this up, you can render your host system unusable. In my case, it was “/dev/disk2”.
- Add a “raw” host hard disk to the Virtualbox machine by doing this in Terminal:
$ cd /Applications/VirtualBox.app/Contents/MacOS/ $ sudo -s # diskutil unmount /Volumes/UNTITLED # ./VBoxManage internalcommands createrawvmdk -filename /Users/bjchapm/usb.vmdk -rawdisk /dev/disk2 # chmod 666 /dev/disk2
That’s about it. You need to become root (using sudo) so that you can run the unmount command to take the thumbdrive away from OSX. At this point, you will need to add the VMDK file to Virtualbox the way that you would add any new disk to a virtual machine. Now you’re ready to test the USB thumbdrive.
Note that any time you stop Virtualbox, OSX will re-assert control over the USB key. You will need to open a terminal window and run “sudo diskutil unmount /Volumes/UNTITLED” manually before launching Virtualbox.
Please share your thoughts in the comments.