PDA

View Full Version : Safely and easily removing old Linux and initrd images.



rsteinmetz70112
April 11th, 2019, 06:27 PM
Whenever I update the kernel and generate a new grub configuration file I get a list of old images like the list below. Often that kernel version has long been removed How can I safely and easily remove these?



Found linux image: /boot/vmlinuz-4.4.0-145-generic
Found initrd image: /boot/initrd.img-4.4.0-145-generic
Found linux image: /boot/vmlinuz-4.4.0-142-generic
Found initrd image: /boot/initrd.img-4.4.0-142-generic
Found linux image: /boot/vmlinuz-4.4.0-138-generic
Found initrd image: /boot/initrd.img-4.4.0-138-generic
Found linux image: /boot/vmlinuz-4.4.0-112-generic
Found initrd image: /boot/initrd.img-4.4.0-112-generic
Found linux image: /boot/vmlinuz-4.4.0-103-generic
Found initrd image: /boot/initrd.img-4.4.0-103-generic
Found linux image: /boot/vmlinuz-2.6.32-31-generic
Found initrd image: /boot/initrd.img-2.6.32-31-generic
Found memtest86+ image: /memtest86+.elf
Found memtest86+ image: /memtest86+.bin

TheFu
April 11th, 2019, 06:48 PM
sudo apt autoremove works on 16.04 and later.
If it doesn't, post back and there are scripts.

Removing the left over kernels from prior releases is manual, methinks. Just get the package name and remove it.

dpkg -l |grep linux-image-2. will find the 2.6 kernel package name.

rsteinmetz70112
April 11th, 2019, 07:24 PM
# apt autoremove
Doesn't work for these old files. It does work when a new kernel is installed.

TheFu
April 11th, 2019, 07:35 PM
Try, sudo apt-get autoremove linux-image-4.4.0-1[0-3]* linux-image-2.*
apt-get works with regex.

TheFu
April 11th, 2019, 08:31 PM
Try, sudo apt-get remove linux-image-4.4.0-1[0-3]* linux-image-2.*
apt-get works with regex.

Update: autoremove --> remove above.