Configuring a single Ubuntu installation as a dual-boot option and a VirtualBox appliance under Windows 10

I often need to use Windows 10 and Ubuntu on the same machine within a single login session, so I run Ubuntu as a virtual machine in Oracle VirtualBox. But I also like to be able to boot my computer natively into Ubuntu, so a dual-boot configuration is optimal. 

To get the best of both worlds, I install Ubuntu in a dual-boot configuration alongside Windows, and configure VirtualBox to access the Ubuntu disk partitions as a raw disk image. This allows me to boot directly into Ubuntu, or boot the same Ubuntu installation from within Windows using VirtualBox.

This configuration was performed successfully using Ubuntu 14.04.4, Windows 10 Pro v.1511 build 10586, and VirtualBox 5.0.24 for 64-bit Windows.

Step 1: Enable Virtualization Technology

Direct hardware access is key to this configuration, so make sure that virtualization technology is enabled in your BIOS, specifically Intel VT-x or AMD-v

Step 2: Download and Verify the Ubuntu ISO

Download the ISO you'll be installing on your system. In this example, we're installing the 64-bit Desktop version of Ubuntu 14.0.4.

Verify the ISO before installing. Download SHA256SUMS and SHA256SUMS.gpg from the same directory that contains the ISO. For Ubuntu 14.0.4, the files are here (random U.S. mirror). 

Use gpg to verify the authenticity of SHA256SUMS. (If you are on a Windows-only machine, gpg is available as a package for Cygwin.)

Download the Ubuntu public key, and add it to gpg's keyring:

gpg --keyserver hkp:// --recv-keys 0xEFE21092

Verify the key's fingerprints:

gpg --list-keys with-fingerprint 0xEFE21092

Verify the file SHA256SUMS using the signature in SHA256SUMS.gpg:

gpg --verify SHA256SUMS.gpg SHA256SUMS

