Due to the nature of my research, some things are easy in Windows and hard on Linux and other things are easy on Linux and hard on Windows. What I'd like to do is have a dual-boot setup where I can access my Ubuntu "VM" as either from VirtualBox in Windows 7 or selecting it at boot.

Before I go off on the deep end and try to get this to run, I'd like to bounce some ideas off people. My first idea is to start with:

Then I can boot the the 30G NTFS partition, set c:/Users, c:/Program Files* to point to subdirs on the 190G partition. Then I can boot the 500M Ubuntu partition and use FUSE to mount / from the 190G partition.

Now I can setup a Ubuntu VirtualBox guest on Windows 7. I pull the same trick and get / mounted from the 190G partition. That way, the size of the virtual disk is quite small, and only really contains virtualization specific things.

So my question is: which of the directories under / do I need to keep separate in the two instances? My assumption is /boot and /etc any others? Will this work at all?

Hi. I think this will be really hard if not impossible to implement. You will run into problems because of the different hardware / drivers depending on the boot method. Why do you want to be able to boot the linux vm as phyiscal machine? I don't see any advantage for this. Take a look at the citrix XenClient (citrix.com/English/ps2/products/feature.asp?contentID=2300346) if you want to create VM's which have 'access' to the hardware.
–
grubSep 30 '10 at 16:22

The goal is to run two different kernels with different sets of modules that share the same application stack. It seems like it would be possible to just, for example, get away with /home and then install all my apps in /opt. I was hoping for something more seamless though.
–
Nathan VanHoudnosSep 30 '10 at 17:41

what exactly are you trying to accomplish by doing this? Is there specific hardware that both OSes need access to or something along those lines?
–
Chris S♦Sep 30 '10 at 21:16

@Chris, I do a lot of number crunching (MCMC and things that are embarrassingly parallel) on both windows and linux. The hope is to be able to do my "light work" in the ubuntu VM and only have to reboot when I want to run something heavier or do sustained development. Ideally, windows would be able to run as a vm under ubuntu, but as alluded below, I don't think that will work without a lot of tinkering.
–
Nathan VanHoudnosSep 30 '10 at 22:39

1 Answer
1

Assuming that VirtualBox allows you to use the real-machine partition as a virtual-machine partition or disk, you can boot the same Linux installation indifferently in the VM or on the real hardware. Live CDs do it all the time, and it's not particularly constraining. (As far as I know, this is a lot harder to achieve for Windows.)

If the partition layout is different, you'll have to have separate bootloaders, or at least separate bootloader configurations. You don't even need to actually separate /boot from the main installation: leave it in, set it up properly for direct booting, and use a different bootloader (such as a standalone Grub (virtual) floppy) in the VM.

You might want some settings (e.g. network configuration) to be different depending on whether you're running on the hardware or in the VM. You can test whether the system is running inside VirtualBox with VBoxControl.

Linux loads most drivers automatically. The only common exception is proprietary video drivers, which might require you (or an automated setup program) to write a brand-specific /etc/X11/xorg.conf. You can get the X server to read a different configuration file with its -config option or with the XORGCONFIG environment variable.

If VirtualBox doesn't allow using the real-machine partition directly inside the VM, you might have to resort to mounting the root filesystem over vboxvfs. This requires an initrd containing the VirtualBox kernel modules, which you can build with update-initramfs.

"As far as I know, this doesn't hold for Windows at all" - You can achieve this kind of thing with Hardware Profiles, but it's not particularly pretty.
–
Chris ThorpeSep 30 '10 at 21:48

Actually, VMware Fusion (the Mac version of VMware Workstation) will allow a single native Windows "Boot Camp" partition to be used both as a guest VM and as a bare-metal/dual-boot OS. Windows has to be activated once in each configuration, but, after that, it doesn't require reactivation. No manual configuration of hardware profiles is required on the user's part, but I'd imagine that quite a lot happens behind the scenes.
–
SkyhawkSep 30 '10 at 21:57