Virtualbox cannot boot guest from GPT physical partition
Virtualbox cannot boot the guest from a GPT physical partition, it stops at a black screen with the cursor in the top left corner (not blinking). Virtualbox version is 5.0.10 x64.
PhysicalDrive0 is the GPT drive, here is the partition information:
C:\Program Files\Oracle\VirtualBox>VBoxManage.exe internalcommands listpartitions -rawdisk \\.\PhysicalDrive0
Number Type StartCHS EndCHS Size (MiB) Start (Sect)
1 0x00 0 /0 /0 0 /0 /0 100 2048
2 0x00 0 /0 /0 0 /0 /0 128 206848
3 0x00 0 /0 /0 0 /0 /0 409372 468992
4 0x00 0 /0 /0 0 /0 /0 409600 838862848
5 0x00 0 /0 /0 0 /0 /0 409600 1677723648
6 0x00 0 /0 /0 0 /0 /0 662640 2516584448
7 0x00 0 /0 /0 0 /0 /0 16288 3873671168
- Partition #3: Win7 sp1 x64, host
- Partition #6: Ubuntu14.04.3 x64, Guest
- Partition 7: Swap
Dual booting via BIOS works fine.
First, boot the computer with Ubuntu 14.04.3 through the BIOS and run the following command to create the .mbr file:
sudo grub-install /dev/sdb
sudo dd if=/dev/sdb of=~/my.mbr
/dev/sdb is the USB flash, after executing these commands, I can boot Ubuntu14.04.3 through this USB falsh.
Then boot the computer with Win7, run the following command at the DOS prompt to create the vmdk file, administrator permission is required:
C:\Program Files\Oracle\VirtualBox>VBoxManage.exe internalcommands createrawvmdk
-filename e:\VirtualBox\a.vmdk -rawdisk \\.\PhysicalDrive0 -partitions 6,7 -mbr
e:\VirtualBox\my.mbr
RAW host disk access VMDK file e:\VirtualBox\a.vmdk created successfully
Start Virtualbox with admin rights, create a virtual machine, Ubuntu 64bit, 4G ram, and use the existing a.vmdk. Start the virtual machine, it stops at a black screen and the cursor is in the upper left corner (not blinking).
I did a lot of searching but didn't find a solution. Can anyone here help me?
In the end, I managed to do it, although there were still some issues I couldn't explain. I wanted to document it here for people with the same problem so I can remember it in the future.
This parameter is not required when creating the vmdk file
-mbr
, but make sure not to include the partition where the host OS is located, that is, including the entire physical drive in the vmdk will fail. My last command line (excluding host partition 3) is:C:\Program Files\Oracle\VirtualBox>VBoxManage.exe internalcommands createrawvmdk -filename e:\VirtualBox\Ubuntu.vmdk -rawdisk \\.\PhysicalDrive0 -partitions 1,2,4,5,6,7
After creating the guest machine (as described in the question), go to Guest Settings, System, Motherboard, Extended Features, make sure "Enable EFI (special OS only)" is checked.
Boot the guest , then quickly press into the guest's VirtualBox BIOS Delbefore the Windows boot menu is displayed . If you didn't, go to the Windows boot menu, force power off the guest, and restart.
In BIOS, go to Boot Maintenance Manager, Boot Options, Change Boot Order. Move the EFI inner shell to the first option, commit the changes and exit. Press the Reset System menu item in the Boot Maintenance Manager screen. Instructions on how to change the boot order are provided at the bottom of the BIOS screen.
When the guest reboots again, it will enter the EFI Shell (not the Windows boot menu). Now you need to determine which partition is the EFI bootloader. Once inside the shell, it prints the parts and their mixtures, but it doesn't seem to print them all for me. Once you've figured out which is the EFI bootloader, run:
BLK2:\EFI\ubuntu\grubx64.efi
It will return an error if it is not an EFI bootloader.
Now, the GRUB boot menu will be displayed and we can boot Ubuntu.
Sometimes I find that the guest is still on an empty Ubuntu screen, and sometimes VirtualBox shows an error. I kept restarting the client until it worked. You may also have to reboot from step 3 as it appears your BIOS settings have been lost.
Hope this helps you. I would like to clarify, I have only tested this with: * VirtualBox 5.0.10 x64 * Host OS: Win7 sp1 x64 * Guest OS: Ubuntu 14.04.3 x64 * with the specific disk partitions described.
Be careful as this runs directly on the physical drive. Your data is your responsibility.