1

I'm receiving out of space errors when attempting to install updates on my Linux Mint 18 system. /boot is showing 100% full.

I noticed that I have a slew of old kernels that need to be removed. I installed byobu and issued purge-old-kernels however I again get the out of space error and none of the kernels are removed.

The same happens if I attempt to manually apt-get purge any of the old kernels.

Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 6 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up initramfs-tools (0.122ubuntu8.16) ...
update-initramfs: deferring update (trigger activated)
Setting up linux-image-4.4.0-169-generic (4.4.0-169.198) ...
Processing triggers for initramfs-tools (0.122ubuntu8.16) ...
update-initramfs: Generating /boot/initrd.img-4.15.0-70-generic

gzip: stdout: No space left on device
E: mkinitramfs failure cpio 141 gzip 1
update-initramfs: failed for /boot/initrd.img-4.15.0-70-generic with 1.
dpkg: error processing package initramfs-tools (--configure):
 subprocess installed post-installation script returned error exit status 1
Processing triggers for linux-image-4.4.0-169-generic (4.4.0-169.198) ...
/etc/kernel/postinst.d/dkms:
 * dkms: running auto installation service for kernel 4.4.0-169-generic
Error! echo
Your kernel headers for kernel 4.4.0-169-generic cannot be found at
/lib/modules/4.4.0-169-generic/build or /lib/modules/4.4.0-169-generic/source.
Error! echo
Your kernel headers for kernel 4.4.0-169-generic cannot be found at
/lib/modules/4.4.0-169-generic/build or /lib/modules/4.4.0-169-generic/source.
Error! echo
Your kernel headers for kernel 4.4.0-169-generic cannot be found at
/lib/modules/4.4.0-169-generic/build or /lib/modules/4.4.0-169-generic/source.
Error! echo
Your kernel headers for kernel 4.4.0-169-generic cannot be found at
/lib/modules/4.4.0-169-generic/build or /lib/modules/4.4.0-169-generic/source.
   ...done.
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-4.4.0-169-generic

gzip: stdout: No space left on device
E: mkinitramfs failure cpio 141 gzip 1
update-initramfs: failed for /boot/initrd.img-4.4.0-169-generic with 1.
run-parts: /etc/kernel/postinst.d/initramfs-tools exited with return code 1
dpkg: error processing package linux-image-4.4.0-169-generic (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 initramfs-tools
 linux-image-4.4.0-169-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)

Is there safe way of using rm to remove boot images without wrecking my system?

