kyC6u
Posts: 12
Joined: Mon Jun 29, 2020 8:03 am

Bookworm update: generating a heap of /boot/initrd.img....

Wed Dec 06, 2023 12:35 pm

Rpi4 (1.1) and got a large bookworm update (~35 packages). It was taking a long time to do the update. Was taking a long time during these :

Image


https://imgur.com/a/hZjjbIO

Anyone have the same?

idk why I should have so many different boot images....

hippy
Posts: 15828
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Bookworm update: generating a heap of /boot/initrd.img....

Wed Dec 06, 2023 1:23 pm

kyC6u wrote:
Wed Dec 06, 2023 12:35 pm
idk why I should have so many different boot images....
So that SD Card can boot and be used on any Pi SBC.

BigRedMailbox
Posts: 514
Joined: Sat Aug 20, 2022 10:37 pm

Re: Bookworm update: generating a heap of /boot/initrd.img....

Wed Dec 06, 2023 1:25 pm

No image at the link.
My posts may be "controversial" and/or out-of-sync with the party line.

Nothing I write should in any way be taken as an official statement by any organization connected with (any branch of) RPi and/or any of its funding sources.

redvli
Posts: 1735
Joined: Thu Sep 03, 2020 8:09 am

Re: Bookworm update: generating a heap of /boot/initrd.img....

Wed Dec 06, 2023 1:54 pm

If you use 64-bit OS

Code: Select all

sudo apt purge linux-image-rpi-2712 linux-image-rpi-v6 linux-image-rpi-v7 linux-image-rpi-v7l
will remove all unneeded and unused kernels.

andrum99
Posts: 2099
Joined: Fri Jul 20, 2012 2:41 pm

Re: Bookworm update: generating a heap of /boot/initrd.img....

Wed Dec 06, 2023 3:02 pm

redvli wrote:
Wed Dec 06, 2023 1:54 pm
If you use 64-bit OS

Code: Select all

sudo apt purge linux-image-rpi-2712 linux-image-rpi-v6 linux-image-rpi-v7 linux-image-rpi-v7l
will remove all unneeded and unused kernels.
A warning for anyone stumbling across this thread: be aware that running the above command will make that installation (SD card or whatever you installed the OS to) unbootable on anything other than a Pi 4. (Although the Pi 5 can also boot the v8 kernel with a config.txt tweak, I believe).

dom
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7171
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge

Re: Bookworm update: generating a heap of /boot/initrd.img....

Wed Dec 06, 2023 3:19 pm

andrum99 wrote:
Wed Dec 06, 2023 3:02 pm
A warning for anyone stumbling across this thread: be aware that running the above command will make that installation (SD card or whatever you installed the OS to) unbootable on anything other than a Pi 4. (Although the Pi 5 can also boot the v8 kernel with a config.txt tweak, I believe).
I think a Pi5 will be okay here.

Pi5 defaults to kernel_2712.img.
If kernel8.img exists and kernel_2712.img does not (e.g. you've purged it), then the kernel8.img will be used instead.

You'll lose a slight performance boost from the 16k pagesize, but it should work fine.

redvli
Posts: 1735
Joined: Thu Sep 03, 2020 8:09 am

Re: Bookworm update: generating a heap of /boot/initrd.img....

Wed Dec 06, 2023 4:17 pm

andrum99 wrote:
Wed Dec 06, 2023 3:02 pm
A warning for anyone stumbling across this thread: be aware that running the above command will make that installation (SD card or whatever you installed the OS to) unbootable on anything other than a Pi 4. (Although the Pi 5 can also boot the v8 kernel with a config.txt tweak, I believe).
All my Pi3 also use 64-bit OS, so only v8 kernel is needed.
My Pi2 is broken, so don't need v7. And for the Pi1 and P0 it is really great that now standard Debian /boot structures are respected. I keep only v6 kernel on those that saves many minutes and 10s of megabytes of generating useless initrd's (and copying them from rootfs to bootfs in addition). And good brand SD-cards never leave the SD-card slot, I use Btrfs as rootfs, can do all disk management online while Pi keeps running.

User avatar
framp
Posts: 171
Joined: Sun Jan 27, 2013 7:03 pm
Location: next to Stuttgart, Germany

Re: Bookworm update: generating a heap of /boot/initrd.img....

Thu Dec 07, 2023 5:06 pm

I switched from Bullseye to Bookworm recently and detected yesterday an upgrade now takes > 20 minutes if all the kernels are built on my 1B. I know it's the least powerful Raspberry but even with Bookworm all applications run successful with no performance issues.

@rpdom suggested in this thread
Is it worth someone looking at putting an option in raspi-config to remove/reinstall the required packages based on the current platform?

With suitable warnings that it will limit the range of systems that it the OS will work on.
I think this is a very good idea. Would be great if more people ask for this feature to get DEV to have a look on this :)

