anatol / booster

Fast and secure initramfs generator
MIT License
489 stars 40 forks source link

Usable with Grub? #29

Open abenz1267 opened 3 years ago

abenz1267 commented 3 years ago

Hi,

the doc only describes updating systemd-boot, but does this work with grub as well? What do i have to do to make it work? When i run grub-mkconfig it doesn't find the new booster images. They are present in the /boot folder though.

Regards

anatol commented 3 years ago

I do not use grub myself. But there is a great reply at reddit that worth quoting here:

GRUB by default only looks for some predefined initramfs file names, as you can see in /etc/grub.d/10-linux. If you want it to also search for Booster–generated images, you could duplicate that config file as 11-linux-booster (or 9-… if you want Booster entries at the top of the list) and patch it like this:

https://gist.github.com/Saancreed/7603709409c4220659b8e0e0b62e7a31

This works for me with submenu disabled, not sure if there would be any issues if it wasn't. Of course, you can always roll your own config but yes, it's GRUB that has to be configured for this.

So GRUB looks for hardcoded image names. And this list need to be patched manually as for now.

anatol commented 3 years ago

Is there any chance you try to compile grub2 with this patch and see if it makes the booster image detection possible?

diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
index e8b01c0d0..8e9cbaa9e 100644
--- a/util/grub.d/10_linux.in
+++ b/util/grub.d/10_linux.in
@@ -214,7 +214,7 @@ while [ "x$list" != "x" ] ; do
   for i in "initrd.img-${version}" "initrd-${version}.img" "initrd-${version}.gz" \
           "initrd-${version}" "initramfs-${version}.img" \
           "initrd.img-${alt_version}" "initrd-${alt_version}.img" \
-          "initrd-${alt_version}" "initramfs-${alt_version}.img" \
+          "initrd-${alt_version}" "initramfs-${alt_version}.img" "booster-${alt_version}.img" \
           "initramfs-genkernel-${version}" \
           "initramfs-genkernel-${alt_version}" \
           "initramfs-genkernel-${GENKERNEL_ARCH}-${version}" \
diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in
index 3b1f47049..07b58a676 100644
--- a/util/grub.d/20_linux_xen.in
+++ b/util/grub.d/20_linux_xen.in
@@ -283,7 +283,7 @@ while [ "x${xen_list}" != "x" ] ; do
        for i in "initrd.img-${version}" "initrd-${version}.img" "initrd-${version}.gz" \
           "initrd-${version}" "initramfs-${version}.img" \
           "initrd.img-${alt_version}" "initrd-${alt_version}.img" \
-          "initrd-${alt_version}" "initramfs-${alt_version}.img" \
+          "initrd-${alt_version}" "initramfs-${alt_version}.img" "booster-${alt_version}.img" \
           "initramfs-genkernel-${version}" \
           "initramfs-genkernel-${alt_version}" \
           "initramfs-genkernel-${GENKERNEL_ARCH}-${version}" \
anatol commented 3 years ago

cc @eworm-de

ghost commented 3 years ago

It sort of works. Sadly it doesn't detect all my kernels:

ls -lh /boot/booster-*.img                                                                                                                                               8:19
Permissions Size User Date Modified Name
.rw-r--r--  4,6M root 26 Feb 19:31  /boot/booster-linux-xanmod-cacule.img
.rw-r--r--  3,3M root 26 Feb 19:28  /boot/booster-linux59.img
sudo rg booster /boot/grub                                                                                                                                               8:28
/boot/grub/grub.cfg
266:            initrd  /boot/amd-ucode.img /boot/booster-linux59.img
anatol commented 3 years ago

Interesting.. Do you have /boot/initramfs-linux-xanmod-cacule.img? Does grub detect it correctly?

ghost commented 3 years ago

Interesting.. Do you have /boot/initramfs-linux-xanmod-cacule.img? Does grub detect it correctly?

yes and yes

anatol commented 3 years ago

@lavalampa unfortunately GRUB expects only 1 initramfs per kernel. It uses only the first image in the list and the other initramfs images are ignored. initrd- and initramfs- are at the beginning of the list and they have higher priority. You can change the patch and put booster to the beginning of the list.

anatol commented 3 years ago

A preview for booster support has been added to the Arch's GRUB package https://github.com/archlinux/svntogit-packages/commit/177e28ebb2d3c4c6151a502401928615e69e58f8#diff-3e341d2d9c67be01819b25b25d5e53ea3cdf3a38d28846cda85a195eb9b7203a

Please build grub from the repo and try it with booster. Please share your experience.

eworm-de commented 3 years ago

Or just test grubpackage version 2:2.06rc1-2. 😉

anatol commented 3 years ago

Or just test grubpackage version 2:2.06rc1-2.

Woot! Thank you for the package release.

abenz1267 commented 3 years ago

Or just test grubpackage version 2:2.06rc1-2. wink

While grub now correctly finds the booster images, the generated grub.cfg doesn't seem to be correct, copy paste from my comment on the commit:

The generated /boot/grub/grub.cfg seems to be missing the actual img for the first menu-entry, it's just initdr /boot/amd-ucode.img instead of /boot/amd-ucode.img /boot/booster-linux-zen.img for example

eworm-de commented 3 years ago

Works for me... Anybody else wants to share experience?

Kyuzial commented 3 years ago

Or just test grubpackage version 2:2.06rc1-2. wink

While grub now correctly finds the booster images, the generated grub.cfg doesn't seem to be correct, copy paste from my comment on the commit:

The generated /boot/grub/grub.cfg seems to be missing the actual img for the first menu-entry, it's just initdr /boot/amd-ucode.img instead of /boot/amd-ucode.img /boot/booster-linux-zen.img for example

I have the same issue, the default archlinux entry in grub is not using any initrd images, just intel-ucode.img. I have to manually select the booster entry.

bjo81 commented 2 years ago

A workaround is to set

GRUB_DEFAULT=saved
GRUB_SAVEDEFAULT=true

in /etc/default/grub to "survive" a reboot, but maybe @eworm-de could take a look into this issue.

borislavba commented 2 years ago

In /etc/grub.d/10_linux in order for the generation to work as expected after this line: for i in "initrd.img-${version}" "initrd-${version}.img" "initrd-${version}.gz" \ this should be added: "booster-${version}.img" \ The result is that two entries for booster images are generated - this is not ideal, but I don't have time to investigate further.

deathtrip commented 1 year ago

So will GRUB be officially supported or not? If yes, there should be setup instructions added to the readme and manpage. If not, there should be a warning notice that it's not supported, so people don't try.

meltdown03 commented 1 year ago

Only "(booster)" version of the grub menu item works for me also. The Default Linux version just locks up. I'll switch back to mkinitcpio until it's working as expected. I see it's doing the same as: https://github.com/anatol/booster/issues/29#issuecomment-827083752

deathtrip commented 1 year ago

I use booster with GRUB, so i think we can safely say that it's compatible with grub. @meltdown03 The default menu entries are probably for old mkinitcpio images. You need to regenerate your grub.cfg. When using LUKS you can't use mkinitcpio and booster images simultaneously, without changing the kernel command-line.

Arzumify commented 1 year ago

Can confirm GRUB works beautifully on Void Linux. Perhaps you could try regenerating grub.cfg as suggested?