Linux – Dual-boot or virtual machine for Linux programmer that does some Visual Studio development

bootlinuxvirtualizationvisual studiowindows

The scenario:

  • I am a freelance software developer that mostly develop on Linux (Python, MySQL, MongoDB etc.)
  • My work computer is a Lenovo laptop w/ a i7 processor and 8GB RAM. Big HD + 128 GB SSD. The OS is Ubuntu Linux

I might get some .NET/C# projects in the near future, I am therefore looking for some guidance on the following:

  • Should I go for a dual-boot solution or use virtual machines for Windows stuff?
  • If I go dual-boot: What is the recommended installation sequence? Windows first or Linux first? (I'm looking at a complete Ubuntu reinstall to get the latest LTS anyway so I can start install everything fresh)
  • If I go VM: How does VMWare Workstation and VirtualBox compare performance-wise?
  • My dream setup would probably be the following:
    • Dual boot
    • But if I boot into Linux, I can boot the Windows partition as a virtual machine. Is this possible?
    • And/or: If I boot into Windows, I can boot the Linux partition as a virtual machine. Is this possible?

Best Answer

Others have covered the rest of your question, but I see they have left this part unaddressed:

But if I boot into Linux, I can boot the Windows partition as a virtual machine. Is this possible? And/or: If I boot into Windows, I can boot the Linux partition as a virtual machine. Is this possible?

The short answer is yes.

The long answer is yes, but with number of caveats and implications.

Until this January (when we got new machines), I had my work computer configured to either dual boot, or to use Linux as a host for a Windows 7 VM which directly accessed the Windows partition. I never bothered trying to use Windows as a host for a direct-disk Linux VM, but it is also possible. My computer used legacy BIOS/MBR, I am not sure how to do this if you use UEFI/GPT.

I chose VirtualBox to do it, but from what I understand it should also be possible with VMWare.

Performance was perfectly acceptable for my purposes; I gave Windows 1 CPU core, 2GB of memory, 1 monitor, and I don't remember how much video memory. The VM was capable of playing video and working with my Java GUI application and many rich-content websites.

I'll discuss the weirdness before going into details:

  • Switching between Native-boot and VM-mode Windows 7 triggered Windows's warning that my copy of Windows was not be genuine. Depending on your license, MS may consider this a breach of license by installing on two pieces of hardware. I also needed to "repair" my installation because many of the low-level drivers are different for the real hardware and the VM "hardware."

  • Every time Windows Update ran (or any other large disk I/O operation), my hard disk was crushed under load and everything on both machines became dog slow. Moving each OS to its own dedicated hard drive fixed this problem nicely; using a solid state drive would have also solved the issue.

  • For some reason, Ubuntu occasionally didn't like waking up after suspending (maybe 20% of the time), which was the equivalent of a hard power-off for my Windows VM. As a result I would power down the VM every evening before suspending the host.

  • I had to be very careful to never attempt to mount the Windows partition in Linux to prevent possible data corruption/loss. I quickly added a udev rule to prevent this.

Alright, if that doesn't sound too bad, here are the details: The most useful reference I found to do this is this blog: http://www.rajatarya.com/website/taming-windows-virtualbox-vm. Here are the steps summarized:

  • RTFM. Really. You will be using commands that could corrupt your file system if done wrong.

  • Find the partitions.

  • Change the permissions for your partitions (alternatively you could boot your VM using sudo, but then any files created on the host/guest shared drive will be owned by root).

  • Create an MBR so the guest doesn't try using the normal bootloader.

  • Use a VirtualBox internal command to create the vmdk image to use for the VM.

  • Create the VM. Have it use the vmdk you just created.

  • Boot and repair your installation.

I would expect to find many of the same issues using a Windows host, but Linux would probably handle the different hardware more elegantly. It really might be easier though to use a shared /home (and maybe /opt) partition(s) and just have different root partitions for the native vs guest machines.

Related Question