Just for completeness: On this page I found a table which lists which kernels are required for which platform.

Code: Select all

kernel.img is 32-bit for BCM2835 (RPi1 & Zero)
kernel7.img is 32-bit for BCM2836 (RPi2) and BCM2837 (RPi3)
kernel7l.img is 32-bit for BCM2711 (RPi4)
kernel8.img is 64-bit for BCM2837 (RPi3) or BCM2711 (RPi4)
This table is important if you decide to delete kernels but want to keep kernels for other platforms for backup purposes. E.g. I need a kernel for my 1B and also for a 3B just in case the 1B HW fails and I have to start the OS on the backup 3B.
"Really, I'm not out to destroy Microsoft. That will just be a completely unintentional side effect." Linus Torvalds, 28.9.2003

Have you already backed up your Raspberries :?: For me raspiBackup creates them unattended every week :D

User avatar
AkulaMD
Posts: 356
Joined: Fri Jun 19, 2020 6:51 am

Re: Bookworm update: generating a heap of /boot/initrd.img....

Thu Dec 07, 2023 5:19 pm

redvli wrote:
Wed Dec 06, 2023 1:54 pm
If you use 64-bit OS

Code: Select all

sudo apt purge linux-image-rpi-2712 linux-image-rpi-v6 linux-image-rpi-v7 linux-image-rpi-v7l
will remove all unneeded and unused kernels.
What command should I use to retain the RP4 and RP5 but delete all others?
Btw, by deleting all this, how much saving we are looking at?
Thank you in advance.
Raspberry Pi OS (64-bit) with desktop and recommended software
Raspberry Pi 5 Model B 4GB at stock speed (never overclock)

Never overclock your Pi.
Encourage optimization instead.

redvli
Posts: 1735
Joined: Thu Sep 03, 2020 8:09 am

Re: Bookworm update: generating a heap of /boot/initrd.img....

Thu Dec 07, 2023 6:09 pm

AkulaMD wrote:
Thu Dec 07, 2023 5:19 pm
redvli wrote:
Wed Dec 06, 2023 1:54 pm
If you use 64-bit OS

Code: Select all

sudo apt purge linux-image-rpi-2712 linux-image-rpi-v6 linux-image-rpi-v7 linux-image-rpi-v7l
will remove all unneeded and unused kernels.
What command should I use to retain the RP4 and RP5 but delete all others?

Code: Select all

sudo apt purge linux-image-rpi-v6 linux-image-rpi-v7 linux-image-rpi-v7l
Btw, by deleting all this, how much saving we are looking at?
Thank you in advance.
An initrd file is usually about 10MB to 30MB if is it about space. On a Pi5 with SSD speed/time is not a big issue, but on Pi1 an Pi0 from SD-card it takes many minutes. It depends if you wait on it to finish of course, I mostly run it in a background terminal including pre and post backup and reboot.

redvli
Posts: 1735
Joined: Thu Sep 03, 2020 8:09 am

Re: Bookworm update: generating a heap of /boot/initrd.img....

Fri Dec 08, 2023 7:48 am

framp wrote:
Thu Dec 07, 2023 5:06 pm
I switched from Bullseye to Bookworm recently and detected yesterday an upgrade now takes > 20 minutes if all the kernels are built on my 1B. I know it's the least powerful Raspberry but even with Bookworm all applications run successful with no performance issues.
In the kernel post-install process there is a shell variable INITRD. If you know Linux and/or generic Debian well enough, you might set that to 'false' so then initramfs won't be generated. You also need to tell the firmware/bootloader not to load initramfs by setting auto_initramfs=0 and/or removing older initrd statements.

In the past, when the bootpartition was mounted on /boot instead of /boot/firmware, there was also RPINITRD or so, it actually was broken in Bullseye, at least my search to do something with it ended in nirvana.

No initrd likely means no filesystems check at bootup which I saw it is there in Bookworm, so things like dirty flag on FAT32 bootpartition won't be fixed I think. But you need your own research, I need initrd.
My Pi1 is remote headless PoE powered since 2016, I do upgrades, even the dist-upgrade from Bullseye to Bookworm via ssh/remote, so I don't wait for it, just start it in a background terminal session and next day or so it has rebooted if that is needed.

User avatar
framp
Posts: 171
Joined: Sun Jan 27, 2013 7:03 pm
Location: next to Stuttgart, Germany

Re: Bookworm update: generating a heap of /boot/initrd.img....

Fri Dec 08, 2023 10:22 pm

