To delete old kernel images on a Debian or Ubuntu system, you can use the apt-get
command with the purge
option. This will remove the kernel images and their associated packages from your system, freeing up disk space.
dpkg
command:dpkg --list | grep linux-image
This will list the installed kernel images, along with their version numbers.
Determine which kernel images you want to delete. It is generally recommended to keep the latest two or three kernel images in case you need to boot into a different kernel for any reason. You can delete the older kernel images.
Uninstall the kernel images you want to delete using the apt-get
command with the purge
option. For example, to delete the linux-image-4.19.0-8-amd64
kernel image, you can run the following command:
sudo apt-get purge linux-image-4.19.0-8-amd64
This will remove the kernel image and its associated packages from your system.
Repeat step 3 for each kernel image you want to delete.
After deleting the old kernel images, you can use the update-grub
command to update the boot menu and remove the entries for the deleted kernel images:
sudo update-grub
This will update the boot menu and remove the entries for the deleted kernel images.
Note: It is generally recommended to keep at least one kernel image on your system in case you need to boot into a different kernel for any reason. Be careful when deleting kernel images, as it can cause problems if you delete the kernel image that your system is currently using.