How do I remove unwanted kernels in my 12.x machine
sudo update-grub
Generating grub.cfg ...
Warning: Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported.
Found linux image: /boot/vmlinuz-3.13.0-96-generic
Found initrd image: /boot/initrd.img-3.13.0-96-generic
Found linux image: /boot/vmlinuz-3.13.0-93-generic
Found initrd image: /boot/initrd.img-3.13.0-93-generic
Found linux image: /boot/vmlinuz-3.13.0-35-generic
Found initrd image: /boot/initrd.img-3.13.0-35-generic
Found linux image: /boot/vmlinuz-3.11.0-26-generic
Found initrd image: /boot/initrd.img-3.11.0-26-generic
Found linux image: /boot/vmlinuz-3.8.0-44-generic
Found initrd image: /boot/initrd.img-3.8.0-44-generic
Found linux image: /boot/vmlinuz-3.5.0-61-generic
Found initrd image: /boot/initrd.img-3.5.0-61-generic
Found linux image: /boot/vmlinuz-3.5.0-18-generic
Found initrd image: /boot/initrd.img-3.5.0-18-generic
Found linux image: /boot/vmlinuz-3.2.0-68-generic
Found initrd image: /boot/initrd.img-3.2.0-68-generic
Found linux image: /boot/vmlinuz-3.13.0-96-generic
Found initrd image: /boot/initrd.img-3.13.0-96-generic
Found linux image: /boot/vmlinuz-3.13.0-93-generic
Found initrd image: /boot/initrd.img-3.13.0-93-generic
Found linux image: /boot/vmlinuz-3.13.0-35-generic
Found initrd image: /boot/initrd.img-3.13.0-35-generic
Found linux image: /boot/vmlinuz-3.11.0-26-generic
Found initrd image: /boot/initrd.img-3.11.0-26-generic
Found linux image: /boot/vmlinuz-3.8.0-44-generic
Found initrd image: /boot/initrd.img-3.8.0-44-generic
Found linux image: /boot/vmlinuz-3.5.0-61-generic
Found initrd image: /boot/initrd.img-3.5.0-61-generic
Found linux image: /boot/vmlinuz-3.5.0-18-generic
Found initrd image: /boot/initrd.img-3.5.0-18-generic
Found linux image: /boot/vmlinuz-3.2.0-68-generic
Found initrd image: /boot/initrd.img-3.2.0-68-generic
Found memtest86+ image: /boot/memtest86+.bin
done
There is documentation on this issue over at the wiki, see here: https://help.ubuntu.com/community/RemoveOldKernels
If "apt-get autoremove" does not remove them, your best choice for precise might be to install the byobu package from it's PPA as mentioned on that page, to get the 'purge-old-kernels' command.
Please also note that Ubuntu 12.04 (Precise) reaches end of support next month in April and is now end-of-life. Please consider upgrading to 14.04 (trusty) or preferably 16.04 (xenial).
To remove old kernel, first you may want to use
sudo apt-get autoremove
as this command is the default approach offered byapt
tool to remove packages that were automatically installed to satisfy dependencies for other packages and are now no longer needed.If you feel like to doing it yourself, then do it. However there are an important thing to watch for, DO NOT EVER REMOVE CURRENTLY USED KERNEL !!!. Did this and you're done for sure.
(To check currently kernel images, run
uname -r
on terminal)For safer alterniative, consider try a command called
purge-old-kernels
that can be used to purge extra kernels. It will keep 2 latest kernels and the current one by default. The script is maintained on Byobu package, so install them:Followed by
purge-old-kernels
command: