Thursday, August 7, 2008

Thinking Outside the (Virtual) Box (3)

It was quite inevitable.

Following my previous escapades with WinXP and VirtualBox, I simply had to get my live-HDD running under VirtualBox...

The first step was to create a disk image that actually points to the raw disk (see section 9.9 in the VirtualBox User Manual):
VBoxManage internalcommands createrawvmdk -filename live-hdd.vmdk -rawdisk /dev/sda -register
The next step was to create a virtual PC in VirtualBox that's based on this image. And that was basically it. There's really nothing more to it.

Well, I've also installed the VirtualBox Guest Additions on the live HDD, and that wasn't as neat.

The X server on my live HDD is configured to auto-detect the video adapter, and it works just fine, allowing easy resizing of the virtual PC display. The mouse, however, is not auto-detected. I've added the following bit of shell-script at the end of do_start in /etc/init.d/bootmisc.sh, to fix this (note the use of lspci to figure out if this is a real or virtual session):
# Setup display
rm -f /etc/X11/xorg.conf.200*
# are we running inside VirtualBox ?
if [ -z "$(lspci -d 80ee:beef)" ]; then
# real
dpkg-reconfigure -fnoninteractive xserver-xorg
else
# virtual
/usr/share/virtualbox/x11config.pl
fi
The other issue is accessing the VirtualBox shared folder. It's done like this (as root):
modprobe vboxvfs
mount -t vboxsf -o uid=zungbang,gid=zungbang,rw /vboxsvr/tmp /mnt/vbox
(replace the colored parts with the your own stuff).

It seems that mount.vboxsf doesn't grok the noauto flag, so there's no way to add entries for shared folders in /etc/fstab, if, like me, you need these to not be mounted at startup.

I'm virtually happy now.

No comments:

Post a Comment