redvli wrote:
Fri Dec 08, 2023 7:48 am
If you know Linux and/or generic Debian well enough, you might set that to 'false' so then initramfs won't be generated.
I never deep dived into the Linux initramfs processing. But your hint may help others when they find this thread :)
redvli wrote:
Fri Dec 08, 2023 7:48 am
My Pi1 is remote headless PoE powered since 2016, I do upgrades, even the dist-upgrade from Bullseye to Bookworm via ssh/remote, so I don't wait for it, just start it in a background terminal session and next day or so it has rebooted if that is needed.
I see your point. Just kick off the upgrade in a screen session and log out and check next day. But if there are any upgrade issues my clients @home will not be able to connect to the internet because my 1B provides important networking services. That's why I monitor the upgrade process carefully all the time. It took about 3 minutes with Bullseye and now takes about 20 mins with Bookworm because of the kernel stuff generation :oops:
"Really, I'm not out to destroy Microsoft. That will just be a completely unintentional side effect." Linus Torvalds, 28.9.2003

Have you already backed up your Raspberries :?: For me raspiBackup creates them unattended every week :D

User avatar
framp
Posts: 171
Joined: Sun Jan 27, 2013 7:03 pm
Location: next to Stuttgart, Germany

Re: Bookworm update: generating a heap of /boot/initrd.img....

Tue Dec 12, 2023 9:58 pm

I just created a small script which deletes unused kernels and allows to reinstall the deleted kernels if needed. I tested it on a CM4 running Bookworm32 lite and on my RPi1 running also Bookworm32 lite. Not sure whether the script will work with all HW platform and OS combinations. In any case a user has to confirm he has a backup :D

If there are any improvements possible just let me know or create an issue or PR in github ;)
"Really, I'm not out to destroy Microsoft. That will just be a completely unintentional side effect." Linus Torvalds, 28.9.2003

Have you already backed up your Raspberries :?: For me raspiBackup creates them unattended every week :D

User avatar
AkulaMD
Posts: 356
Joined: Fri Jun 19, 2020 6:51 am

Re: Bookworm update: generating a heap of /boot/initrd.img....

Wed Dec 13, 2023 1:57 am

redvli wrote:
Thu Dec 07, 2023 6:09 pm
AkulaMD wrote:
Thu Dec 07, 2023 5:19 pm
redvli wrote:
Wed Dec 06, 2023 1:54 pm
If you use 64-bit OS

Code: Select all

sudo apt purge linux-image-rpi-2712 linux-image-rpi-v6 linux-image-rpi-v7 linux-image-rpi-v7l
will remove all unneeded and unused kernels.
What command should I use to retain the RP4 and RP5 but delete all others?

Code: Select all

sudo apt purge linux-image-rpi-v6 linux-image-rpi-v7 linux-image-rpi-v7l
Btw, by deleting all this, how much saving we are looking at?
Thank you in advance.
An initrd file is usually about 10MB to 30MB if is it about space. On a Pi5 with SSD speed/time is not a big issue, but on Pi1 an Pi0 from SD-card it takes many minutes. It depends if you wait on it to finish of course, I mostly run it in a background terminal including pre and post backup and reboot.
Thank you very much for the sharing.
Raspberry Pi OS (64-bit) with desktop and recommended software
Raspberry Pi 5 Model B 4GB at stock speed (never overclock)

Never overclock your Pi.
Encourage optimization instead.

User avatar
AkulaMD
Posts: 356
Joined: Fri Jun 19, 2020 6:51 am

Re: Bookworm update: generating a heap of /boot/initrd.img....

Wed Dec 13, 2023 9:31 am

framp wrote:
Tue Dec 12, 2023 9:58 pm
I just created a small script which deletes unused kernels and allows to reinstall the deleted kernels if needed. I tested it on a CM4 running Bookworm32 lite and on my RPi1 running also Bookworm32 lite. Not sure whether the script will work with all HW platform and OS combinations. In any case a user has to confirm he has a backup :D

If there are any improvements possible just let me know or create an issue or PR in github ;)
A newbie question here. May I know from where the script pull the kernels to perform the function of "to reinstall the deleted kernels if needed"? And does the script wait for users to choose which kernel that needed to be reinstalled? Thank you in advance.
Raspberry Pi OS (64-bit) with desktop and recommended software
Raspberry Pi 5 Model B 4GB at stock speed (never overclock)

Never overclock your Pi.
Encourage optimization instead.

User avatar
framp
Posts: 171
Joined: Sun Jan 27, 2013 7:03 pm
Location: next to Stuttgart, Germany

Re: Bookworm update: generating a heap of /boot/initrd.img....

Wed Dec 13, 2023 9:34 pm

When you remove unused kernels the names of the current unused kernels are saved in /boot/deletedKernels.txt. That way the script can install the deleted kernels again if requested. There is no way to select which kernels to reinstall. All kernels deleted previously will be reinstalled.
"Really, I'm not out to destroy Microsoft. That will just be a completely unintentional side effect." Linus Torvalds, 28.9.2003

Have you already backed up your Raspberries :?: For me raspiBackup creates them unattended every week :D

Return to “Raspberry Pi OS”