Since there is no easier way that I have found, I am trying to change GRUB boot to systemd boot in a virtual machine. I know that the hypervisor configuration has to utilize UEFI instead of default Legacy. Then Tianocore initiates the KVM boot. Don’t know what is omitted from the instructions or or needs to be updated for 38. I’m adding screenshots to see if anyone can figure out what is missing.
Rather than creating the directory manually, it might be better to use bootctl’s --make-entry-directory=yes option when running bootctl install.
Also, sudo dnf reinstall kernel-core shouldn’t be necessary at the end.
Also, there is an os-prober package that is actually part of GRUB (even through it doesn’t have the grub2- prefix). You might want to remove that too.
Also, since you are removing grubby, you might want to also remove kexec-tools. The kexec-tools package adds /usr/lib/kernel/install.d/92-crashkernel.install which calls /usr/bin/kdumpctl which calls grubby and it will generate an error message whenever a new kernel is installed.
kexec-tools are used for systemctl kexec. So removing them is not good advice in general. The packaging in kexec-tools needs to be fixed to silence that stupid warning.
I had recommended removing grub2 in some older threads. But that was because, at the time, it really wouldn’t work with sd-boot. It would alter the drop-in configs under loader/entries such that there were variables in the kernel parameters that sd-boot wouldn’t be able to process.
Also, I like to “merge” the two bootloader partitions and have just one mounted at /boot. But grub2 didn’t get along with that configuration because it would create a symlink under /boot. I believe that has since been fixed. But I’ve long since stopped using grub2, so I don’t really know for sure.
I just tried in a VM.
Have a working grub configuration at hand, and a live usb.
The ESP should be mounted as /efi, not /boot/efi and should have enough space to accomodate kernels.
It is extremely annoying that GRUB finally stopped trying to make symlinks under /boot and someone added a new one shortly thereafter. I even submitted a PR to fix that so it would copy that file to /boot instead of creating a symlink (the file is only 177KB). But, to date, no one has merged my pull request.
Excerpt from “Linux Boot Partitions and How to Set Them Up”:
Whenever possible, only have one boot partition, not two. On EFI systems, make it the ESP. On non-EFI systems use an XBOOTLDR partition instead (see below). Only have both in the case where a Linux OS is installed on a system that already contains an OS with an ESP that is too small to carry sufficient kernels/initrds. When a system contains a XBOOTLDR partition put kernels/initrd on that, otherwise the ESP.
…
Use vFAT for both partitions, it’s the only thing universally understood among relevant firmwares and Linux. It’s simple enough to be useful for untrusted storage. Or to say this differently: writing a file system driver that is not easily vulnerable to rogue disk images is much easier for vFAT than for let’s say btrfs. – But the choice of vFAT implies some care needs to be taken to address the data safety issues it brings, see below.
Before GRUB, when syslinux was a popular bootloader, it was common to format /boot with a FAT filesystem. (People could then put small DOS binaries such as firmware updates on their /boot and chainload them with syslinux.)
It was never required that /boot be a POSIX filesystem. Please do not introduce any such new requirement!
The symbolic link is created by the shell file /usr/lib/kernel/install.d/20-grub.install. If you convert the kernel-core rpm file to cpio and unpack it you can see that the symlink does not come from the rpm file.
$ ls /usr/lib/kernel/install.d/20-grub.install
"/usr/lib/kernel/install.d/20-grub.install": No such file or directory (os error 2)
I don’t even have grub2 installed.
$ rpm -q grub2
package grub2 is not installed
I still see attempts to create that symlink though.
...
ln: failed to create symbolic link '/boot/symvers-6.2.15-200.fc37.x86_64.gz': Operation not permitted
restorecon: lstat(/boot/symvers-6.2.15-200.fc37.x86_64.gz) failed: No such file or directory
warning: %posttrans(kernel-core-6.2.15-200.fc37.x86_64) scriptlet failed, exit status 255
Error in POSTTRANS scriptlet in rpm package kernel-core
...
So, are you sure?
I think the reason you aren’t seeing it when extracting the RPM archive with cpio is because it is being created in a post transaction script.
But maybe there are multiple packages trying to create that symlink?
Why that was added, is not stated and does not make sense in Fedora as grub2 would take care of creating this symbolic link. At least refer to a readable Bugzilla report.
sudo mkdir /usr/lib/systemd/boot/efi
is required before
bootctl install --make-entry-directory=yes
and I am not sure why none of the directions mention that since it is needed.
In my latest attempt, I did not reinstall kernel core. I don’t know how to remove os-prober. I did not remove kexec-tools or grub.
When I tried
kernel-install add 'uname r`/boot/vmlinuz…
then there was an error message like this
grub2mkrelpath: error: failed to get canonical path (…6.2.9-300fc38…) dirname missing operand
So I ignored that because the advice above appears equivocal to me. Doesn’t seem mission critical. Then I did a reboot and boot was successful but I don’t know how to verify that the boot was a systemd boot and not a grub boot. What information should I be looking for in sudo bootctl?
Refering to h.janssen, bootctl does not return the same information you have listed to check kernel (6.2.9-300). It has a list of several red x and other info. How do I check “default boot loader entry” like you did?
Also, I will mention that the outcome, the end result I am looking for is to cryptenroll systemd boot with Yubikey. To test that in a VM first, I need to know how to passthrough USB by editing XML in KVM. I also need to know how to do that to test the dracut Yubikey method which I think eliminates the need for systemd boot. You might reply to other threads I have posted about this or here if you have answers. Ultimately, I am grub/systemd boot agnostic since from what I have read about the varying methods, there aren’t obvious reasons to favor one boot method over the other. Admittedly, that’s what part of this discussion is about.
Do you have a way of opting for systemd boot at installation?
After I followed the steps I could piece together from the replies, and entered
bootctl install --make-entry-directory=yes
the output is
“Failed to open boot loader directory usr/lib/systemd/boot/efi”
so I had to make it and then it installs.
The third screenshot of gparted I posted above is the sort of hierarchy you would expect, isn’t it? That’s how the directions from kowalski7 seemed to think best.
If I remember correctly, when I ran bootctl, I also specified the path to the ESP by adding --esp-path=/boot. Maybe that parameter is required? I set my Fedora Linux installs up in a highly-customized way. So I may not be much help with answering how things should be. FWIW, this is what those parts of the PC I’m currently working from look like.
/usr/lib/systemd/boot/efi and its contents are provided by the package systemd-boot-unsigned. If that package is not installed, you will need to install it.
Not too long ago systemd-boot-unsigned was split out from the systemd package and may not be installed by default.
Only if you chose to mount the ESP partition on /boot. It is easier to mount the ESP on /efi, and then that would be automatically detected. Also when you haven’t remove grub2 yet.
It will auto-detect /boot as long as /efi doesn’t exist. Below are the lines from the kernel-install script that show what order it searches for the ESP.
if [ -n "$BOOT_ROOT" ]; then
# If this was already configured, don't try to guess
BOOT_ROOT_SEARCH="$BOOT_ROOT"
else
BOOT_ROOT_SEARCH="/efi /boot /boot/efi"
fi
Oh, yeah, I think I get what you are saying. @system76g6: You need to have a properly-formatted ESP mounted at /efi or /boot before you run bootctl install.