If you see "Good signature," the file is verified. (You may receive a message about the key not being certified with a trusted signature, which means that you have not specifically marked Ubuntu's key as trusted. This message can be ignored.)

Finally, verify the ISO. SHA256SUMS will contain several checksums, so grep only the one you need and check it with gpg.

sha256sum -c < (grep ubuntu-14.04.4-desktop-amd64.iso SHA256SUMS)

Step 3. Create a Partition for the Ubuntu Installation

Create a partition for Ubuntu to use, using the disk partitioning utility of your choice. In this example, I'm starting from a Windows install so I use Windows 10 Disk Manager. Windows 10 occupies the entire disk; I need to carve out some space for Ubuntu.

Right click the Windows partition and select Shrink Volume.

Create a partition

For my purposes, 20GB is enough for Ubuntu so I shrink the Windows volume by that amount:

Shrink the Volume

The operation successful, and I'm left with a little less than 20GB of unallocated space:

New partition layout

Step 4: Create Bootable Ubuntu media

Next, create bootable USB media from the Ubuntu ISO. This process overwrites ALL data on the thumbdrive, so move any pre-existing data off the thumbdrive before proceeding.

Creating Bootable USB in Linux:

Determine the device name of your USB disk with lsblk. If the disk is mounted, unmount it now.

You can write the ISO using the dd utility. As root:

dd bs=4M if=/path/to/ubuntu-14.04.4-desktop-amd64.iso of=/dev/sdx && sync

Where sdx is the device identifier of your USB disk, e.g. sdb. Do not specify a partition, such as sdb1.

Creating Bootable USB in Windows 10:

I recommend using Rufus, a free Windows application. In the Rufus dialog, you can select your source ISO by clicking the removable media icon (indicated here with a red arrow).

Rufus Dialog

When you're ready to create the USB, click Start.

Step 5: Install Ubuntu

Boot your computer from the USB drive, which will start the Ubuntu Live session. Choose to Install Ubuntu Alongside Windows 10

When installation is complete, remove the installation media and reboot. You will be greeted by a GRUB boot menu. Select Ubuntu.

Step 6: Update Ubuntu

Log in to Ubuntu, open a terminal and bring your system up to date.

sudo apt-get update && sudo apt-get upgrade

If you will be installing the VirtualBox Guest Services to enhance your virtualization experience, install the kernel module build requirements:

sudo apt-get install dkms build-essentials linux-headers-generic

You might also want to install your preferred window manager now:

sudo apt-get install openbox

Step 7: Create VirtualBox Raw Disk Image of Ubuntu Partition

Boot into Windows 10. If you have not already installed VirtualBox, do so now.

Open a command prompt as Administrator. Use the Windows Management Instrumentation Command-line (WMIC) tool to get the DeviceID for the physical disk drive:

wmic diskdrive list brief /format:list

In this example, our DeviceID is \\.\PHYSICALDRIVE0.

In the Administrator Command Prompt, change directory to your VirtualBox installation directory and use VBoxManage to list all partitions on that drive:

cd "\Program Files\Oracle\VirtualBox"
VBoxManage.exe internalcommands listpartitions -rawdisk \\.\PHYSICALDRIVE0

Output will resemble the following:

Number  Type  StartCHS     EndCHS       Size (MiB)  Start (Sect)
1 0x07 0 /32 /33 1023/239/63 217962 2048
6 0x83 1023/254/63 1023/254/63 16110 446392320
5 0x82 1023/254/63 1023/254/63 3891 479385600
2 0x27 1023/239/63 1023/239/63 508 487354368

Here, partition number 1 is my Windows installation, and partition 2 is my Windows Recovery partition. Partition 6 is my Ubuntu installation, and partition 5 is the Ubuntu swap partition.

I want to create a raw disk image which provides access to my Ubuntu partitions, which are partitions 5 and 6. For this configuration, the VBoxManage command is:

VBoxManage internalcommands createrawvmdk -filename “C:\path\to\ubuntu-raw.vmdk” -rawdisk \\.\PHYSICALDISK0 -partitions 5,6

Where C:\path\to\ubuntu-raw.vmdk is the location of the raw disk image file to be created. 

Step 8: Create a GRUB ISO

Ubuntu needs GRUB to boot, but the Ubuntu virtual machine will not have access to the default GRUB installation because it resides on your Windows partition.

In this step we create a bootable GRUB Recovery ISO which the Virtual Machine will use to boot into Ubuntu.

In Ubuntu, choose a location (such as a temporary directory) and create the directory structure iso/boot/grub.

mkdir -p iso/boot/grub

Copy the contents of /usr/lib/grub/i386-pc/* into iso/boot/grub:

cp /usr/lib/grub/i386-pc/* iso/boot/grub

Then copy /boot/grub/grub.cfg into the same directory:

cp /boot/grub/grub.cfg iso/boot/grub

Edit this copy of grub.cfg with your favorite text editor:

vi iso/boot/grub

In this file, locate and remove the boot menu entry for Windows 10. It looks like this:

menuentry 'Windows 10' {

Comment out or delete this menu entry (everything between menuentry and }, inclusive). Write the changes to grub.cfg and exit the editor.

Next, use grub-mkrescue to create a bootable GRUB ISO. This requires GNU xorriso. If you do not already have it installed, install it now:

sudo apt-get install xorriso

Run grub-mkrescue, specifying your iso directory:

grub-mkrescue -o boot.iso ./iso

This creates the bootable GRUB recovery ISO boot.iso, which must be transferred to Windows 10. Copy it to your USB thumbdrive.

Step 9: Create Virtual Machine in Windows

Boot into Windows 10. Copy boot.iso to a location suitable for long-term access, such as your VirtualBox VMs directory, or your Documents folder.

Launch VirtualBox as Administrator. It's important that VirtualBox has Administrator privileges so that it can access the Ubuntu partition.

Now, create a new Virtual Machine for Ubuntu. When configuring the hard disk drive, choose Use an existing virtual hard drive file. Select the VDMK file you created in step 7. This raw disk image enables your virtual machine to access the Ubuntu partition.

After creating the Ubuntu VM, select it and go to Settings -> Storage. Select Controller: IDE and use the optical drive icon to add a removable disk. 

Virtualbox IDE Controller

Select your boot.iso file and click OK.

Now when you boot the virtual machine, it will read the GRUB Recovery ISO as a removable disk and provide you with your GRUB boot menu, minus the option to boot Windows 10.

After this step, your Virtual Machine should be ready to go.

Recommendations and Caveats

Make sure that you run VirtualBox as Administrator when you want to virtualize Ubuntu, otherwise the Ubuntu partition will be inaccessible.

Feel free to pause the VM and leave it in a saved state in between consecutive virtualization sessions, but make sure to properly shut down the virtual machine before booting the computer directly into Ubuntu. 

Do not try to access your Windows partition from within the Ubuntu Virtual Machine -- this will produce unpredictable results. Doing so may destroy data! Use other methods to exchange data between the Ubuntu VM and Windows, such as removable media or network transfers such as rsync.


If you boot your computer and the GRUB menu entry for Windows is missing, log in to Ubuntu as root and run os-prober to scan for bootable operating systems:


Then, update your GRUB configuration:


...and reboot.

Share this page:

15 Comment(s)

Add comment

Please register in our forum first to comment.


By: Derek Broughton

"Feel free to pause the VM and leave it in a saved state in between consecutive virtualization sessions, but make sure to properly shut down the virtual machine before booting the computer directly into Ubuntu"

That really needs to be in larger, bolder, font!  In fact, if you're going to use a raw disk image, I'd recommend never pausing the VM, to ensure you don't end up booting into the native Linux with your VM still paused. If you do that, you will lose data.

I'm not so sure about the issue of writing to your Windows partition from the VM: surely you can only do that by either mounting a VirtualBox shared folder, or through a Windows (SMB) Share. I would have thought either one should be safe.

By: Neil Golden

Shutting down the VM operating system once per host session is the more prudent operating policy.

I wasn't able to adequately test SMB file sharing in this configuration. Until then I would recommend that the results of such a configuration be considered unpredictable.

By: Bill

This looks good for an initial setup, but what about updates?   Your bootable grup ISO isn't going to update itself when a new release of GRUB comes out and I don't think it is even going to catch kernel updates (which are much more common).   Any suggestions on this?

By: Neil Golden

Correct, the GRUB ISO will not be automatically updated. When a new version of GRUB is available, manually repeating step 8 will ensure that the virtual machine is using an up-to-date boot loader. This warrants mention, thank you!

By: Martin

You can also create a raw-disk for the full harddrive by omitting the -partitions parameter when creating the VMDK-file. Then mount the full hard-disk in VirtualBox (make sure to use nVMe-type where applicable) and boot the system via the regular EFI/GRUB bootloader. This way, there's no need to create and mount a separate GRUB-ISO and always redo that step when there's a new Linux kernel.

Works great for me with Windows 10 and Ubuntu 17.10. Just make sure you don't boot the VM into the same Windows that is running VirtualBox...



Any way to do the opposite? Boot Ubuntu/any Linux and access the installed Windows 10  from within a VM. Had done it with Win 7 (around 2009) - but not sure if that can be done today. The key issue that came was with activation ...

By: Neil Golden

I guess I would consider the benefits of "flipping" the configuration to be minimal or preferential in nature. And, when given the choice of installing Linux or Windows as a second operating system, I will choose Linux every time: Windows is (much) less friendly to non-standard configurations, whereas Linux is more configurable, modular, and transparent about low-level process. And Ubuntu is an easy choice if there are no other prohibitive criteria because its installation process is specifically and explicitly aware of the Windows install.

That said, if I had the time and patience, I would love to try it ... 

By: Ingo Pan

So when i boot into the Ubuntu VM,do some work and save same stuff - will my work be there on next boot into native ubuntu or will the changes made to the VM just reside/stay visible in the VM ?  

By: Wouter

At first it worked like a charm, until I installed the guest additions. After installing the guest additions I keep getting an application error in Virtualbox: "The Instruction at 0x... referenced memory at 0x... The memory could not be read."

Are there specific settings that I should change in the VM's settings?

By: Wouter

Hmmm... now I can't boot the 'regular' linux anymore (dualboot). It hangs at boot. If anyone has dome advice that would be nice!

By: Marcel Savelkoul

I'm stuck in step 7. I know on which partitions are the Ubuntu installation and the swap partition.So I run the command to create the raw disk image in a command prompt as Administrator:VBoxManage internalcommands createrawvmdk -filename “C:\path\to\ubuntu-raw.vmdk” -rawdisk \\.\PHYSICALDISK0 -partitions 5,6

Which gives me as output:

VBoxManage.exe: error: Cannot open the raw disk '\\.\PHYSICALDISK0': VERR_FILE_NOT_FOUNDVBoxManage.exe: error: The raw disk vmdk file was not createdAnybody run into this and found the solution?

By: Scotty

You gotta change the \\.\PHYSICALDISK0 -partitions 5,6 


\\.\PHYSICALDRIVE0 -partitions 5,6

By: Martin

I tried to follow the instructions step by step, but with an already existing ubuntu installation. But when I try to use boot from the boot.iso in Virtualbox I get a black screen with a single light-grey underline _

What could be the problem?

By: Daniele Piscaglia

For those who are trying to do this on a UEFI machine i suggest to take a look here:

By: Pete Skeggs

I had this all working on a new machine, and then after running grub-customizer when booted directly to Ubuntu (to clean up the boot menu), it stopped working from Windows 10 -- I started getting "unknown filesystem" errors.  I incorrectly concluded grub was the issue and kept trying different things to create a "better" boot.iso, to no avail.  I fiddled with the grub CLI, and despite having 'part_gpt' loaded, it could not decode any of the file system types on the partitions using 'probe -f (hdX,Y)'.  Strange.

I finally realized I should try creating a fresh 'ubuntu-raw.vmdk', in case (somehow) it was no longer correct.  Bingo!  I must have changed something else on my machine around the same time I ran grub-customizer (perhaps related to setting up a RAID array) which caused PHYSICALDRIVE1 to change to PHYSICALDRIVE0.

So, word to the wise -- if it stops working from Windows, check the PHYSICALDRIVE value to make sure it is still correct.