Can’t decide whether you want to dual-boot that second OS or virtualise it? Debate no more: you can have both. Here’s how to dual-boot and virtualise the same partition on your Windows PC or Mac.
Once you’re finished, you’ll be able to reboot into your secondary OS and run it natively, or run it in your favourite virtualisation program without having to reboot. You’ll get the best of both worlds, and you’ll never have to decide between the two again.
The process is a little different for every OS, but we’re not going to go through every possible combination here. We will, however, go through some of the more popular ones and provide some resources for you to research your own individual setup. Everyone’s is different, so you may have to do some tweaking to get it to work properly.
Windows Users: Virtualise Your Linux Partition
If you’re primarily a Windows user but want occasional access to your Linux partition, you can do so using some of VirtualBox’s built-in tools.
WARNING: These tools are very advanced and are considered “expert” tools in VirtualBox. You’ll need to do some command line work to make it happen, and there’s a reason: without the proper precautions, you could cause serious data corruption on your Windows partition. Use these instructions at your own risk and for God’s sake, back up all your data before you try this, and keep your data backed up regularly! We also highly suggest you read the corresponding chapter in VirtualBox’s manual before you continue.
We’re going to use Ubuntu for this tutorial, but you should be able to reproduce the steps with other Linux distributions. Also, if you have proprietary graphics drivers, you may encounter problems — VirtualBox has trouble with 3D acceleration in this setup. For now, it’s best to use the default open source graphic drivers. Check out the video below for an overview of the process, then read on for the individual steps.
Step 1: Create Your New Virtual Machine
Assuming you already have both partitions set up, boot into Windows and perform the following steps:
- Back up everything before you begin. No, I’m serious. Don’t skip this step. Don’t!
- Open up a Command Prompt as an administrator and run the following command:
wmic diskdrive list brief /format:listFind the drive on which your Linux partition resides and note its number (in my case, it was Disk 0)
- Use the CD command to change to the directory in which VirtualBox is installed. For me, this was:
CD "C:Program FilesOracleVirtualBox"
- Run this next command, replacing the variables with the correct ones for your system:
VBoxManage internalcommands createrawvmdk -filename "C:UsersWhitsonDesktopUbuntu.vmdk" -rawdisk .PhysicalDrive0Replace the file path with wherever you want to put your VMDK file. Replace the 0 in .PhysicalDrive0 with your disk number.
- You should get a message saying the VMDK was created successfully. If not, make sure you followed these steps exactly, and if you’re still having problems read through that manual chapter. You may have special needs that we didn’t discuss here.
Step 2: Create a GRUB ISO
Now, boot into Linux. We’re going to use Ubuntu for this example. Before we set up our virtual machine, we’ll need to put the GRUB bootloader on an ISO, since not all computers will load your existing version of GRUB properly. Once you’re inside Linux, perform the following steps:
- Create a new folder on your desktop and call it “iso”. Inside that folder, create one called “boot”, and inside the boot folder, create a folder called “grub”.
- Open a terminal and run the following command:
cp /usr/lib/grub/i386-pc/* /home/yourusername/Desktop/iso/boot/grubObviously, replace “yourusername” with your user name.
- Next, run:
cp /boot/grub/grub.cfg /home/yourusername/Desktop/iso/boot/grub
- Run the following command:
sudo nano /home/yourusername/Desktop/iso/boot/grub/grub.cfgScroll down to the section that says “menuentry ‘Windows’” or something similar and delete everything from “menuentry” to the “}” at the end of that section.
- Lastly, run:
grub-mkrescue -o boot.iso /home/yourusername/Desktop/iso/If you get an error saying “xorriso: not found”, you may have to install the xorriso package with:
sudo apt-get install xorrisoWhen you’re done, you should have a file called boot.iso in your home directory. Copy this to a flash drive or to your Windows partition.
Step 3: Boot Into Your New Virtual Machine
Now, it’s time to boot back into Windows and get this sucker up and running. Once you’ve returned to Windows:
- Run VirtualBox as an administrator. Click the New button and name your virtual machine. Choose the amount of RAM to allocate to the virtual machine as normal.
- At the next step, choose “Use an existing virtual hard drive file”. Click the browse button on the right and browse to the VMDK file we made earlier. Click the Create button. If all goes well, you should see it show up in VirtualBox’s sidebar.
- Select your new virtual machine in the sidebar and click the Settings button. Under Storage, select “Controller: IDE” and click the plus sign next to it. Press “Choose Disk” and navigate to the boot.iso file we created earlier. Click OK and return to the main VirtualBox screen.
- Select your new virtual machine and click the Start button. Choose Linux from the GRUB menu that pops up.
- If all goes well, you should see your Linux installation’s login screen. You can log in, install VirtualBox’s Guest Additions, and use your Linux partition without shutting down Windows!
IMPORTANT NOTE: Never try to mount or read from your Windows partition while you’re running Linux in VirtualBox. This is where the danger of this method comes in. If you try to read your Windows partition, your machine will crash and you could cause data corruption (since your host OS is already using that partition). In fact, I recommend removing it from your fstab file so it never pops up in Linux, thus keeping you much safer.
Mac Users: Virtualise Your Windows Partition
Mac users have it easy: both Parallels and VMWare Fusion allow you to run your Boot Camped Windows partition without leaving OS X, and they do it in a way that’s safe and incredibly easy. We like Parallels around here, so we’ll use it as an example. If you don’t own Parallels and you boot into Windows often, we highly recommend picking it up — it’s well worth the cost, and it goes on sale all the time.
- Install Parallels and start it up. From the main screen, choose “Use Windows from Boot Camp”.
- Check the “I want to continue” box and click Continue. Parallels will import your Boot Camp partition, which may take a few minutes.
- When it’s done, click the “My Boot Camp” button to run your Windows installation inside Parallels.
From here, you can run Windows in its own Window or use “Coherence Mode”, which allows you to run Windows programs as if they were standalone apps on your Mac desktop. Easy, huh?
Virtualising Windows and OS X in Other Situations
The above methods are the two most common things you’ll encounter, but if you want to virtualise Windows from Linux, Windows from Windows, or OS X from anything, you’re going to have a harder time. Virtualising Windows from Linux or Windows is possible, but it’s much more difficult and can be a bit more dangerous to your data. If you want to do so, we recommend proceeding with extra caution. We aren’t going to get into the nitty gritty here, but this article should help you get started.
Virtualising a Mac partition is going to be extremely difficult, if it’s even possible at all. We’ve shown you how to run OS X in VirtualBox before, and, if you recall, it’s a pretty hairy process. Throwing another spanner into the equation is going to make it all the more difficult, so we haven’t tried it here. If you do, give us a shout and let us know how it goes.