Configure EFI bootloader to use raw linux partition in Virtual Box

1

I`m trying to launch existing Archlinux installation inside Virtualbox on Windows host. Linux uses EFISTUB, Windows - its own EFI bootloader.

- /dev/sda1 - EFI partition, also mounted as /boot for linux on host. It contains vmlinuz-linux and initramfs. Windows Boot manager is there too.

- /dev/sda2 - Linux partition

- /dev/sda3 - Windows partition

I have created .vmdk file which represents partitions sda1 & sda2, then launched Vbox with administrator rights. Attached .vmdk to a VM. Then booted from a live-DVD iso inside the VM, executed

# efibootmgr -d /dev/sda -p 1 -c -L "Arch Linux" -l /vmlinuz-linux -u "root=/dev/sda2 rw initrd=/initramfs-linux.img"

(i know, not the best idea, because Vbox will erase all EFI variables after closing the VM. But I dont have any bootloader installed on /sda1)

Efi boot option was created successfully. But it causes

Waiting 10 secs for device /dev/sda2 ...
ERROR: device '/dev/sda2' not found.  Skipping fsck.
ERROR: Unable to find root device '/dev/sda2'.
You are being dropped to a recovery shell 

Has anyone succeeded in configuring EFISTUB in such case? Or should I try grub-efi?

MichaelZelenoborskyLong

Posted 2017-07-19T13:44:12.707

Reputation: 11

It looks to me like your virtualized environment does not map the true /dev/sda2 to the virtualized /dev/sda2, hence the problem. OTOH, I'm not an expert on giving VirtualBox access to "real" disk devices, so I may be misinterpreting something here.... – Rod Smith – 2017-07-19T16:35:24.150

@Rod-Smith Thanks for hypothesis. I checked it using PARTUUID instead of /dev/sda/ while creating EFI boot entry. Got a bit different result than before - ERROR: Unable to find root device /dev/disk/by-partuuid/MY_PARTUUID.

PARTUUID inside the virtualized environment is the same as on real hardware. System from live-dvd is able to see all partitions inside VM, but can read and write only to sda1 & sda2. – MichaelZelenoborskyLong – 2017-07-21T11:54:45.533

No answers