Score:0

Updating Ubuntu when /boot partition is almost full

gs flag
ile

My /boot partition is 500M in size, as I thought it would be enough when I did the installation. It seems it isn't.

Now it's almost full

/dev/sda1               446M  352M   61M  86% /boot

Doing apt-get upgrade doesn't succeed:

update-initramfs: Generating /boot/initrd.img-5.11.0-25-generic
Error 24 : Write error : cannot write compressed block 
E: mkinitramfs failure cpio 141 lz4 -9 -l 24
update-initramfs: failed for /boot/initrd.img-5.11.0-25-generic with 1.
dpkg: error processing package initramfs-tools (--configure):
 installed initramfs-tools package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 initramfs-tools
E: Sub-process /usr/bin/dpkg returned an error code (1)

Contents of the /boot:

total 343M
-rw-r--r--  1 root root 248K kesä   17 01:38 config-5.11.0-22-generic
-rw-r--r--  1 root root 248K heinä   9 20:42 config-5.11.0-25-generic
drwx------  6 root root 4,0K tammi   1  1970 efi
drwxr-xr-x  4 root root 4,0K heinä  23 13:13 grub
-rw-r--r--  1 root root 153M heinä  10 14:22 initrd.img-5.11.0-22-generic
-rw-r--r--  1 root root 151M heinä  23 13:13 initrd.img-5.11.0-25-generic
lrwxrwxrwx  1 root root   28 heinä  23 06:04 initrd.img.old -> initrd.img-5.11.0-22-generic
drwx------  2 root root  16K heinä   6 08:52 lost+found
-rw-r--r--  1 root root 179K elo    18  2020 memtest86+.bin
-rw-r--r--  1 root root 181K elo    18  2020 memtest86+.elf
-rw-r--r--  1 root root 181K elo    18  2020 memtest86+_multiboot.bin
-rw-------  1 root root 5,7M kesä   17 01:38 System.map-5.11.0-22-generic
-rw-------  1 root root 5,7M heinä   9 20:42 System.map-5.11.0-25-generic
lrwxrwxrwx  1 root root   25 heinä  23 06:04 vmlinuz -> vmlinuz-5.11.0-25-generic
-rw-------  1 root root  15M kesä   17 01:55 vmlinuz-5.11.0-22-generic
-rw-------  1 root root  15M heinä   9 21:04 vmlinuz-5.11.0-25-generic
lrwxrwxrwx  1 root root   25 heinä  23 06:04 vmlinuz.old -> vmlinuz-5.11.0-22-generic

Do I need to resize my boot partition? Is there a way to do the upgrade without resizing boot partition?

N0rbert avatar
zw flag
Does this answer your question? [How do I free up space on /boot?](https://askubuntu.com/questions/1032783/how-do-i-free-up-space-on-boot)
Zeiss Ikon avatar
cn flag
Looks like the initrd.* entries are where the space is going -- those are over 300M for two of them.
ile avatar
gs flag
ile
@N0rbert No, this is a different question. For example, the update tool could handle this situation.
karel avatar
sa flag
Does this answer your question? [How to resize partitions?](https://askubuntu.com/questions/126153/how-to-resize-partitions)
ile avatar
gs flag
ile
No it doesn't, @karel.
ile avatar
gs flag
ile
The main partition is encrypted and resizing it seems to be complicated. So it seems I won't be updating my Ubuntu for a while. https://help.ubuntu.com/community/ResizeEncryptedPartitions
Score:1
pk flag

try

to check installed kernels first

dpkg --list | egrep -i --color 'linux-image|linux-headers' | wc -l

to delete older versions of kernel

sudo apt --purge <kernel> autoremove

or 

sudo apt-get --purge <kernel> autoremove

its mostly wise to keep older kernels to revert back to incase u face some problems

Zeiss Ikon avatar
cn flag
For my own use, I keep at least one, but seldom more than two old kernel versions, plus the latest one or two versions of the plain generic kernel if I'm running HWE kernel. Enough to fall back on, not enough to take up huge amounts of space.
ile avatar
gs flag
ile
There is only the 22, which is currently in use (it seems) and 25 (which failed to update). So it seems I need to resize the boot partition, which is a shame. Thanks.
Henzo avatar
pk flag
yes dont use lvm for boot incase ur thinking of it
Score:0
cn flag

Based on what I see in your /boot volume, it looks to me like you need to resize that volume. BE SURE YOU BACK UP EVERYTHING BEFORE YOU START!

I say this because the initramfs entries for two kernels are taking up close to two thirds of the space you've allowed in /boot (with other files taking up most of the remaining third). There's not room for another kernel, headers, config, and initramfs. As a temporary fix, you could follow @Henzo's answer to remove the older of the two kernels, but I like to be sure I have at least one older kernel in case a bug pops up or a file gets damaged.

If you're going to put your boot files in their own volume, I'd suggest (with modern 5.x kernels) you need to allow 2 GB to ensure you have enough for two or three older kernels plus the one you're installing for your upgrade. With modern hard disks and SSDs, this isn't a huge amount of space, but it's cheap insurance against having to resize a critical partition...

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.