List of kernel headers/images: https://pastebin.com/TYFMv6x7

  • As a means of the last resort, you could get around the problem in two steps: 1) identify the kernel versions older than what you boot into; 2) truncate the files in /boot which belong to the packages of those older kernels (they all have versions encoded in their names, so it's easy to detect them). Truncation can be done merely by running something like : >/boot/a_file_to_truncate — the built-in : command writes nothing to its stdout and exits successfully; hence redirecting the output of such command to a file using > first truncates the file and then writes nothing to it. – kostix Dec 4 at 15:43
  • This way you would free up the space while keeping the files in place—allowing the uninstallation of the obsolete kernel packages to continue OK. – kostix Dec 4 at 15:43
  • To identify whan kernel you're running, run uname -a. – kostix Dec 4 at 15:44
3

The safest way to remove unused kernel packages is to use the utility purge-old-kernels, created by one of the developers of Ubuntu, Dustin Kirkland, available for desktop and server systems, Ubuntu and therefore Linux Mint.

To install and use the package do:

sudo apt-get install -y bikeshed byobu
sudo purge-old-kernels

If the utility fails to detect older kernels, it will display the message:

No kernels are eligible for removal

If your kernels were installed automatically, such kernels can be removed by the commands:

sudo apt-get autoremove
sudo apt-get autoclean

However, these commands may also fail when /boot is 100% full.

In that case, remove manually one or two old initrd.img* files. Verify first, using the command uname -a that you are not trying to remove your own kernel.

Once you have regained some space for successfully running apt-get, you may then run the above two commands.

Mind your backups before starting.

  • 1
    FWIW, in plain Debian 10 ("Buster") the purge-old-kernel utility is distributed as part of the byobu package, and it, in turn, is marked as replacing the bikeshed package. – kostix Dec 4 at 15:40
0

There are two or three places old kernels and associated cruft are stored. Here are the steps I use to get rid of the old cruft. I use the steps when remove-old-kernels leaves cruft lying around.

First, identify old kernels. They hang around in /boot:

$ cd /boot/
$ ls -1
config-5.0.0-36-generic
config-5.0.0-37-generic
efi
grub
initrd.img-5.0.0-36-generic
initrd.img-5.0.0-37-generic
memtest86+.bin
memtest86+.elf
memtest86+_multiboot.bin
System.map-5.0.0-36-generic
System.map-5.0.0-37-generic
vmlinuz-5.0.0-36-generic
vmlinuz-5.0.0-37-generic

Second, perform an apt-get remove and apt-get purge to remove the package files and packages from disk:

sudo apt get -y remove '*5.0.0-36*
...
sudo apt-get -y purge
...

DKMS may have some cruft in /lib/modules. I often have un-removed cruft because Nvidia and VirtualBox. I have no idea why 4.15.0-nn kernel gear keeps getting reinstalled. I keep removing it, it keeps coming back.

Third, see if DKMS cruft remains.

# dkms status
nvidia, 430.50, 4.15.0-72-generic, x86_64: installed
nvidia, 430.50, 5.0.0-36-generic, x86_64: installed
nvidia, 430.50, 5.0.0-37-generic, x86_64: installed
virtualbox, 5.2.34, 4.15.0-72-generic, x86_64: installed
virtualbox, 5.2.34, 5.0.0-36-generic, x86_64: installed
virtualbox, 5.2.34, 5.0.0-37-generic, x86_64: installed

Fourth, remove the cruft with:

# dkms remove nvidia/430.50 -k 4.15.0-72-generic
# dkms remove nvidia/430.50 -k 5.0.0-36-generic
# dkms remove virtualbox/5.2.34 -k 4.15.0-72-generic
# dkms remove virtualbox/5.2.34 -k 5.0.0-36-generic

And then:

# find /var/lib -name '*4.15.0-72*'
/var/lib/dpkg/info/linux-headers-4.15.0-72.md5sums
/var/lib/dpkg/info/linux-headers-4.15.0-72.list
/var/lib/dpkg/info/linux-headers-4.15.0-72-generic.list
/var/lib/dpkg/info/linux-headers-4.15.0-72-generic.md5sums
/var/lib/dpkg/info/linux-headers-4.15.0-72-generic.postinst
/var/lib/dkms/nvidia/kernel-4.15.0-72-generic-x86_64
/var/lib/dkms/nvidia/430.26/4.15.0-72-generic
/var/lib/dkms/virtualbox/kernel-4.15.0-72-generic-x86_64
/var/lib/dkms/virtualbox/5.2.34/4.15.0-72-generic

Fifth, manually remove the old artifacts:

# find /var/lib -name '*4.15.0-72*' -exec rm -rf {} \;

Sixth, ensure there is no cruft in /lib/modules:

$ ls /lib/modules/
4.15.0-72-generic    5.0.0-36-generic    5.0.0-37-generic

And remove the old cruft:

$ sudo rm -rf /lib/modules/4.15.0-72-generic/
$ sudo rm -rf /lib/modules/5.0.0-36-generic/

Seventh, update initramfs and regenerate the grub menu:

# /sbin/depmod -a
# /usr/sbin/update-initramfs -u
# /usr/sbin/update-grub2

And finally, check the old kernels are really gone:

$ ls -1 /boot/
config-5.0.0-37-generic
efi
grub
initrd.img-5.0.0-37-generic
memtest86+.bin
memtest86+.elf
memtest86+_multiboot.bin
System.map-5.0.0-37-generic
vmlinuz-5.0.0-37-generic

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.