TransWikia.com

Boot a physical disk with EFI in VirtualBox Ubuntu 18.04 host

Super User Asked by SuperMechaCow on November 14, 2021

I used to use legacy BIOS booting on this machine to dual-boot Ubuntu 16.04 and Windows 10 across three hard drives. I used GRUB to boot to Ubuntu on an SSD and HDD combo and Windows 10 on it’s own SSD, but I could also boot that Windows 10 disk in a Virtual Machine in Ubuntu.

When I upgraded to Ubuntu 18.04 I reinstalled both Ubuntu and Windows as a UEFI install. Eveything works as expected except I can no longer use the physical Windows 10 drive in Virtualbox.

I’ve tried tweaking permissions for days but ultimately I just get dumped to a GRUB recovery shell on boot. I can boot the virtual machine to a live disk and access the drive just fine.

I’m really not familiar with EFI boot partitions or how they work at all. I’m not even sure if I need an EFI partition for each operating system, but I would like to be able to use the Windows 10 disk in other machines without the Ubuntu hard disks.

Can anyone tell me what I am doing wrong?

This is my set up. /dev/sda is my home and var mount points. sdc is my root. sdb is the Windows disk.

Disk /dev/sda: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 1D529F06-982A-4C10-86F1-9AABFA271304

Device          Start        End    Sectors   Size Type
/dev/sda1        2048   16777215   16775168     8G Linux swap
/dev/sda2    16777216   25165823    8388608     4G Linux filesystem
/dev/sda3    25165824 1659922431 1634756608 779.5G Linux filesystem
*** IGNORE THESE PARTITIONS ***
/dev/sda4  1659922432 1695938559   36016128  17.2G Linux filesystem
/dev/sda5  1695938560 1704327167    8388608     4G Linux filesystem
/dev/sda6  1704327168 1828964351  124637184  59.4G Linux filesystem
/dev/sda7  1828964352 1926782975   97818624  46.7G Microsoft basic data


Disk /dev/sdb: 238.5 GiB, 256060514304 bytes, 500118192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: C76B0EBA-27D6-4FE0-A92F-F78276F26981

Device       Start       End   Sectors   Size Type
/dev/sdb1     2048   1023999   1021952   499M Windows recovery environment
/dev/sdb2  1024000   1228799    204800   100M EFI System
/dev/sdb3  1228800   1261567     32768    16M Microsoft reserved
/dev/sdb4  1261568 500117503 498855936 237.9G Microsoft basic data


Disk /dev/sdc: 29.8 GiB, 32017047552 bytes, 62533296 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: D7616B5D-A0FA-4ACD-9122-DAB9BA2F21ED

Device      Start      End  Sectors  Size Type
/dev/sdc1    2048   411647   409600  200M EFI System
/dev/sdc2  411648 62531583 62119936 29.6G Linux filesystem

2 Answers

For the time being, I'm using EFI shell to boot windows.

You can launch the boot loader manually by using the EFI shell: Type fs0: to access the first filesystem, which is usually the ESP. Type cd EFI{osname}, where {osname} is the name of the directory where your OS installed its boot loader. (You haven't said what OS you've installed, so I can't be sure what that is. Typing ls EFI will show you what's there.) Launch the boot loader by typing its name. Again, I can't know what that is. For Linux, it's usually grubx64.efi. For Windows, it's bootmgfw.efi.

See how in the answer, here: How to get out of EFI shell in virtual box

You could also recreate the Physical disk without including the host partition.

When creating the vmdk file, the -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. My final command line (with host partition #3 excluded) was:

C:Program FilesOracleVirtualBox>VBoxManage.exe internalcommands createrawvmdk -filename e:VirtualBoxUbuntu.vmdk -rawdisk .PhysicalDrive0 -partitions 1,2,4,5,6,7

Source: https://stackoverflow.com/questions/34371180/virtualbox-fail-to-bootup-guest-from-gpt-physical-partition

Answered by Meetai.com on November 14, 2021

I found out you just need to press delete as the VM boots to enter the BIOS then, manually add the EFI boot option for Windows.

Answered by SuperMechaCow on November 14, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP