After the Kernel is updated, the old unused kernels in Ubuntu are not removed by default. To clean them, you can do the following actions.
Added on 2018-03-16: I find a better method to do the same thing from here. What you do is just install the “byobu” package and run the “purge-old-kernels” command like below:
sudo apt-get install byobu
I test this solution on Mint 18.3. It should also work on Ubuntu.
Here is the previous solution.
Run “apt autoremove”:
~> sudo apt autoremove --purge
[sudo] password for gang:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
linux-headers-4.4.0-57* linux-headers-4.4.0-57-generic* linux-image-4.4.0-57-generic* linux-image-extra-4.4.0-57-generic*
0 upgraded, 0 newly installed, 4 to remove and 0 not upgraded.
After this operation, 296 MB disk space will be freed.
Do you want to continue? [Y/n] y
For some kernels cannot be removed by the “apt autoremove” command, you can run the following command to list them first(from here):
~> dpkg -l | tail -n +6 | grep -E 'linux-image-[0-9]+' | grep -Fv $(uname -r)rc linux-image-4.4.0-31-generic 4.4.0-31.50 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
rc linux-image-4.4.0-47-generic 4.4.0-47.68 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
rc linux-image-4.4.0-51-generic 4.4.0-51.72 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii linux-image-4.4.0-53-generic 4.4.0-53.74 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii linux-image-4.4.0-59-generic 4.4.0-59.80 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
Note that in the above command, the “grep -Fv $(uname -r)” section makes sure that you won’t remove the current used kernel, without which you may remove the current used kernel and Ubuntu will not be able to boot.
Then remove the kernels by the following commands: