pftf / RPi4

Raspberry Pi 4 UEFI Firmware Images
https://rpi4-uefi.dev
Other
1.19k stars 140 forks source link

How to boot a distro from UEFI Shell? #189

Closed xiongyw closed 2 years ago

xiongyw commented 2 years ago

Thanks for the releases. Following the readme, I can boot into UEFI Shell via a USB stick.

Now I am wondering how to boot a linux kernel (e.g., ubuntu 20.04 server for arm64) from UEFI Shell? I know it's a sort of off-the-topic, but it would be helpful to have a kind guide/pointer on this topic, since in most of the scenarios a user needs to boot kernel in the end I guess.

Btw, I tried to extract the vmlinux (EFI stub enabled), initrd, and squashfs from the installation iso of ubuntu 20.04, so far the kernel can be booted from UEFI Shell, but I have still some problem in mounting the root file system.

Thanks again!

sunnywang-arm commented 2 years ago

This is just like how you boot other OSes from the UEFI shell. You can google "\EFI\Boot\bootaa64.efi". You can find more information by googling "\EFI\Boot\bootx64.efi" By the way, there should be a UEFI boot option created while installing the OS for you to boot the OS you installed. I think most people would boot OS in this way.

jlinton commented 2 years ago

yes, you can boot directly from the vmlinux, but you need to pass the appropriate flags to it. I did a lot of bringup on another platform that way. IIRC something like

vmlinux initrd=initrd.image root=/dev/sda earlycon console=ttyAMA0

etc.

The key is having the vmlinux and initrd on a fat/esp partition that the shell can read. The linux stub is what reads the initrd, note https://elixir.bootlin.com/linux/latest/source/Documentation/admin-guide/kernel-parameters.txt

jlinton commented 2 years ago

Of course, unless your trying to debug something, the best way is to just grab the .iso images from ubuntu here https://ubuntu.com/download/server/arm and dd the .iso image to your USB disk. From there you won't need the shell/etc because it will find the bootaa64.efi file and boot it automatically. Or as Sunny notes, you can then run shim/grub from the disk via the shell the same way.

xiongyw commented 2 years ago

Thanks for your answers, @sunnywang-arm and @jlinton.

My goal was to learn more details of UEFI and Linux boot process (with ACPI and/or dtb). So I choose RPi4B as the platform for doing some tests. The reason why I was not able boot into rootfs (but into initramfs) is because I was using the initrd image directly from the ubuntu install iso (under casper directory). It seems that this initrd image contains a init script dedicated for looking a live file system, so it complains "no live file system found" and drops me into initramfs/busybox environment.

Now I use qemu-system-aarch64 to install the ubuntu server into a VM, and then copy the installed kernel/initrd/rootfs back to RPi4B environment (also updating /etc/fstab). It should give me a test environment for booting with both ACPI and dtb.

Thanks again.