I also posted this over at linuxquestions.org. I hope you may find it useful here as well.
I don’t know if this is posted in the correct forum, but I wanted to share some information that I couldn’t find on the internet, and had to hack my way through. (Moderators, please feel free to move/edit this post.) NOTE: I use openSUSE 11.2, so other distro may do things differently.
I have a dual-boot machine, and I like to use VirtualBox, but I don’t want to have duplicate VB’s on each partition. I wanted to create a guest VB, and be able to use it from either Host Windows or Host Linux, so any changes I made while booted in Linux using the shared VB would be available when I booted to Windows using the share VB. I received all sorts of weird problems when trying to do this.
The problem I had is that I was trying to share the actual IMAGE/Machine. Instead create a VB Image/Machine and share the HARD-DRIVE!!! This is actually pretty clever the way VB does it. You can create VBoxes that have no hard drive. You can create Virtual HardDrives that aren’t connected to any machine. Or you can connect Virtual Hard Drives to different Machines (similar to what we do in the labs). The only problem I ran into was the read/write permissions of using a file on a windows partition.
Here is what I had to do to accomplish this.
First - create the VB image in Windows. Include all the configurations you want.
When you boot to linux, your Windows Drives must be mounted. By default, linux mounts NTFS drives as “ntfs-3g” and makes them read-only. (That is how openSUSE does.) You have to unmount the windows drive, and remount it with different permissions.
Example: Your Windows “C” drive is mounted read-only as an NTFS-3G filesystem under /windows/C Let’s say this is under /dev/sda1
So you would issue (as root)
umount /dev/sda1
OR
umount /windows/C
Then remount the drive with these options
mount -t ntfs-3g -o inherit /dev/sda1 /windows/C
The other option is to edit your /etc/fstab file. Mine had an entry like this:
/dev/disk/by-id/ata-ST9500325AS_5VE3C3LX-part2 /windows/C ntfs-3g users,gid=users,fmask=133,dmask=022,locale=en_US.UTF-8 0 0
Which basically was seen by the OS as /dev/sda2
I edited the line to look like this:
/dev/disk/by-id/ata-ST9500325AS_5VE3C3LX-part2 /windows/C ntfs-3g rw 0 0
Now - all those pesky read/write permissions don’t get in the way.
I start VB in Linux - create a NEW MACHINE, and attach the EXISTING Virtual Hard Drive from my Windows partition. I also set up the network adapters to be the same. (Example: NIC1 is bridged to my Wired LAN in windows, and to eth0 in linux. NIC2 is bridged to my WIFI card in Windows, and to wlan0 in linux.) Now - I can just connect/disconnect the cable to the correct virtual NIC depending on how my host machine connects to the network.
Whew! Hope that helps!