Thursday, April 11, 2019

how to remove old kernels in grub2, including files?

How to remove old kernels in Grub2, including files.


Using the Disk Usage Analyzer, I found that the Linux
kernels are located in 4 areas of the root directory:
/boot
/lib/firmware
/lib/modules
/usr/src


All we have to do is, go to each directory and remove the
files or directories that are not needed.


Use the command [rm] for files and [rm -r] for directories.
You have to use [sudo su] to have administrative account, or
use [sudo (command)] to invoke administrative command.


For our example, we will use the linux kernel version 4.4.0-112
You can choose which version you will remove.


at /boot = kernels are all files : abi-4.4.0-112-generic
config-4.4.0-112-generic
initrd.img-4.4.0-112-generic
retpoline-4.4.0-112-generic
System.map-4.4.0-112-generic
vmliniz-4.4.0-112-generic


(note: not all kernel versions have these files included above)


at /lib/firmware = kernels are in subdirectories : 4.4.0-112-generic


at /lib/modules = kernels are in subdirectories : 4.4.0-112-generic


at /usr/src = kernels are in subdirectories : linux-headers-4.4.0-112
linux-headers-4.4.0-112-generic


Now all we need to do is use the command [update-grub]


This will free your hard disk around 300MB worth of disk space
for every kernel that you will remove.


Please note that I am using Ubuntu 16.04 Xenial.


And if anybody knows how to delete files in GUI,
please let me know, it would be alot easier.

No comments:

Post a Comment

11.10 - Can't boot from USB after installing Ubuntu

I bought a Samsung series 5 notebook and a very strange thing happened: I installed Ubuntu 11.10 from a usb pen drive but when I restarted (...