I have ubuntu 20.04. I have been having problems with the /boot folder running out of space.
$ sudo apt list --installed | grep linux-image
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
linux-image-5.11.0-38-generic/focal-updates,focal-security,now 5.11.0-38.42~20.04.1 amd64 [installed]
linux-image-5.11.0-40-generic/focal-updates,focal-security,now 5.11.0-40.44~20.04.2 amd64 [installed,automatic]
linux-image-5.11.0-41-generic/focal-updates,focal-security,now 5.11.0-41.45~20.04.1 amd64 [installed,automatic]
linux-image-5.11.0-43-generic/focal-updates,focal-security,now 5.11.0-43.47~20.04.2 amd64 [installed,automatic]
linux-image-5.11.0-44-generic/focal-updates,focal-security,now 5.11.0-44.48~20.04.2 amd64 [installed,automatic]
linux-image-5.11.0-46-generic/focal-updates,focal-security,now 5.11.0-46.51~20.04.1 amd64 [installed]
linux-image-5.13.0-25-generic/focal-updates,focal-security,now 5.13.0-25.26~20.04.1 amd64 [installed]
linux-image-5.13.0-27-generic/focal-updates,focal-security,now 5.13.0-27.29~20.04.1 amd64 [installed]
linux-image-5.13.0-28-generic/focal-updates,focal-security,now 5.13.0-28.31~20.04.1 amd64 [installed]
linux-image-5.13.0-30-generic/focal-updates,focal-security,now 5.13.0-30.33~20.04.1 amd64 [installed]
linux-image-5.13.0-35-generic/focal-updates,focal-security,now 5.13.0-35.40~20.04.1 amd64 [installed,automatic]
linux-image-5.13.0-37-generic/focal-updates,focal-security,now 5.13.0-37.42~20.04.1 amd64 [installed,automatic]
linux-image-5.13.0-48-generic/focal-updates,focal-security,now 5.13.0-48.54~20.04.1 amd64 [installed,automatic]
linux-image-5.13.0-51-generic/focal-updates,focal-security,now 5.13.0-51.58~20.04.1 amd64 [installed]
linux-image-5.13.0-52-generic/focal-updates,focal-security,now 5.13.0-52.59~20.04.1 amd64 [installed]
linux-image-5.15.0-41-generic/focal-updates,focal-security,now 5.15.0-41.44~20.04.1 amd64 [installed]
linux-image-5.15.0-43-generic/focal-updates,focal-security,now 5.15.0-43.46~20.04.1 amd64 [installed]
linux-image-5.15.0-46-generic/focal-updates,focal-security,now 5.15.0-46.49~20.04.1 amd64 [installed]
linux-image-5.15.0-48-generic/focal-updates,focal-security,now 5.15.0-48.54~20.04.1 amd64 [installed]
linux-image-5.15.0-50-generic/focal-updates,focal-security,now 5.15.0-50.56~20.04.1 amd64 [installed]
linux-image-5.15.0-52-generic/focal-updates,focal-security,now 5.15.0-52.58~20.04.1 amd64 [installed]
linux-image-5.15.0-53-generic/focal-updates,focal-security,now 5.15.0-53.59~20.04.1 amd64 [installed]
linux-image-5.15.0-56-generic/focal-updates,focal-security,now 5.15.0-56.62~20.04.1 amd64 [installed]
linux-image-5.15.0-57-generic/focal-updates,focal-security,now 5.15.0-57.63~20.04.1 amd64 [installed]
linux-image-5.15.0-58-generic/focal-updates,focal-security,now 5.15.0-58.64~20.04.1 amd64 [installed]
linux-image-5.15.0-67-generic/focal-updates,focal-security,now 5.15.0-67.74~20.04.1 amd64 [installed]
linux-image-5.15.0-69-generic/focal-updates,focal-security,now 5.15.0-69.76~20.04.1 amd64 [installed]
linux-image-5.15.0-71-generic/focal-updates,focal-security,now 5.15.0-71.78~20.04.1 amd64 [installed]
linux-image-5.15.0-79-generic/focal-updates,focal-security,now 5.15.0-79.86~20.04.2 amd64 [installed]
linux-image-5.15.0-82-generic/focal-updates,focal-security,now 5.15.0-82.91~20.04.1 amd64 [installed]
linux-image-5.15.0-84-generic/focal-updates,focal-security,now 5.15.0-84.93~20.04.1 amd64 [installed]
linux-image-5.15.0-87-generic/focal-updates,focal-security,now 5.15.0-87.97~20.04.1 amd64 [installed]
linux-image-5.15.0-88-generic/focal-updates,focal-security,now 5.15.0-88.98~20.04.1 amd64 [installed]
linux-image-5.15.0-91-generic/focal-updates,focal-security,now 5.15.0-91.101~20.04.1 amd64 [installed]
linux-image-5.8.0-59-generic/focal-updates,focal-security,now 5.8.0-59.66~20.04.1 amd64 [installed]
linux-image-5.8.0-63-generic/focal-updates,focal-security,now 5.8.0-63.71~20.04.1 amd64 [installed]
linux-image-generic-hwe-20.04/focal-updates,focal-security,now 5.15.0.91.101~20.04.48 amd64 [installed,automatic]
linux-image-unsigned-5.11.0-27-generic/focal-updates,focal-security,now 5.11.0-27.29~20.04.1 amd64 [installed,automatic]
linux-image-unsigned-5.11.0-34-generic/focal-updates,focal-security,now 5.11.0-34.36~20.04.1 amd64 [installed,automatic]
linux-image-unsigned-5.11.0-36-generic/focal-updates,focal-security,now 5.11.0-36.40~20.04.1 amd64 [installed,automatic]
linux-image-unsigned-5.11.0-37-generic/focal-updates,focal-security,now 5.11.0-37.41~20.04.2 amd64 [installed,automatic]
linux-image-unsigned-5.13.0-39-generic/focal-updates,focal-security,now 5.13.0-39.44~20.04.1 amd64 [installed,automatic]
linux-image-unsigned-5.13.0-40-generic/focal-updates,focal-security,now 5.13.0-40.45~20.04.1 amd64 [installed,automatic]
linux-image-unsigned-5.13.0-41-generic/focal-updates,focal-security,now 5.13.0-41.46~20.04.1 amd64 [installed,automatic]
linux-image-unsigned-5.13.0-44-generic/focal-updates,focal-security,now 5.13.0-44.49~20.04.1 amd64 [installed,automatic]
linux-image-unsigned-5.15.0-70-generic/focal-updates,focal-security,now 5.15.0-70.77~20.04.1 amd64 [installed,automatic]
linux-image-unsigned-5.15.0-72-generic/focal-updates,focal-security,now 5.15.0-72.79~20.04.1 amd64 [installed,automatic]
linux-image-unsigned-5.15.0-73-generic/focal-updates,focal-security,now 5.15.0-73.80~20.04.1 amd64 [installed,automatic]
linux-image-unsigned-5.15.0-86-generic/focal-updates,focal-security,now 5.15.0-86.96~20.04.1 amd64 [installed,automatic]
/boot folder contents:
$ ls -l /boot
total 342408
-rw-r--r-- 1 root root 262258 Aug 18 10:34 config-5.15.0-82-generic
-rw-r--r-- 1 root root 262265 Nov 16 08:58 config-5.15.0-91-generic
drwx------ 3 root root 4096 Dec 31 1969 efi
drwxr-xr-x 4 root root 4096 Dec 14 11:32 grub
-rw-r--r-- 1 root root 129102715 Sep 19 07:56 initrd.img-5.15.0-82-generic
-rw-r--r-- 1 root root 55717600 Dec 14 11:30 initrd.img-5.15.0-86-generic
-rw-r--r-- 1 root root 129129902 Dec 14 10:45 initrd.img-5.15.0-91-generic
lrwxrwxrwx 1 root root 28 Dec 14 11:30 initrd.img.old -> initrd.img-5.15.0-91-generic
drwx------ 2 root root 16384 Jun 9 2021 lost+found
-rw-r--r-- 1 root root 182704 Aug 18 2020 memtest86+.bin
-rw-r--r-- 1 root root 184380 Aug 18 2020 memtest86+.elf
-rw-r--r-- 1 root root 184884 Aug 18 2020 memtest86+_multiboot.bin
-rw------- 1 root root 6240491 Aug 18 10:34 System.map-5.15.0-82-generic
-rw------- 1 root root 6242483 Nov 16 08:58 System.map-5.15.0-91-generic
lrwxrwxrwx 1 root root 25 Dec 14 11:30 vmlinuz -> vmlinuz-5.11.0-25-generic
-rw------- 1 root root 11522568 Aug 18 12:03 vmlinuz-5.15.0-82-generic
-rw------- 1 root root 11517416 Nov 16 09:01 vmlinuz-5.15.0-91-generic
lrwxrwxrwx 1 root root 25 Dec 14 11:30 vmlinuz.old -> vmlinuz-5.15.0-91-generic
If I run:
sudo apt remove --purge linux-image-unsigned-5.11.0-25-generic
I get:
$ sudo apt remove --purge linux-image-unsigned-5.11.0-25-generic
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
linux-modules-5.11.0-25-generic : Depends: linux-image-5.11.0-25-generic but it is not going to be installed or
linux-image-unsigned-5.11.0-25-generic but it is not going to be installed
linux-modules-extra-5.11.0-25-generic : Depends: linux-image-5.11.0-25-generic but it is not going to be installed or
linux-image-unsigned-5.11.0-25-generic but it is not going to be installed
linux-signatures-nvidia-5.11.0-25-generic : Depends: linux-image-5.11.0-25-generic but it is not going to be installed or
linux-image-unsigned-5.11.0-25-generic but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
If I then run the command it suggests:
$ sudo apt --fix-broken install
It shows (moving to pastebin to free up characters):
https://pastebin.com/FmpseWKi
/boot partition size
$ df -h | grep boot
/dev/nvme0n1p2 704M 343M 310M 53% /boot
/dev/nvme0n1p1 511M 87M 425M 17% /boot/efi
I don't know how to purge these old kernels and how to keep the /boot folder from filling up.
UPDATE I tried using Synaptic as user68186 suggested (and also was suggested in the links posted). When I tried to only uninstall linux-image-5.13.0-25-generic, it also wanted to install linux-image-unsigned-5.13.0-25-generic. I read here Removing linux-image kernel causes linux-image-unsigned package to be installed that this is because I need to also remove the corresponding modules package. I selected linux-modules-extra-5.13.0-25-generic and linux-image-5.13.0-25-generic, and This is what I got:
(Reading database ... 2036888 files and directories currently installed.)
Removing linux-signatures-nvidia-5.13.0-25-generic (5.13.0-25.26~20.04.1+1) ...
Removing linux-modules-extra-5.13.0-25-generic (5.13.0-25.26~20.04.1) ...
Removing linux-modules-5.13.0-25-generic (5.13.0-25.26~20.04.1) ...
Removing linux-image-5.13.0-25-generic (5.13.0-25.26~20.04.1) ...
I: /boot/vmlinuz.old is now a symlink to vmlinuz-5.15.0-82-generic
I: /boot/initrd.img.old is now a symlink to initrd.img-5.15.0-82-generic
I: /boot/vmlinuz is now a symlink to vmlinuz-5.15.0-91-generic
I: /boot/initrd.img is now a symlink to initrd.img-5.15.0-91-generic
/etc/kernel/postrm.d/initramfs-tools:
update-initramfs: Deleting /boot/initrd.img-5.13.0-25-generic
/etc/kernel/postrm.d/zz-update-grub:
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.15.0-91-generic
Found initrd image: /boot/initrd.img-5.15.0-91-generic
Found linux image: /boot/vmlinuz-5.15.0-82-generic
Found initrd image: /boot/initrd.img-5.15.0-82-generic
Adding boot menu entry for UEFI Firmware Settings
done
Setting up linux-image-unsigned-5.11.0-36-generic (5.11.0-36.40~20.04.1) ...
Setting up linux-image-5.13.0-48-generic (5.13.0-48.54~20.04.1) ...
Setting up linux-image-unsigned-5.15.0-73-generic (5.15.0-73.80~20.04.1) ...
Setting up linux-image-unsigned-5.13.0-39-generic (5.13.0-39.44~20.04.1) ...
(Reading database ... 2029733 files and directories currently installed.)
Purging configuration files for linux-modules-5.13.0-25-generic (5.13.0-25.26~20.04.1) ...
Processing triggers for linux-image-5.13.0-48-generic (5.13.0-48.54~20.04.1) ...
/etc/kernel/postinst.d/dkms:
* dkms: running auto installation service for kernel 5.13.0-48-generic
...done.
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-5.13.0-48-generic
I: The initramfs will attempt to resume from /dev/dm-2
I: (/dev/mapper/vgubuntu-swap_1)
I: Set the RESUME variable to override this.
/etc/kernel/postinst.d/zz-update-grub:
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.15.0-91-generic
Found initrd image: /boot/initrd.img-5.15.0-91-generic
Found linux image: /boot/vmlinuz-5.15.0-82-generic
Found initrd image: /boot/initrd.img-5.15.0-82-generic
Adding boot menu entry for UEFI Firmware Settings
done
Processing triggers for linux-image-unsigned-5.15.0-73-generic (5.15.0-73.80~20.04.1) ...
/etc/kernel/postinst.d/dkms:
* dkms: running auto installation service for kernel 5.15.0-73-generic
...done.
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-5.15.0-73-generic
I: The initramfs will attempt to resume from /dev/dm-2
I: (/dev/mapper/vgubuntu-swap_1)
I: Set the RESUME variable to override this.
/etc/kernel/postinst.d/zz-update-grub:
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.15.0-91-generic
Found initrd image: /boot/initrd.img-5.15.0-91-generic
Found linux image: /boot/vmlinuz-5.15.0-82-generic
Found initrd image: /boot/initrd.img-5.15.0-82-generic
Adding boot menu entry for UEFI Firmware Settings
done
Processing triggers for linux-image-unsigned-5.13.0-39-generic (5.13.0-39.44~20.04.1) ...
/etc/kernel/postinst.d/dkms:
* dkms: running auto installation service for kernel 5.13.0-39-generic
...done.
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-5.13.0-39-generic
I: The initramfs will attempt to resume from /dev/dm-2
I: (/dev/mapper/vgubuntu-swap_1)
I: Set the RESUME variable to override this.
/etc/kernel/postinst.d/zz-update-grub:
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.15.0-91-generic
Found initrd image: /boot/initrd.img-5.15.0-91-generic
Found linux image: /boot/vmlinuz-5.15.0-82-generic
Found initrd image: /boot/initrd.img-5.15.0-82-generic
Adding boot menu entry for UEFI Firmware Settings
done
Processing triggers for linux-image-unsigned-5.11.0-36-generic (5.11.0-36.40~20.04.1) ...
/etc/kernel/postinst.d/dkms:
* dkms: running auto installation service for kernel 5.11.0-36-generic
...done.
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-5.11.0-36-generic
I: The initramfs will attempt to resume from /dev/dm-2
I: (/dev/mapper/vgubuntu-swap_1)
I: Set the RESUME variable to override this.
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-36-generic with 1.
run-parts: /etc/kernel/postinst.d/initramfs-tools exited with return code 1
dpkg: error processing package linux-image-unsigned-5.11.0-36-generic (--configure):
installed linux-image-unsigned-5.11.0-36-generic package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
linux-image-unsigned-5.11.0-36-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)
A package failed to install. Trying to recover:
Setting up linux-image-unsigned-5.11.0-36-generic (5.11.0-36.40~20.04.1) ...
Processing triggers for linux-image-unsigned-5.11.0-36-generic (5.11.0-36.40~20.04.1) ...
/etc/kernel/postinst.d/dkms:
* dkms: running auto installation service for kernel 5.11.0-36-generic
...done.
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-5.11.0-36-generic
I: The initramfs will attempt to resume from /dev/dm-2
I: (/dev/mapper/vgubuntu-swap_1)
I: Set the RESUME variable to override this.
Error 24 : Write error : cannot write compressed block
cpio: write error: Broken pipe
sort: write failed: 'standard output': Broken pipe
sort: write error
E: mkinitramfs failure cpio 2 lz4 -9 -l 24
update-initramfs: failed for /boot/initrd.img-5.11.0-36-generic with 1.
run-parts: /etc/kernel/postinst.d/initramfs-tools exited with return code 1
dpkg: error processing package linux-image-unsigned-5.11.0-36-generic (--configure):
installed linux-image-unsigned-5.11.0-36-generic package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
linux-image-unsigned-5.11.0-36-generic
Do you have any suggestions for what to do here?
Update 2
I ran
sudo apt autopurge
and got this (unfortunately it won't let me add anymore text to this question, so I had to put it in pastebin):
https://pastebin.com/wb00JM5y
Update 3
I was finally able to use Synaptic to remove the old kernels. For some reason it had a problem with 5.11.0-36 and 5.11.0-25. It was like I had to remove 36 first and then it let me remove 25. But after I got those removed, I could remove all the others with no errors.
Synaptic
to look up and remove old kernels. It will not fix the "Unmet dependencies" issue though. – user68186 Dec 14 '23 at 16:52