Dual booting can be both useful and inconvenient.
Having both a Linux (in this case, Ubuntu 20.04 LTS) and Windows (10) partition means that they can each harness the power of a dedicated GPU that is just not possible in a virtual machine (there’s work in progress to have GPU access via Windows Subsystem for Linux 2, though).
Even as faster drives seek to reduce the boot time, restarting a selecting the next partition closes previous work and forces you to “context switch” whether you want to or not.
Fortunately, referencing the already set up “other” operating system is possible in VirtualBox.
Here, I will consider the case where…
- We have a single disk (SSD) that has been set up to boot into Ubuntu 20.04 (default) or Windows 10.
- Ubuntu is the “host” machine where we have VirtualBox installed (v6.1)
- Windows 10 is the “guest” machine that we want to access from the “host” without rebooting or setting up a new virtual disk + machine.
- EFI - mounted to
- Microsoft reserved - not mounted
- Windows 10 - not mounted
- Ubuntu 20.04 - mounted at
- Recovery partition
VirtualBox commands (Ubuntu host)
- Open a terminal and type
sudo VBoxManage internalcommands createrawvmdk -filename windows.vmdk -rawdisk /dev/sda -partitions 1,3
windows.vmdk is the output filename,
/dev/sda is the disk containing the operating systems (can be check using the Disks program), and
-partitions 1,3 references the EFI (1) and Windows 10 (3) partitions (seek Disk partitions above).
- Open VirtualBox with root privileges (e.g.
sudo virtualbox &)
Add the hard drive
Settings -> Media -> Hard drive -> Add > select the
windows.vmdkfile created above
Create a new virtual machine in expert mode
OS: Windows 10 (64-bit)
Existing virtual disk > select
- Try boot and if it works, great success! Otherwise close and continue
Changes virtual machine settings
Make sure “Enable EFI (special OSes only)” is checked
In a terminal:
sudo nano /boot/efi/startup.nsh
Make sure the file has the following contents
# startup.nsh FS0:\EFI\Microsoft\Boot\bootmgfw.efi
Save and quit
Run the virtual machine again
You will likely encounter the EFI interactive shell. If the
startup.nshfile is set up correctly, then it will shortly boot into Windows.
Subsequent boots should head straight to Windows!
- Enjoy accessing your Windows partition on Ubuntu!
- do not attempt to access the Ubuntu drive within the Windows machine within Ubuntu