Virtual machine fail to bootup from GPT physical drive

Discussions related to using VirtualBox on Windows hosts.
Post Reply
zhiyazw
Posts: 4
Joined: 14. Dec 2015, 04:05

Virtual machine fail to bootup from GPT physical drive

Post by zhiyazw »

Hi, Virtual machine fail to bootup from GPT physical drive, it stop at a black screen with a cursor(doesn't blink) at the left top corner. Virtualbox version is 5.0.10 x64.

PhysicalDrive0 is a GPT drive, Here is 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, the Host
Partition #6: Ubuntu14.04.3 x64, the Guest
Partition #7: swap

Dual boot via BIOS works fine.

Firstly, boot up computer with Ubuntu14.04.3 via BIOS, run below commands to create .mbr file:
sudo grub-install /dev/sdb
sudo dd if=/dev/sdb of=~/my.mbr
/dev/sdb is a USB flash, and after these commands, I can bootup the Ubuntu14.04.3 via this USB falsh.

Then boot up computer with Win7, run below commands to create vmdk file, in a DOS prompt, with administrators persmission:
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.

Launch Virtualbox with administrators permission, create a virtual machine, Ubuntu 64-bit, 4G ram, use existing a.vmdk . Start the virtual machine, it stop at a black screen with a cursor(doesn't blink) at the left top corner.

I did a lot of search, but didn't get a solution. Anybody here could help me this ?
zhiyazw
Posts: 4
Joined: 14. Dec 2015, 04:05

Re: Virtual machine fail to bootup from GPT physical drive

Post by zhiyazw »

Finally, I managed to accomplish this, though there are still some questions I am not able to explain. I would like to record it here for people who get the same problem, and for I can remember this myself in future.

1. When creating the vmdk file, mbr parameter is not necessary, but be sure NOT to include the partition in which the host OS resides, that is, including whole physical drive in vmdk will fail. Paste my final command line below, Host partition #3 excluded:

C:\Program Files\Oracle\VirtualBox>VBoxManage.exe internalcommands createrawvmdk -filename e:\VirtualBox\Ubuntu.vmdk -rawdisk \\.\PhysicalDrive0 -partitions 1,2,4,5,6,7

2. After creating guest machine ( as steps in previous post ), go to guest Settings, System, MotherBoard, Extended Features, be sure to keep "Enable EFI (special OSes only)" checked

3. Start guest, and press <Del> key quickly to enter BIOS, before it shows Windows boot menu automatically( which is the exactly same Windows as the host ), if you failed to do so and got to the Windows boot menu, force to power off guest and restart again. The BIOS and when you read BIOS again in left of this post, it means the BIOS of guest machine in Virtualbox.

4. In BIOS, go to Boot Maintenance Manager, Boot Options, Change Boot Order, move EFI Internal Shell to the first option, Commit Changes and Exit, press Reset System menu item in Boot Maintenance Manager screen. About how to change the boot order, read the guide at the bottom of BIOS screen.

5. When guest reboot again, it enter EFI shell ( instead of previous Windows boot menu ), then you need to find out which partition is your EFI bootloader. When entering EFI shell, it print out your partitions and its alias, but it seems that it doesn't print out all, it doesn't print out BLK2 for me and deadly it exactly is the EFI bootloader, I fight to guess out that one by one. When you decide your EFI bootloader, for example it's BLK2, then execute below command:

BLK2:\EFI\ubuntu\grubx64.efi

And you can use above command to test whether a partition is EFI bootloader, e.g., none EFI bootloader BLK1:\EFI\ubuntu\grubx64.efi return an error.

6. After step 5, Grub boot menu shows, of course we launch Ubuntu, but this is not the end, at least for me. It stays with a empty Ubuntu-red screen, the guest machine state is "Running", in this condition, use Virtualbox menu Machine, Reset to reboot the guest; and sometimes Virtualbox show an error dialog, in this condition, I have to power off Virtualbox guest machine and start again; at the end I can success to boot up to Ubuntu. Each time you reboot or restart guest machine, be sure to check again from step #3 carefully, it seems that the BIOS will lose what you set.

Now, hope this help you somewhat. But I would like to declare that I only test this under my environments: Virtualbox 5.0.10 x64, host OS Win7 sp1 x64, guest OS Ubuntu 14.04.3 x64, and specific disk partitions as describled in my previous post. And be very careful and your responsibility to keep your data safe for this operates physical drive directly.
Post Reply