Ubuntu – Windows 7 Dual Boot + Virtualization under Ubuntu 10.04

dual-bootUbuntuvirtual machinewindows

Question: I currently have a dual boot: Win 7 x64 Pro & Ubuntu 10.04.1 x64. Is there a way to boot Win 7 as a virtual machine under Ubuntu without reinstalling anything, in addition to maintaining the ability to dual boot?

Background: I have a dual boot system with Windows 7 installed on one partition in a Raid 5 and Ubuntu 10.04.1 installed in a separate partition (actually split across three) in the same Raid 5. I have a Core i7-930 with 6GB of RAM. I'd be happy to provide any other hardware specs.

I require Windows 7 x64 Pro for only a small number of things, basically just VS 2008 / VS 2010 so that I can use nSight from nVidia to debug CUDA / OpenCL projects.

I must be able to dual boot because (and this is more just my suspicion) I don't want any more between the software and the three graphics cards that I have installed than is absolutely necessary. If it means anything, when in production mode where I'm running without virtualization, I have two cards set to exclusive mode and one set to prohibited mode (to drive the display). I'm worried that running nvidia-smi under either Ubuntu as the host OS or Win 7 as guest OS might bollux things up.

I don't know much about Xen, KVM, etc. I've played around a bit with them, but I'm more than willing to use any virtualization software as long as it's free and it can accomplish what I want. Note that I'm a student — this is all non-commercial development.

I can, if absolutely necessary, reinstall everything, but I had many, many problems getting the CUDA environment to work under VS 2010 — I installed/uninstalled/reinstalled VS '08 & '10 so many times that it corrupted the Win 7 registry and I had to start over from scratch. Now that it's working as a dual boot, I'd really like to avoid starting from scratch a fourth time.

Best Answer

The on-topic part: yes, you can run a virtual machine under Ubuntu.

CUDA requires direct access to the hardware. That means you'll have to run Windows either directly on the hardware or on a virtualization engine that allows a virtual machine to access hardware devices directly. That pretty much means hypervisor-based virtualization. VirtualBox is definitely out. Google suggests that Xen will do.

Running a single Windows installation in different hardware configurations (such as the bare metal and a virtual machine) is notoriously difficult. If you really don't want to install Windows, you might prefer to run Ubuntu in a VM under Windows.

It's not clear from your question whether you also want to run CUDA programs in Ubuntu. If you do, you can boot your existing installation on pretty much any hardware, there's little if any setup required. This does require a virtualization system that can bind a disk partition inside a VM, which I think VMWare can do but not VirtualBox. (It's also possible with VirtualBox by making a custom initrd with the vboxsfs module, but that's no longer no-setup-required. An alternative method is to clone the system partition to a virtual machine disk.) ADDED: You might want to investigate AndLinux, which is a port of Ubuntu to CoLinux, a Linux port running on top of Windows; I don't know whether CoLinux can support CUDA.

Given your workflow, I think your best bet is Xen. If this turns out not to work so that you need to dual boot, note that both OSes support hibernation, so with the right setup you can switch relatively quickly between the two (without needing to log in, restart all programs, etc.).

Related Question