Comments on 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.
15 Comment(s)
Comments
"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.
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.
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?
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!
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 ...
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 ...
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 ?
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?
Hmmm... now I can't boot the 'regular' linux anymore (dualboot). It hangs at boot. If anyone has dome advice that would be nice!
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?
You gotta change the \\.\PHYSICALDISK0 -partitions 5,6
to:
\\.\PHYSICALDRIVE0 -partitions 5,6
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?
For those who are trying to do this on a UEFI machine i suggest to take a look here: https://www.virtualbox.org/ticket/14268?cversion=1&cnum_hist=4
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.