Solving the Issue with Virtualbox Raw Host Hard Disk Access

The solution to the boot issue provided by Lifehacker


Recently I wanted to boot a physical Ubuntu installation in a Virtualbox machine. The target Ubuntu is in the partition 5 on the same disk where the host is (also an Ubuntu 20.04 OS) on partition 6.

I followed the instruction provided by Virtualbox here and this one from serverwatch.com. However when I tried to create the vmdk file with this command:

VBoxManage internalcommands createrawvmdk -filename ubuntu.vmdk -rawdisk /dev/nvme0n1 -partitions 5

I couldn't go past the error VERR_ACCESS_DENIED. Even the solution posted here on superuser.com didn't help.

After wasting some time with this issue I finally found the solution: the user should have the right to access the disk, so make sure your user account is included in the group disk (/etc/group). So the first hurdle passed. 

Please note however in the end I didn't proceed with accessing the Ubuntu installation on my ssd, where my host OS also resides. I find it too risky and I didn't have time for testing. So I installed Ubuntu on my second harddisk (/dev/sda2) and continued with the Virtualbox setup. Then I created the disk with this command:

VBoxManage internalcommands createrawvmdk -filename ubuntu.vmdk -rawdisk /dev/sda -partitions 2

I thought from here it would be a plain sailing. However the system couldn't boot! It seemed that the physical Ubuntu installation in the VM couldn't find the necessary boot information.

I read again and again the instruction on the virtualbox website, but couldn't find the solution.

When I finally wanted to give up I eventually found this video on youtube and that basically solved this final issue. Yes, you hear that correct: you need to create a boot.iso from that physical Ubuntu installation and attache it to the VM! Make sure to make the boot.iso be the first in boot order.

Warning: Please follow the instruction provided by Virtualbox and others I mentioned above. I'm not liable for any damage you create on your machine.