How to remove kernel images on Ubuntu
I have upgraded the kernel on my Ubuntu and my system get broken and it is not working properly
on starting of ubuntu you can see a option advancnced startup and you can see the different version of linux kernel installed
In Ubuntu, kernel images consist of the following packages.
First, check what kernel image(s) are installed on your system.
open termianl and copy paste or type the command below one by one
Among the listed kernel images, you can remove a particular version (e.g., 3.19.0-15) as follows.
sudo apt-get purge linux-image-3.19.0-15
sudo apt-get purge linux-headers-3.19.0-15
The above commands will remove the kernel image, and its associated kernel modules and header files.
Note that removing an old kernel will automatically trigger the installation of the latest Linux kernel image if you haven't upgraded to it yet. Also, after the old kernel is removed, GRUB configuration will automatically be updated to remove the corresponding GRUB entry from GRUB menu.
If you have many unused kernels, you can remove multiple of them in one shot using the following shell expansion syntax. Note that this brace expansion will work only for bash or any compatible shells.
The above command will remove 4 kernel images: 3.19.0-18, 3.19.0-20, 3.19.0-21 and 3.19.0-25.
If GRUB configuration is not properly updated for whatever reason
after old kernels are removed, you can try to update GRUB configuration
manually with update-grub2 command.
on starting of ubuntu you can see a option advancnced startup and you can see the different version of linux kernel installed
How to Clean up Old Kernel Images with Apt-get
Before you remove old kernel images, remember that it is recommended to keep at least two kernel images (the latest one and an extra older version), in case the primary one goes wrong. That said, let's see how to uninstall old kernel images on Ubuntu platform.In Ubuntu, kernel images consist of the following packages.
- linux-image-<VERSION-NUMBER>: kernel image
- linux-image-extra-<VERSION-NUMBER>: extra kernel modules
- linux-headers-<VERSION-NUMBER>: kernel header files
open termianl and copy paste or type the command below one by one
dpkg --list | grep linux-image
dpkg --list | grep linux-headers
Among the listed kernel images, you can remove a particular version (e.g., 3.19.0-15) as follows.
sudo apt-get purge linux-image-3.19.0-15
sudo apt-get purge linux-headers-3.19.0-15
The above commands will remove the kernel image, and its associated kernel modules and header files.
Note that removing an old kernel will automatically trigger the installation of the latest Linux kernel image if you haven't upgraded to it yet. Also, after the old kernel is removed, GRUB configuration will automatically be updated to remove the corresponding GRUB entry from GRUB menu.
If you have many unused kernels, you can remove multiple of them in one shot using the following shell expansion syntax. Note that this brace expansion will work only for bash or any compatible shells.
sudo apt-get purge linux-image-3.19.0-{18,20,21,25}
sudo apt-get purge linux-headers-3.19.0-{18,20,21,25}
sudo apt-get purge linux-headers-3.19.0-{18,20,21,25}
sudo update-grub2
Now reboot and verify that your GRUB menu has been properly cleaned up.
Comments
Post a Comment