Brool brool (n.) : a low roar; a deep murmur or humming

Virtualizing an Ubuntu Partition with EFI

 |  coding virtualbox ubuntu partition efi

I installed Ubuntu on a new latop (UX305LA – nice laptop, will do a review at some point maybe), and wanted to be able to run the Ubuntu partition both standalone as well as from Windows with VirtualBox.

Didn’t find anything that exactly addressed my situation (basically, virtualizing an Ubuntu EFI partition), and after some fiddling ended up getting stuff mostly working. So, to remember what I did, and in the hopes that I can save a few minutes time for someone else…

This basically follows the steps in this article, with some tweaks.


From your Ubuntu partition:

cd ~/Desktop
mkdir -p iso/boot/grub
cp /usr/lib/grub/x86_64-efi/* iso/boot/grub
cp /boot/grub/grub.cfg iso/boot/grub

Edit iso/boot/grub/grub.cfg and delete the menuentry for “Windows.”

sudo apt-get install xorriso
grub-mkrescue -o boot.iso iso/

Copy off the boot.iso somewhere; you’ll use it on the Windows side.

Also keep track of what partitions you’re using on the Ubuntu side; in my particular case it was /dev/sda5 for the main drive and /dev/sda6 for the swap.

Creating the VMDK

From Windows:

Open a command window as an administrator (i.e., right click / Open As Administrator).

Use wmic diskdrive list brief /format:list to figure out the physical Windows drive. It will almost always be PhysicalDrive0, unless you’ve got an unusual setup.

Change into the VirtualBox directory

cd \Program Files\Oracle\VirtualBox

Run VBoxManage to create the VMDK.

VBoxManage internalcommands createrawvmdk -filename "C:\Users\yourname\Ubuntu.vmdk" -rawdisk \\.\PhysicalDrive0 -partitions 5,6

PhysicalDrive0 and -partitions 5,6 will of course be dependent on your setup.

Setting up VirtualBox

And… run it! I’m getting a few warnings that flash by, and a prompt at boot that says /boot/efi was not mounted. Press S to continue on that.

And… it all works, at that point. I increased graphics memory to 128MB in VirtualBox and turned on 3D acceleration, but Unity is still a dog in the VM, like always; I usually switch to LXDE or Awesome when in a VM.

At this point you can install the Guest Additions in the VM, at the cost of some spurious notifications when you boot the Ubuntu partition directly.

See Also


Comments are moderated whenever I remember that I have a blog.

X.Remember | 2017-12-03 21:45:35
Great, works like a charm! If you use like me GRUB_DEFAULT="saved" make sure that you copy /boot/grub/grubenv to iso/boot/grub as well before creating the iso file with grub-mkrescue. If this file is missing you will see a error message before the boot process and the system start is delayed for a few seconds. Booting will still work. Usually GRUB_DEFAULT="saved" will remember your last selected grub entry but since the iso file is read-only this feature won't work anymore.
Add a comment