How do I free up more space in /boot?












537














My /boot partition is nearly full and I get a warning every time I reboot my system. I already deleted old kernel packages (linux-headers...), actually I did that to install a newer kernel version that came with the automatic updates.



After installing that new version, the partition is nearly full again. So what else can I delete? Are there some other files associated to the old kernel images?



Here is a list of files that are on my /boot partition:



:~$ ls /boot/
abi-2.6.31-21-generic lost+found
abi-2.6.32-25-generic memtest86+.bin
abi-2.6.38-10-generic memtest86+_multiboot.bin
abi-2.6.38-11-generic System.map-2.6.31-21-generic
abi-2.6.38-12-generic System.map-2.6.32-25-generic
abi-2.6.38-8-generic System.map-2.6.38-10-generic
abi-3.0.0-12-generic System.map-2.6.38-11-generic
abi-3.0.0-13-generic System.map-2.6.38-12-generic
abi-3.0.0-14-generic System.map-2.6.38-8-generic
boot System.map-3.0.0-12-generic
config-2.6.31-21-generic System.map-3.0.0-13-generic
config-2.6.32-25-generic System.map-3.0.0-14-generic
config-2.6.38-10-generic vmcoreinfo-2.6.31-21-generic
config-2.6.38-11-generic vmcoreinfo-2.6.32-25-generic
config-2.6.38-12-generic vmcoreinfo-2.6.38-10-generic
config-2.6.38-8-generic vmcoreinfo-2.6.38-11-generic
config-3.0.0-12-generic vmcoreinfo-2.6.38-12-generic
config-3.0.0-13-generic vmcoreinfo-2.6.38-8-generic
config-3.0.0-14-generic vmcoreinfo-3.0.0-12-generic
extlinux vmcoreinfo-3.0.0-13-generic
grub vmcoreinfo-3.0.0-14-generic
initrd.img-2.6.31-21-generic vmlinuz-2.6.31-21-generic
initrd.img-2.6.32-25-generic vmlinuz-2.6.32-25-generic
initrd.img-2.6.38-10-generic vmlinuz-2.6.38-10-generic
initrd.img-2.6.38-11-generic vmlinuz-2.6.38-11-generic
initrd.img-2.6.38-12-generic vmlinuz-2.6.38-12-generic
initrd.img-2.6.38-8-generic vmlinuz-2.6.38-8-generic
initrd.img-3.0.0-12-generic vmlinuz-3.0.0-12-generic
initrd.img-3.0.0-13-generic vmlinuz-3.0.0-13-generic
initrd.img-3.0.0-14-generic vmlinuz-3.0.0-14-generic


Currently, I'm using the 3.0.0-14-generic kernel.










share|improve this question




















  • 4




    It's worth mentioning that not every Ubuntu installation will have a separate /boot partition - often it will all just be one big partition. This answer applies for those who do have a separate /boot partition. Those using LVM or "full disk" encryption need a separate /boot, otherwise it may be optional.
    – thomasrutter
    Oct 1 '14 at 3:38






  • 4




    If anyone else has the same problem as me: after /boot has no space left "apt-get upgrade" will fail when re-generating initrd files for the kernels that are installed or that the update-initramfs script believes are installed by examining the contents of /var/lib/initramfs-tools. In this situation one cannot remove old kernels using apt-get because the fscking /boot partition has no space left on device. One can do this using "dpkg -P" followed by cleaning up the corresponding entry in /boot (to free space) and /var/lib/initramfs-tools (the initrd image will not be generated).
    – wojci
    Feb 11 '17 at 8:20








  • 2




    A key point for correct answers is that they tell you to remove the packages containing the older versions of the kernel. Many web pages that address this problem recommend directly removing the files in the /boot partition; that may work for a while, but you may eventually update a package that re-creates files that are missing for the kernel versions that have packages, thereby running you out of space.
    – kgrittn
    Apr 20 '17 at 14:56












  • help.ubuntu.com/community/RemoveOldKernels
    – jarno
    Aug 12 '18 at 20:03
















537














My /boot partition is nearly full and I get a warning every time I reboot my system. I already deleted old kernel packages (linux-headers...), actually I did that to install a newer kernel version that came with the automatic updates.



After installing that new version, the partition is nearly full again. So what else can I delete? Are there some other files associated to the old kernel images?



Here is a list of files that are on my /boot partition:



:~$ ls /boot/
abi-2.6.31-21-generic lost+found
abi-2.6.32-25-generic memtest86+.bin
abi-2.6.38-10-generic memtest86+_multiboot.bin
abi-2.6.38-11-generic System.map-2.6.31-21-generic
abi-2.6.38-12-generic System.map-2.6.32-25-generic
abi-2.6.38-8-generic System.map-2.6.38-10-generic
abi-3.0.0-12-generic System.map-2.6.38-11-generic
abi-3.0.0-13-generic System.map-2.6.38-12-generic
abi-3.0.0-14-generic System.map-2.6.38-8-generic
boot System.map-3.0.0-12-generic
config-2.6.31-21-generic System.map-3.0.0-13-generic
config-2.6.32-25-generic System.map-3.0.0-14-generic
config-2.6.38-10-generic vmcoreinfo-2.6.31-21-generic
config-2.6.38-11-generic vmcoreinfo-2.6.32-25-generic
config-2.6.38-12-generic vmcoreinfo-2.6.38-10-generic
config-2.6.38-8-generic vmcoreinfo-2.6.38-11-generic
config-3.0.0-12-generic vmcoreinfo-2.6.38-12-generic
config-3.0.0-13-generic vmcoreinfo-2.6.38-8-generic
config-3.0.0-14-generic vmcoreinfo-3.0.0-12-generic
extlinux vmcoreinfo-3.0.0-13-generic
grub vmcoreinfo-3.0.0-14-generic
initrd.img-2.6.31-21-generic vmlinuz-2.6.31-21-generic
initrd.img-2.6.32-25-generic vmlinuz-2.6.32-25-generic
initrd.img-2.6.38-10-generic vmlinuz-2.6.38-10-generic
initrd.img-2.6.38-11-generic vmlinuz-2.6.38-11-generic
initrd.img-2.6.38-12-generic vmlinuz-2.6.38-12-generic
initrd.img-2.6.38-8-generic vmlinuz-2.6.38-8-generic
initrd.img-3.0.0-12-generic vmlinuz-3.0.0-12-generic
initrd.img-3.0.0-13-generic vmlinuz-3.0.0-13-generic
initrd.img-3.0.0-14-generic vmlinuz-3.0.0-14-generic


Currently, I'm using the 3.0.0-14-generic kernel.










share|improve this question




















  • 4




    It's worth mentioning that not every Ubuntu installation will have a separate /boot partition - often it will all just be one big partition. This answer applies for those who do have a separate /boot partition. Those using LVM or "full disk" encryption need a separate /boot, otherwise it may be optional.
    – thomasrutter
    Oct 1 '14 at 3:38






  • 4




    If anyone else has the same problem as me: after /boot has no space left "apt-get upgrade" will fail when re-generating initrd files for the kernels that are installed or that the update-initramfs script believes are installed by examining the contents of /var/lib/initramfs-tools. In this situation one cannot remove old kernels using apt-get because the fscking /boot partition has no space left on device. One can do this using "dpkg -P" followed by cleaning up the corresponding entry in /boot (to free space) and /var/lib/initramfs-tools (the initrd image will not be generated).
    – wojci
    Feb 11 '17 at 8:20








  • 2




    A key point for correct answers is that they tell you to remove the packages containing the older versions of the kernel. Many web pages that address this problem recommend directly removing the files in the /boot partition; that may work for a while, but you may eventually update a package that re-creates files that are missing for the kernel versions that have packages, thereby running you out of space.
    – kgrittn
    Apr 20 '17 at 14:56












  • help.ubuntu.com/community/RemoveOldKernels
    – jarno
    Aug 12 '18 at 20:03














537












537








537


339





My /boot partition is nearly full and I get a warning every time I reboot my system. I already deleted old kernel packages (linux-headers...), actually I did that to install a newer kernel version that came with the automatic updates.



After installing that new version, the partition is nearly full again. So what else can I delete? Are there some other files associated to the old kernel images?



Here is a list of files that are on my /boot partition:



:~$ ls /boot/
abi-2.6.31-21-generic lost+found
abi-2.6.32-25-generic memtest86+.bin
abi-2.6.38-10-generic memtest86+_multiboot.bin
abi-2.6.38-11-generic System.map-2.6.31-21-generic
abi-2.6.38-12-generic System.map-2.6.32-25-generic
abi-2.6.38-8-generic System.map-2.6.38-10-generic
abi-3.0.0-12-generic System.map-2.6.38-11-generic
abi-3.0.0-13-generic System.map-2.6.38-12-generic
abi-3.0.0-14-generic System.map-2.6.38-8-generic
boot System.map-3.0.0-12-generic
config-2.6.31-21-generic System.map-3.0.0-13-generic
config-2.6.32-25-generic System.map-3.0.0-14-generic
config-2.6.38-10-generic vmcoreinfo-2.6.31-21-generic
config-2.6.38-11-generic vmcoreinfo-2.6.32-25-generic
config-2.6.38-12-generic vmcoreinfo-2.6.38-10-generic
config-2.6.38-8-generic vmcoreinfo-2.6.38-11-generic
config-3.0.0-12-generic vmcoreinfo-2.6.38-12-generic
config-3.0.0-13-generic vmcoreinfo-2.6.38-8-generic
config-3.0.0-14-generic vmcoreinfo-3.0.0-12-generic
extlinux vmcoreinfo-3.0.0-13-generic
grub vmcoreinfo-3.0.0-14-generic
initrd.img-2.6.31-21-generic vmlinuz-2.6.31-21-generic
initrd.img-2.6.32-25-generic vmlinuz-2.6.32-25-generic
initrd.img-2.6.38-10-generic vmlinuz-2.6.38-10-generic
initrd.img-2.6.38-11-generic vmlinuz-2.6.38-11-generic
initrd.img-2.6.38-12-generic vmlinuz-2.6.38-12-generic
initrd.img-2.6.38-8-generic vmlinuz-2.6.38-8-generic
initrd.img-3.0.0-12-generic vmlinuz-3.0.0-12-generic
initrd.img-3.0.0-13-generic vmlinuz-3.0.0-13-generic
initrd.img-3.0.0-14-generic vmlinuz-3.0.0-14-generic


Currently, I'm using the 3.0.0-14-generic kernel.










share|improve this question















My /boot partition is nearly full and I get a warning every time I reboot my system. I already deleted old kernel packages (linux-headers...), actually I did that to install a newer kernel version that came with the automatic updates.



After installing that new version, the partition is nearly full again. So what else can I delete? Are there some other files associated to the old kernel images?



Here is a list of files that are on my /boot partition:



:~$ ls /boot/
abi-2.6.31-21-generic lost+found
abi-2.6.32-25-generic memtest86+.bin
abi-2.6.38-10-generic memtest86+_multiboot.bin
abi-2.6.38-11-generic System.map-2.6.31-21-generic
abi-2.6.38-12-generic System.map-2.6.32-25-generic
abi-2.6.38-8-generic System.map-2.6.38-10-generic
abi-3.0.0-12-generic System.map-2.6.38-11-generic
abi-3.0.0-13-generic System.map-2.6.38-12-generic
abi-3.0.0-14-generic System.map-2.6.38-8-generic
boot System.map-3.0.0-12-generic
config-2.6.31-21-generic System.map-3.0.0-13-generic
config-2.6.32-25-generic System.map-3.0.0-14-generic
config-2.6.38-10-generic vmcoreinfo-2.6.31-21-generic
config-2.6.38-11-generic vmcoreinfo-2.6.32-25-generic
config-2.6.38-12-generic vmcoreinfo-2.6.38-10-generic
config-2.6.38-8-generic vmcoreinfo-2.6.38-11-generic
config-3.0.0-12-generic vmcoreinfo-2.6.38-12-generic
config-3.0.0-13-generic vmcoreinfo-2.6.38-8-generic
config-3.0.0-14-generic vmcoreinfo-3.0.0-12-generic
extlinux vmcoreinfo-3.0.0-13-generic
grub vmcoreinfo-3.0.0-14-generic
initrd.img-2.6.31-21-generic vmlinuz-2.6.31-21-generic
initrd.img-2.6.32-25-generic vmlinuz-2.6.32-25-generic
initrd.img-2.6.38-10-generic vmlinuz-2.6.38-10-generic
initrd.img-2.6.38-11-generic vmlinuz-2.6.38-11-generic
initrd.img-2.6.38-12-generic vmlinuz-2.6.38-12-generic
initrd.img-2.6.38-8-generic vmlinuz-2.6.38-8-generic
initrd.img-3.0.0-12-generic vmlinuz-3.0.0-12-generic
initrd.img-3.0.0-13-generic vmlinuz-3.0.0-13-generic
initrd.img-3.0.0-14-generic vmlinuz-3.0.0-14-generic


Currently, I'm using the 3.0.0-14-generic kernel.







boot hard-drive filesystem disk-usage init






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 12 '18 at 20:16









Jastria Rahmat

1078




1078










asked Dec 22 '11 at 10:06









user6722

2,85031213




2,85031213








  • 4




    It's worth mentioning that not every Ubuntu installation will have a separate /boot partition - often it will all just be one big partition. This answer applies for those who do have a separate /boot partition. Those using LVM or "full disk" encryption need a separate /boot, otherwise it may be optional.
    – thomasrutter
    Oct 1 '14 at 3:38






  • 4




    If anyone else has the same problem as me: after /boot has no space left "apt-get upgrade" will fail when re-generating initrd files for the kernels that are installed or that the update-initramfs script believes are installed by examining the contents of /var/lib/initramfs-tools. In this situation one cannot remove old kernels using apt-get because the fscking /boot partition has no space left on device. One can do this using "dpkg -P" followed by cleaning up the corresponding entry in /boot (to free space) and /var/lib/initramfs-tools (the initrd image will not be generated).
    – wojci
    Feb 11 '17 at 8:20








  • 2




    A key point for correct answers is that they tell you to remove the packages containing the older versions of the kernel. Many web pages that address this problem recommend directly removing the files in the /boot partition; that may work for a while, but you may eventually update a package that re-creates files that are missing for the kernel versions that have packages, thereby running you out of space.
    – kgrittn
    Apr 20 '17 at 14:56












  • help.ubuntu.com/community/RemoveOldKernels
    – jarno
    Aug 12 '18 at 20:03














  • 4




    It's worth mentioning that not every Ubuntu installation will have a separate /boot partition - often it will all just be one big partition. This answer applies for those who do have a separate /boot partition. Those using LVM or "full disk" encryption need a separate /boot, otherwise it may be optional.
    – thomasrutter
    Oct 1 '14 at 3:38






  • 4




    If anyone else has the same problem as me: after /boot has no space left "apt-get upgrade" will fail when re-generating initrd files for the kernels that are installed or that the update-initramfs script believes are installed by examining the contents of /var/lib/initramfs-tools. In this situation one cannot remove old kernels using apt-get because the fscking /boot partition has no space left on device. One can do this using "dpkg -P" followed by cleaning up the corresponding entry in /boot (to free space) and /var/lib/initramfs-tools (the initrd image will not be generated).
    – wojci
    Feb 11 '17 at 8:20








  • 2




    A key point for correct answers is that they tell you to remove the packages containing the older versions of the kernel. Many web pages that address this problem recommend directly removing the files in the /boot partition; that may work for a while, but you may eventually update a package that re-creates files that are missing for the kernel versions that have packages, thereby running you out of space.
    – kgrittn
    Apr 20 '17 at 14:56












  • help.ubuntu.com/community/RemoveOldKernels
    – jarno
    Aug 12 '18 at 20:03








4




4




It's worth mentioning that not every Ubuntu installation will have a separate /boot partition - often it will all just be one big partition. This answer applies for those who do have a separate /boot partition. Those using LVM or "full disk" encryption need a separate /boot, otherwise it may be optional.
– thomasrutter
Oct 1 '14 at 3:38




It's worth mentioning that not every Ubuntu installation will have a separate /boot partition - often it will all just be one big partition. This answer applies for those who do have a separate /boot partition. Those using LVM or "full disk" encryption need a separate /boot, otherwise it may be optional.
– thomasrutter
Oct 1 '14 at 3:38




4




4




If anyone else has the same problem as me: after /boot has no space left "apt-get upgrade" will fail when re-generating initrd files for the kernels that are installed or that the update-initramfs script believes are installed by examining the contents of /var/lib/initramfs-tools. In this situation one cannot remove old kernels using apt-get because the fscking /boot partition has no space left on device. One can do this using "dpkg -P" followed by cleaning up the corresponding entry in /boot (to free space) and /var/lib/initramfs-tools (the initrd image will not be generated).
– wojci
Feb 11 '17 at 8:20






If anyone else has the same problem as me: after /boot has no space left "apt-get upgrade" will fail when re-generating initrd files for the kernels that are installed or that the update-initramfs script believes are installed by examining the contents of /var/lib/initramfs-tools. In this situation one cannot remove old kernels using apt-get because the fscking /boot partition has no space left on device. One can do this using "dpkg -P" followed by cleaning up the corresponding entry in /boot (to free space) and /var/lib/initramfs-tools (the initrd image will not be generated).
– wojci
Feb 11 '17 at 8:20






2




2




A key point for correct answers is that they tell you to remove the packages containing the older versions of the kernel. Many web pages that address this problem recommend directly removing the files in the /boot partition; that may work for a while, but you may eventually update a package that re-creates files that are missing for the kernel versions that have packages, thereby running you out of space.
– kgrittn
Apr 20 '17 at 14:56






A key point for correct answers is that they tell you to remove the packages containing the older versions of the kernel. Many web pages that address this problem recommend directly removing the files in the /boot partition; that may work for a while, but you may eventually update a package that re-creates files that are missing for the kernel versions that have packages, thereby running you out of space.
– kgrittn
Apr 20 '17 at 14:56














help.ubuntu.com/community/RemoveOldKernels
– jarno
Aug 12 '18 at 20:03




help.ubuntu.com/community/RemoveOldKernels
– jarno
Aug 12 '18 at 20:03










21 Answers
21






active

oldest

votes


















610














You've a lot unused kernels. Remove all but the last kernels with:



sudo apt-get purge linux-image-{3.0.0-12,2.6.3{1-21,2-25,8-{1[012],8}}}


This is shorthand for:



sudo apt-get purge linux-image-3.0.0-12 linux-image-2.6.31-21 linux-image-2.6.32-25 linux-image-2.6.38-10 linux-image-2.6.38-11 linux-image-2.6.38-12 linux-image-2.6.38-8


Removing the linux-image-x.x.x-x package will also remove linux-image-x.x.x-x-generic.



The headers are installed into /usr/src and are used when building out-tree kernel modules (like the proprietary nvidia driver and virtualbox). Most users should remove these header packages if the matching kernel package (linux-image-*) is not installed.



To list all installed kernels, run:



dpkg -l linux-image-* | grep ^ii


One command to show all kernels and headers that can be removed, excluding the current running kernel:



kernelver=$(uname -r | sed -r 's/-[a-z]+//')
dpkg -l linux-{image,headers}-"[0-9]*" | awk '/ii/{print $2}' | grep -ve $kernelver


It selects all packages named starting with linux-headers-<some number> or linux-image-<some number>, prints the package names for installed packages and then excludes the current loaded/running kernel (not necessarily the latest kernel!). This fits in the recommendation of testing a newer kernel before removing older, known-to-work kernels.



So, after upgrading kernels and rebooting to test it, you can remove all other kernels with:



sudo apt-get purge $(dpkg -l linux-{image,headers}-"[0-9]*" | awk '/ii/{print $2}' | grep -ve "$(uname -r | sed -r 's/-[a-z]+//')")





share|improve this answer



















  • 15




    Fantastic answer. One further piece of info would help: How can you tell (for sure) which of the kernels you're using? Presumably you can't just assume it's the last one... Edit: And it looks like the answer is uname -a. Probably best to ensure you don't have a pending restart-to-install-new-kernel pending (as I did; but I noted the mismatch between uname -a and the "latest" kernel).
    – T.J. Crowder
    Jun 14 '12 at 8:39








  • 5




    @freddyb Done. Note that the commands prints/removes kernels other than the loaded/booted one.
    – Lekensteyn
    Aug 13 '12 at 13:57






  • 8




    If apt-get purge fails because of unmet dependencies then you can follow the advice at askubuntu.com/questions/171209/…
    – svandragt
    Aug 7 '13 at 8:33






  • 10




    Very thorough answer and still works... and still needed in 2014. Kinda ridiculous that it's still not automatically done by the GUI tools.
    – allprog
    Apr 3 '14 at 8:30






  • 4




    @byf-ferdy The kernel is an essential part of the OS, if the newest version somehow does not fully work with your hardware, then you can still select a different one to boot from. A nice feature would probably be something that removes all automatically installed kernels older than a month (except for the latest two).
    – Lekensteyn
    Nov 1 '14 at 14:23



















207














Your boot partition is full. Since this is a kernel update, these files will be copied to the boot partition so you need to clean in out. Here is a blog post that will show you how to clear the old kernel images with one command. I'll give a basic synopsis of the method. Use this command to print out the current version of your kernel:



uname -r


Then use this command to print out all the kernels you have installed that aren't your newest kernel:



dpkg -l linux-{image,headers}-"[0-9]*" | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e '[0-9]'


Make sure your current kernel isn't on that list. Notice how this is the majority of the final command (down below). To uninstall and delete these old kernels you will want to pipe these arguments to:



sudo apt-get -y purge


Now we can do everything we want by combining these last two commands into this unholy mess:



dpkg -l linux-{image,headers}-"[0-9]*" | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e '[0-9]' | xargs sudo apt-get -y purge


And that one command will take care of everything for you. I will confirm that this does work perfectly but never trust anybody on the internet. :) For more info, the blog post gives a very good explanation of what each part of the command does so read through it so you are satisfied that it does what you want it to do.






share|improve this answer



















  • 6




    This worked great, thanks.
    – Michael Durrant
    Feb 21 '13 at 3:59










  • this also matches linux-libc-dev:amd64
    – Frederick Nord
    Aug 29 '14 at 16:39










  • what will the unintended removal of "linux-libc-dev:amd64" cause?
    – ConfusedStack
    Oct 12 '14 at 0:37










  • @FrederickNord thanks for the heads up. Fixed this. It would have caused some difficulties compiling c programs.
    – dward
    Oct 14 '14 at 19:01






  • 7




    The command sounds good, but when I run it I get the same error that I get when I want to install something and it can not do it because boot is full: --------------------------The following packages have unmet dependencies: linux-image-extra-4.2.0-27-generic : Depends: linux-image-4.2.0-27-generic but it is not going to be installed linux-image-extra-4.2.0-30-generic : Depends: linux-image-4.2.0-30-generic but it is not going to be installed
    – Alex
    Oct 1 '16 at 3:29





















96














sudo apt-get autoremove


This command is doing the job automatically.






share|improve this answer



















  • 7




    As the name suggests, apt-get AUTOremove is an automated operation where the system takes its "best guess" what you are trying to achieve. It should not be used as a substitute for common sense system administration. The problem with this approach: If you (or an update) removes a package that is part of this dependency list the auto-remove function wants to remove all other packages in the dependency list, leaving you with a system without working desktop (and sometimes even with a completely broken system).
    – Rinzwind
    Nov 5 '12 at 10:09










  • Reference: 1 of many sources for this comment above: linuxquestions.org/questions/debian-26/…
    – Rinzwind
    Nov 5 '12 at 10:10






  • 7




    if linux-image-generic is installed and new kernels were not installed explicitly, this will remove old kernels. Common sense is to not accept any changes to the system without reading them first. If common sense has been used prior to using this command then there will be no trouble.
    – mchid
    Mar 1 '15 at 23:34






  • 1




    @Rinzwind - This command emptied 250 mb of my disk space by removing old 'linux headers'
    – Chinmaya B
    Jul 28 '15 at 4:41






  • 2




    autoremove works if used before an out-of-space condition exists. However, once apt runs out of space and aborts (and the user finally notices the problem), it's too late to run autremove or any other apt-based solution. If that's the case for you, try one of the dpkg-based solutions.
    – user535733
    Feb 2 '17 at 14:25



















39














The Synaptic Package Manager can be used to easily select and remove old kernel images.
Screenshot of Synaptic Package Manager



If you don't already have Synaptic installed:



sudo apt-get install synaptic


Start the application and select the options shown.



You should be able to highlight all the "linux-" packages with the version "2.6.x" where x is between 31 to 38 according to the files in your /boot folder.



Right-click each of those linux packages and choose the option "Mark for Complete Removal". Finally click the apply button. This will remove all the files and any associated files. Your /boot folder should now be a bit tidier.






share|improve this answer























  • I'm on 14.04. I have handled this situation in the past via the command line, but I decided to try this method today... for me, my linux images were located under installed (manual), not installed (local or obsolete)
    – Ryan
    Jul 9 '16 at 20:32






  • 6




    Oh no. I can't install Synaptic because there is no space on /boot!
    – John McGehee
    Sep 16 '16 at 20:14










  • @JohnMcGehee fsck and parted should solve that issue for you.
    – FlipMcF
    Apr 3 '17 at 20:10



















24














Thank you for your detailed post of your problem, this got me going in the right direction. Although it is useful to keep previous kernel files you can remove all of them in one go, check this post:
How to Remove All Unused Linux Kernel Headers, Images and Modules



Done via command line. If you are doing this via remote use something like WINSCP to open a terminal session and just paste it in, works very well.



Here it is copied from article link, I suggest you read the full article:



dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/(.*)-([^0-9]+)/1/")"'/d;s/^[^ ]* [^ ]* ([^ ]*).*/1/;/[0-9]/!d' | xargs sudo apt-get -y purge





share|improve this answer































    22














    This is a new answer to an old question, but an easy way to clean this thing (and more) is to install Ubuntu Tweak. To install it:



    sudo add-apt-repository ppa:tualatrix/ppa
    sudo apt-get update
    sudo apt-get install ubuntu-tweak


    then you can run Ubuntu Tweak, Going to the "janitor" tab, and from here it's a matter of three clicks:



    Ubuntu tweak janitor for old kernels



    It is better to leave the last kernel (you never know) or a well-known working kernel for safety, though; but that's easily customizable.



    You can use the same tool to clean a lot of things --- just remember that if you clean thumbnail cache or TB cache then the system will have to rebuild them if they are needed.






    share|improve this answer





















    • I tried to install Ubuntu tweak and also going to the repository website. It says it is only for 13.10 and before. Do you have an updated version for 15.04?
      – JayCouture.com
      May 10 '15 at 13:57










    • @JayCouture.com The version in the site is for 14.04 (the "for 13.10 and before" is a link to older releases). I ignore if there is a version for 14.10 or 15.04 .
      – Rmano
      May 11 '15 at 22:15





















    17














    I was able to fix the problem by using dpkg to remove the packages directly. Although the packages are still listed in dpkg -l, the files are removed from /boot, freeing up space.



    phrogz@planar:/boot$ sudo dpkg --remove linux-image-2.6.32-30-server
    (Reading database ... 145199 files and directories currently installed.)
    Removing linux-image-2.6.32-30-server ...
    Running postrm hook script /usr/sbin/update-grub.
    Generating grub.cfg ...
    Found linux image: /boot/vmlinuz-2.6.32-35-server
    Found linux image: /boot/vmlinuz-2.6.32-34-server
    Found initrd image: /boot/initrd.img-2.6.32-34-server
    Found linux image: /boot/vmlinuz-2.6.32-33-server
    Found initrd image: /boot/initrd.img-2.6.32-33-server
    Found linux image: /boot/vmlinuz-2.6.32-32-server
    Found initrd image: /boot/initrd.img-2.6.32-32-server
    Found linux image: /boot/vmlinuz-2.6.32-31-server
    Found initrd image: /boot/initrd.img-2.6.32-31-server
    Found memtest86+ image: /memtest86+.bin
    done

    # Repeat for kernels -31 and -32 and -33, up to (but not including)
    # the version listed by `uname -a`


    After this, apt-get -f install fixed my dependency problems, and all was well with the world.



    I'll not be accepting this answer of mine, however, as I still need to know if I should be increasing my /boot size or doing something else.






    share|improve this answer





















    • You should either not have a separate /boot partition in the first place, or you should increase its size as 100mb is too small.
      – psusi
      Dec 4 '11 at 4:07






    • 1




      Thanks, I delete via: sudo dpkg --remove linux-headers-3.5.0-28*
      – TiloBunt
      Jul 16 '13 at 17:34








    • 2




      and sudo dpkg --remove linux-image-3.5.0-28* for the image, checked via df -h
      – TiloBunt
      Jul 16 '13 at 17:57



















    13














    You can stop using a separate /boot partition, then you won't have such limited space there. To do this, unmount the partition, then mount it somewhere else and copy all of the files there to the /boot directory in your root partition, then remove the entry from /etc/fstab and reinstall grub. For example ( you will need to use the correct partition ):



    sudo -s
    umount /boot
    mount /dev/sda2 /mnt
    cp -a /mnt/* /boot/
    umount /mnt
    gedit /etc/fstab
    grub-install /dev/sda


    You can then use gparted to delete the old /boot partition, and possibly extend the root partition to use that space. To extend the root partition you will need to boot from the livecd, and the free space needs to be immediately to the right. If the /boot partition is currently to the left of the root partition, then you will need to first move the root partition to the left, then extend it, but this can take a very, very long time, so may not be worth the trouble.






    share|improve this answer

















    • 6




      Moving /boot to my main partition isn't a solution for me since everything but /boot is encrypted. You couldn't know that from my question, sorry.
      – user6722
      Dec 24 '11 at 14:15










    • This is a good solution if the solutions above don't work due to having no space at all on the boot volume, or if you repeatedly have the "out of space" issue. Please read first why it's sometimes required to have a /boot partition though: (help.ubuntu.com/community/DiskSpace)
      – svandragt
      Jul 10 '14 at 8:26












    • @svandragt, there basically is no reason left to need a /boot partition these days. About the only one left is if your bios is broken and can't see the whole disk, and any machine made in the last decade doesn't have such a limitation. Other legacy cases such as using raid or LVM are now handled properly by grub2.
      – psusi
      Jul 11 '14 at 1:59










    • There's a few reasons for having a separate boot partition. But I'm not sure the benefits are worth the increased complexity setup. 1. OS can benefit from faster boot via ext2. 2. Security can be increased by mounting /boot as RO. (rootkits, etc.), or even remain unmounted at os runtime. 3. grub (1) has (had) some issues with ext4 still. 4. Required for running lvm (grubv1). Though this does not apply to the default ubuntu setup.
      – David Cahill
      Apr 13 '15 at 17:37












    • lsblk can be used to determine which partition is what
      – Mr Purple
      May 9 '16 at 9:51





















    5














    Taking the best from the answers above, my tried-and-true approach is this:





    • uname -a to find the running kernel.


    • dpkg -l linux-{headers,image}-* | grep ^ii to list all currently installed kernel-related packages. This will include the running kernel.


    • sudo apt-get purge linux-{image,headers}-3.16.0-{xx,yy,zz} to remove the old kernels. Replace xx,yy,zz with a list of the kernel builds you want to remove—these are all the builds listed by the previous command which are older than the currently running kernel. Make sure you don't remove the currently running kernel—your system will become unbootable. You may also need to change the kernel version from 3.16.0 to whatever is installed on your system.

    • Optionally, do an additional sudo apt-get autoremove—this will remove any leftover dependencies of the old kernels which are no longer needed by the current one, freeing up some more space.


    You may have header files without matching kernel versions installed, or vice versa—just include all of these versions in the command. APT will complain that some packages can't be removed because they are not installed, but that will do no harm.



    If something fails...




    • If the apt command fails due to a no space left on device error, use the corresponding dpkg command instead: sudo dpkg --purge linux-{image,headers}-3.16.0-{xx,yy,zz}.

    • If the dpkg command still doesn’t work because the linux-image packages are required by the linux-headers packages of the same version (which you also want to uninstall), dpkg may have failed to resolve that. Re-examine the output of dpkg -l and specify any package name suffixes on the command line. For example, on one of my systems the command that eventually worked was sudo dpkg --purge linux-{image,headers}-3.16.0-{xx,yy,zz}-generic-pae.

    • If you get any other error, seek help—you may have a different problem than you thought.






    share|improve this answer























    • @user535733 the usual case (at least the one I keep running into) is that there’s still some space on /boot, just not enough for another kernel package. In those cases the above has worked well. Feel free, though, to add the corresponding dpkg command. As for purge, no, it’s not a kind of ‘force-remove’. What it does, differently from remove, is that it deletes configuration files as well. Since/as long as kernel packages install no config files, remove and purge will do the same for kernel packages.
      – user149408
      Feb 3 '17 at 23:55










    • Added fourth bullet with the corresponding dpkg command.
      – user535733
      Feb 4 '17 at 0:02



















    4














    For me both apt-get purge and dpkg --remove both failed. So I had to deleted a couple of older kernel images from /boot with rm -f.






    share|improve this answer

















    • 4




      This is not a good way to remove packages. While this answer isn't very specific about why removing them the correct way failed, I'm sure if that information was given (in a separate question of course) we'd be able to try and figure out the cause of the problem.
      – thomasrutter
      Aug 29 '14 at 9:55






    • 2




      I believe it was failed, because /boot partition was full. This commands try first to upgrade kernel to recent and crash with No space left on device while generating initrd.img
      – vp_arth
      Dec 3 '15 at 15:50






    • 1




      WARNING, directly removing files can lead to problems, as an update of the linux-firmware package can recreate the initrd.img file for every version it thinks is installed based on package information. See: askubuntu.com/questions/865577/…
      – kgrittn
      Jan 5 '17 at 13:57










    • thanks, this is the life-saving final solution when nothing else works.
      – Jeff Puckett
      Aug 17 '17 at 3:28



















    2















    I already deleted old kernel packages (linux-headers...)




    linux-headers-* aren't kernels. Kernel packages are the ones named linux-image-*. The ones named linux-headers-* are development packages for compiling kernel modules: they don't live in the /boot directory and are not required for general day to day use of your system.



    The files you listed in /boot do include several old kernel images (vmlinuz*) and compiled initrd images (initrd.img*) for those kernels, which is an indication that you still have a lot of old kernel packages installed.



    You should be able to list your installed kernels with



    aptitude search ~ilinux-image


    (Note that this will probably return packages that aren't kernels, too).



    There is usually no need for more than two kernels to be installed - the one currently in use and the previous one to that (as a fallback). So you can start removing the older ones, one by one, like this:



    sudo apt-get autoremove linux-image-3.2.0-23-generic


    Make sure you substitute "3.2.0-23-generic" with the actual kernel version you want to remove! Also, don't remove packages such as linux-image-generic. You have to be really careful not to remove the currently running kernel or you won't be able to boot (Ubuntu may or may not warn you about doing this).



    You can find your currently running kernel with:



    uname -r





    share|improve this answer































      1














      I had this problem and more as I removed some initrd-img-xxx files manually from the /boot and I had a problem that these old versions keep generated and filling in the /boot folder. To fix it I followed the following:




      • I removed the generated old kernel version manually so to free space.


      • You’ll be editing a text configuration file as superuser, so paste the following into a terminal:



        sudo gedit /etc/initramfs-tools/update-initramfs.conf



      • Locate the line update_initramfs=yes and change it to update_initramfs=no. Save and exit the file, then run:



        sudo dpkg --configure -a



      That solved my problem. That was based on this blog



      Hopefully, everything should be fine when you reboot, and later you can try changing the no back to yes in update-initramfs.conf.






      share|improve this answer































        1














        List all kernels:



        dpkg --list 'linux-image*'


        Display current kernel:



        uname -r


        List all kernels EXCEPT current one:



        dpkg -l linux-{image,headers}-"[0-9]*" | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e '[0-9]'


        Make sure your current kernel isn't on that list.



        Remove all kernels EXCEPT current one:



        dpkg -l linux-{image,headers}-"[0-9]*" | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e '[0-9]' | xargs sudo apt-get -y purge


        Clear other stuff:



        sudo apt-get autoremove


        If it still gives you boot disk space error for installing/uninstalling files then directly remove one of OLD image from /boot directory,



        ls -lh /boot/*-3.13.0-119*;

        rm /boot/*-3.13.0-119*;


        NOTE: Please review current kernel image again before deleting any image.






        share|improve this answer





























          1














          Super helpful utility that will clear out your boot partition



          git clone https://github.com/erichs/bootnukem.git
          cd bootnukem
          sudo ./install.sh


          Use at your own risk, but it worked for me:



          sudo bootnukem





          share|improve this answer























          • Why the downvote?
            – Jonathan
            Feb 8 '17 at 2:30



















          0














          In aptitude or synaptic there is a section "old or manually installed packaged". There should be the old linux packages there.






          share|improve this answer





























            0














            There's a bash script which I wrote give below that makes the process a bit more user-friendly.



            YMMV - it was made for Mint 14. Still learning BASH so it's probably a bit clunky. Use at own risk, but it works for me!



            #!/bin/bash

            endCol='e[0m'
            bold_red='e[1;31m'
            bold_green='e[1;32m'
            bold_yellow='e[1;33m'

            title_color='e[0;30;47m'

            function show_kernel_info {
            clear
            current_kernel=$(uname -r)
            echo "Current ACTIVE kernel is:"
            echo -e " "$bold_yellow$current_kernel$endCol
            echo "This kernel will be TOTALLY EXCLUDED from all actions in this script."
            echo "Also, one fallback non-active kernel will be always left untouched."
            echo ""
            echo "These are the non-active kernels stored in /boot:"
            count_of_old_kernels_in_boot=$(ls -o /boot/initrd* | grep -c -v "$current_kernel")
            if [ $count_of_old_kernels_in_boot = 0 ]; then
            echo " * No non-active kernels found! *"
            else
            ls -o /boot/initrd* | grep -v "$current_kernel"
            fi
            echo ""
            list_of_old_kernels=$(dpkg --list | grep linux-image | awk -F' ' '{ print $2 }' | grep -v "$current_kernel" | grep -v "linux-image-generic")
            current_old_kernel=$(dpkg --list | grep linux-image | awk -F' ' '{ print $2 }' | grep -v "$current_kernel" | grep -v "linux-image-generic" | head -n 1)
            count_of_old_kernels_installed=$(dpkg --list | grep linux-image | awk -F' ' '{ print $2 }' | grep -v "$current_kernel" | grep -c -v "linux-image-generic")
            echo "Listing of all unused kernels still installed in the system (these may not exist in /boot):"
            if [ $count_of_old_kernels_installed = 0 ]; then
            echo " * No unused kernel installs found! *"
            else
            dpkg --list | grep linux-image | awk -F' ' '{ print $2 }' | grep -v "$current_kernel" | grep -v "linux-image-generic"
            fi
            echo ""
            }

            function exit_script {
            free_space_after=$(df -BM /boot | tail -n 1 | awk -F' ' '{ print $4 }' | tr -d M)
            let freed_space=$free_space_after-$free_space_before
            echo ""
            echo "Results (in MB)"
            echo "---------------"
            echo "Free space in /boot before script was run: "$free_space_before
            echo "Free space now: "$free_space_after
            echo ""
            echo "Amount of space freed up = "$freed_space
            echo ""
            echo "Press any key to exit."
            read -s -n 1
            echo ""
            exit
            }

            # Main code
            echo ""
            echo -e $title_color" --------------------------- "$endCol
            echo -e $title_color" - Kernel Cleanup v1.0 - "$endCol
            echo -e $title_color" --------------------------- "$endCol
            echo ""
            echo "Maximise this window for readability."
            echo "Press any key to continue."
            read -s -n 1
            echo ""
            echo "This script will remove old unused kernels, but it will prompt you before removing each one."
            echo "It will never remove the current running kernel, and will also leave one fallback kernel."
            echo "It can also remove source files from /usr/src for each kernel removed."
            echo "This is normally safe to do and will free up lots more space."
            echo ""
            echo "Do you want that done as well? (y/n, enter=yes)"
            valid_input=0
            while [ "$valid_input" = "0" ]; do
            read -s -n 1 YesNo_input
            if [ "$YesNo_input" = "" ]; then
            YesNo_input="y"
            fi
            case $YesNo_input
            in
            y)
            RemoveSource="y"
            valid_input=1
            ;;

            Y)
            RemoveSource="y"
            valid_input=1
            ;;

            n)
            RemoveSource="n"
            valid_input=1
            ;;

            N)
            RemoveSource="N"
            valid_input=1
            ;;
            esac
            done

            free_space_before=$(df -h /boot | tail -n 1 | awk -F' ' '{ print $4 }' | tr -d M)
            show_kernel_info
            while [ $count_of_old_kernels_in_boot -gt 1 ]; do
            # failsafe check if somehow the current kernel is about to be removed!
            if [ "$current_old_kernel" = "$current_kernel" ]; then
            echo -e $bold_red"ERROR!"$endCol" Somehow the current kernel has crept into the removal process!"
            echo "I refuse to do that! Aborting script."
            exit_script
            fi
            # failsafe check if somehow a linux-image-generic entry is about to be removed
            if [ "$current_old_kernel" = "linux-image-generic" ]; then
            echo -e $bold_red"ERROR!"$endCol" Somehow one of the linux-image-generic entries has crept into the removal process!"
            echo "I refuse to do that! Aborting script."
            exit_script
            fi
            echo "Command about to be executed is:"
            echo " $ sudo apt-get purge "$current_old_kernel""
            check_in_boot=$(echo $current_old_kernel | sed 's/linux-image/initrd.img/g')
            if [ -e /boot/$check_in_boot ]; then
            echo -e $bold_yellow"Note:"$endCol" This kernel exists in /boot but it NON-active, so it's OK to remove."
            else
            echo -e $bold_green"Totally safe to remove:"$endCol" This kernel does NOT exist in /boot."
            fi
            echo ""
            echo "Are you sure you want to remove this kernel?"
            echo "(*upper case* Y=yes / any other key will exit the script)"
            read -s -n 1 yes_no
            echo ""
            # Only entering a single upper case Y will work!
            if [ "$yes_no" != "Y" ]; then
            echo "Aborting script."
            exit_script
            fi
            echo "Removing kernel "$current_old_kernel"..."
            sleep 1
            sudo apt-get -y purge $current_old_kernel
            if [ "$RemoveSource" = "y" ]; then
            current_old_source=$(echo $current_old_kernel | sed 's/linux-image/linux-headers/g')
            current_old_source=$(echo $current_old_source | sed 's/-generic//g')
            current_old_source=$(echo $current_old_source | sed 's/-pae//g')
            sudo apt-get -y purge $current_old_source
            fi
            show_kernel_info
            done

            if [ $count_of_old_kernels_in_boot = 0 ]; then
            echo -e $bold_red"There are no NON-active kernels to remove!"$endCol
            else
            echo -e $bold_red"There is only one NON-active kernel left in /boot!"$endCol
            echo "This script will not remove the last non-active kernel so that you have at least one backup kernel."
            fi
            echo "Aborting script."
            exit_script





            share|improve this answer































              0














              [As an AskUbuntu noob I can't comment until reputation = 50 so don't down-vote because of this.]



              My server was doing this, too. Literally none of the expected answers here worked since these require some working room on /boot for them to complete. If the boot partition is full, it will abruptly end without deleting any of the images.



              The only thing that worked for me was to review the current image, then to manually sudo rm filename for the oldest image files (each had -3.16.0-30 in their names). Once that was done, then sudo apt-get autoremove had the wiggle-room it needed to do its job. It did highlight some errors associated with that version, for example: "depmod: FATAL: could not load /boot/System.map-3.16.0-30-generic: No such file or directory" but that is to be expected.



              When finished, the df returned a 42% in use for /boot to indicate that it's healthy again.






              share|improve this answer





















              • The post you're looking for is askubuntu.com/questions/171209/…
                – muru
                Feb 8 '17 at 2:02










              • @muru Well, yes... I would suggest that the original poster would need this advice, too. Once /boot is full, these scripted versions which attempt to fix it also fail since, well, /boot is full.
                – Justin Case
                Feb 8 '17 at 18:36












              • Well, there are two similar problems: a) where the system warns that your disk is getting full, but apt-get has enough space to go on, and b), where apt-get fails because the disk is too full. That's the other post.
                – muru
                Feb 9 '17 at 4:56





















              0














              I wrote this bash script to selective purge old kernels all at once:



              rm kernels real size



              All the bash code and instructions are included in the link.






              share|improve this answer





























                0














                I show that still in 2017 this question has new comments and answers but missing one answer that I think is very useful here:



                Ubuntu as a desktop OS of simple everyday usage has no reason to be installed with separate boot partition and something like this will NOT offer something to a "common user"... So a solution is a fresh install without boot partition and this way you will never have such a problem



                PS: My answer can be deleted or added in the accepted answer... (I think it will help some people this way)






                share|improve this answer





























                  0














                  Save this script as /usr/local/bin/remove_kernels.sh (remember to give execute permissions sudo chmod 755 /usr/local/bin/remove_kernels.sh ):



                  #!/bin/sh
                  if test $(id -u) != 0; then
                  echo Error: You must be root to run this script!
                  exit 1
                  fi
                  apt purge $( dpkg --list | grep -P -o "linux-image-dS+" | grep -v $(uname -r | grep -P -o ".+d") )
                  update-grub


                  Then to remove all old kernels just type: sudo remove_kernels.sh






                  share|improve this answer





























                    -1














                    If you cannot remove more unused files and if you have other partition with/or free space on same device, you can resize of /boot partition by parted/gparted. (It is included on installation media, too.)



                    Warning: Resizing of partition is dangerous operation, save your important data on other media before doing it!






                    share|improve this answer





















                    • Most sufferers of small separate /boot partitions chose 'whole disk encryption' upon install, which requires LVM. This solution will seems to cause more problems than it solves for those users.
                      – user535733
                      Feb 2 '17 at 14:40










                    protected by Community May 4 '14 at 15:22



                    Thank you for your interest in this question.
                    Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



                    Would you like to answer one of these unanswered questions instead?














                    21 Answers
                    21






                    active

                    oldest

                    votes








                    21 Answers
                    21






                    active

                    oldest

                    votes









                    active

                    oldest

                    votes






                    active

                    oldest

                    votes









                    610














                    You've a lot unused kernels. Remove all but the last kernels with:



                    sudo apt-get purge linux-image-{3.0.0-12,2.6.3{1-21,2-25,8-{1[012],8}}}


                    This is shorthand for:



                    sudo apt-get purge linux-image-3.0.0-12 linux-image-2.6.31-21 linux-image-2.6.32-25 linux-image-2.6.38-10 linux-image-2.6.38-11 linux-image-2.6.38-12 linux-image-2.6.38-8


                    Removing the linux-image-x.x.x-x package will also remove linux-image-x.x.x-x-generic.



                    The headers are installed into /usr/src and are used when building out-tree kernel modules (like the proprietary nvidia driver and virtualbox). Most users should remove these header packages if the matching kernel package (linux-image-*) is not installed.



                    To list all installed kernels, run:



                    dpkg -l linux-image-* | grep ^ii


                    One command to show all kernels and headers that can be removed, excluding the current running kernel:



                    kernelver=$(uname -r | sed -r 's/-[a-z]+//')
                    dpkg -l linux-{image,headers}-"[0-9]*" | awk '/ii/{print $2}' | grep -ve $kernelver


                    It selects all packages named starting with linux-headers-<some number> or linux-image-<some number>, prints the package names for installed packages and then excludes the current loaded/running kernel (not necessarily the latest kernel!). This fits in the recommendation of testing a newer kernel before removing older, known-to-work kernels.



                    So, after upgrading kernels and rebooting to test it, you can remove all other kernels with:



                    sudo apt-get purge $(dpkg -l linux-{image,headers}-"[0-9]*" | awk '/ii/{print $2}' | grep -ve "$(uname -r | sed -r 's/-[a-z]+//')")





                    share|improve this answer



















                    • 15




                      Fantastic answer. One further piece of info would help: How can you tell (for sure) which of the kernels you're using? Presumably you can't just assume it's the last one... Edit: And it looks like the answer is uname -a. Probably best to ensure you don't have a pending restart-to-install-new-kernel pending (as I did; but I noted the mismatch between uname -a and the "latest" kernel).
                      – T.J. Crowder
                      Jun 14 '12 at 8:39








                    • 5




                      @freddyb Done. Note that the commands prints/removes kernels other than the loaded/booted one.
                      – Lekensteyn
                      Aug 13 '12 at 13:57






                    • 8




                      If apt-get purge fails because of unmet dependencies then you can follow the advice at askubuntu.com/questions/171209/…
                      – svandragt
                      Aug 7 '13 at 8:33






                    • 10




                      Very thorough answer and still works... and still needed in 2014. Kinda ridiculous that it's still not automatically done by the GUI tools.
                      – allprog
                      Apr 3 '14 at 8:30






                    • 4




                      @byf-ferdy The kernel is an essential part of the OS, if the newest version somehow does not fully work with your hardware, then you can still select a different one to boot from. A nice feature would probably be something that removes all automatically installed kernels older than a month (except for the latest two).
                      – Lekensteyn
                      Nov 1 '14 at 14:23
















                    610














                    You've a lot unused kernels. Remove all but the last kernels with:



                    sudo apt-get purge linux-image-{3.0.0-12,2.6.3{1-21,2-25,8-{1[012],8}}}


                    This is shorthand for:



                    sudo apt-get purge linux-image-3.0.0-12 linux-image-2.6.31-21 linux-image-2.6.32-25 linux-image-2.6.38-10 linux-image-2.6.38-11 linux-image-2.6.38-12 linux-image-2.6.38-8


                    Removing the linux-image-x.x.x-x package will also remove linux-image-x.x.x-x-generic.



                    The headers are installed into /usr/src and are used when building out-tree kernel modules (like the proprietary nvidia driver and virtualbox). Most users should remove these header packages if the matching kernel package (linux-image-*) is not installed.



                    To list all installed kernels, run:



                    dpkg -l linux-image-* | grep ^ii


                    One command to show all kernels and headers that can be removed, excluding the current running kernel:



                    kernelver=$(uname -r | sed -r 's/-[a-z]+//')
                    dpkg -l linux-{image,headers}-"[0-9]*" | awk '/ii/{print $2}' | grep -ve $kernelver


                    It selects all packages named starting with linux-headers-<some number> or linux-image-<some number>, prints the package names for installed packages and then excludes the current loaded/running kernel (not necessarily the latest kernel!). This fits in the recommendation of testing a newer kernel before removing older, known-to-work kernels.



                    So, after upgrading kernels and rebooting to test it, you can remove all other kernels with:



                    sudo apt-get purge $(dpkg -l linux-{image,headers}-"[0-9]*" | awk '/ii/{print $2}' | grep -ve "$(uname -r | sed -r 's/-[a-z]+//')")





                    share|improve this answer



















                    • 15




                      Fantastic answer. One further piece of info would help: How can you tell (for sure) which of the kernels you're using? Presumably you can't just assume it's the last one... Edit: And it looks like the answer is uname -a. Probably best to ensure you don't have a pending restart-to-install-new-kernel pending (as I did; but I noted the mismatch between uname -a and the "latest" kernel).
                      – T.J. Crowder
                      Jun 14 '12 at 8:39








                    • 5




                      @freddyb Done. Note that the commands prints/removes kernels other than the loaded/booted one.
                      – Lekensteyn
                      Aug 13 '12 at 13:57






                    • 8




                      If apt-get purge fails because of unmet dependencies then you can follow the advice at askubuntu.com/questions/171209/…
                      – svandragt
                      Aug 7 '13 at 8:33






                    • 10




                      Very thorough answer and still works... and still needed in 2014. Kinda ridiculous that it's still not automatically done by the GUI tools.
                      – allprog
                      Apr 3 '14 at 8:30






                    • 4




                      @byf-ferdy The kernel is an essential part of the OS, if the newest version somehow does not fully work with your hardware, then you can still select a different one to boot from. A nice feature would probably be something that removes all automatically installed kernels older than a month (except for the latest two).
                      – Lekensteyn
                      Nov 1 '14 at 14:23














                    610












                    610








                    610






                    You've a lot unused kernels. Remove all but the last kernels with:



                    sudo apt-get purge linux-image-{3.0.0-12,2.6.3{1-21,2-25,8-{1[012],8}}}


                    This is shorthand for:



                    sudo apt-get purge linux-image-3.0.0-12 linux-image-2.6.31-21 linux-image-2.6.32-25 linux-image-2.6.38-10 linux-image-2.6.38-11 linux-image-2.6.38-12 linux-image-2.6.38-8


                    Removing the linux-image-x.x.x-x package will also remove linux-image-x.x.x-x-generic.



                    The headers are installed into /usr/src and are used when building out-tree kernel modules (like the proprietary nvidia driver and virtualbox). Most users should remove these header packages if the matching kernel package (linux-image-*) is not installed.



                    To list all installed kernels, run:



                    dpkg -l linux-image-* | grep ^ii


                    One command to show all kernels and headers that can be removed, excluding the current running kernel:



                    kernelver=$(uname -r | sed -r 's/-[a-z]+//')
                    dpkg -l linux-{image,headers}-"[0-9]*" | awk '/ii/{print $2}' | grep -ve $kernelver


                    It selects all packages named starting with linux-headers-<some number> or linux-image-<some number>, prints the package names for installed packages and then excludes the current loaded/running kernel (not necessarily the latest kernel!). This fits in the recommendation of testing a newer kernel before removing older, known-to-work kernels.



                    So, after upgrading kernels and rebooting to test it, you can remove all other kernels with:



                    sudo apt-get purge $(dpkg -l linux-{image,headers}-"[0-9]*" | awk '/ii/{print $2}' | grep -ve "$(uname -r | sed -r 's/-[a-z]+//')")





                    share|improve this answer














                    You've a lot unused kernels. Remove all but the last kernels with:



                    sudo apt-get purge linux-image-{3.0.0-12,2.6.3{1-21,2-25,8-{1[012],8}}}


                    This is shorthand for:



                    sudo apt-get purge linux-image-3.0.0-12 linux-image-2.6.31-21 linux-image-2.6.32-25 linux-image-2.6.38-10 linux-image-2.6.38-11 linux-image-2.6.38-12 linux-image-2.6.38-8


                    Removing the linux-image-x.x.x-x package will also remove linux-image-x.x.x-x-generic.



                    The headers are installed into /usr/src and are used when building out-tree kernel modules (like the proprietary nvidia driver and virtualbox). Most users should remove these header packages if the matching kernel package (linux-image-*) is not installed.



                    To list all installed kernels, run:



                    dpkg -l linux-image-* | grep ^ii


                    One command to show all kernels and headers that can be removed, excluding the current running kernel:



                    kernelver=$(uname -r | sed -r 's/-[a-z]+//')
                    dpkg -l linux-{image,headers}-"[0-9]*" | awk '/ii/{print $2}' | grep -ve $kernelver


                    It selects all packages named starting with linux-headers-<some number> or linux-image-<some number>, prints the package names for installed packages and then excludes the current loaded/running kernel (not necessarily the latest kernel!). This fits in the recommendation of testing a newer kernel before removing older, known-to-work kernels.



                    So, after upgrading kernels and rebooting to test it, you can remove all other kernels with:



                    sudo apt-get purge $(dpkg -l linux-{image,headers}-"[0-9]*" | awk '/ii/{print $2}' | grep -ve "$(uname -r | sed -r 's/-[a-z]+//')")






                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Aug 13 '12 at 13:55

























                    answered Dec 24 '11 at 14:34









                    Lekensteyn

                    120k48263355




                    120k48263355








                    • 15




                      Fantastic answer. One further piece of info would help: How can you tell (for sure) which of the kernels you're using? Presumably you can't just assume it's the last one... Edit: And it looks like the answer is uname -a. Probably best to ensure you don't have a pending restart-to-install-new-kernel pending (as I did; but I noted the mismatch between uname -a and the "latest" kernel).
                      – T.J. Crowder
                      Jun 14 '12 at 8:39








                    • 5




                      @freddyb Done. Note that the commands prints/removes kernels other than the loaded/booted one.
                      – Lekensteyn
                      Aug 13 '12 at 13:57






                    • 8




                      If apt-get purge fails because of unmet dependencies then you can follow the advice at askubuntu.com/questions/171209/…
                      – svandragt
                      Aug 7 '13 at 8:33






                    • 10




                      Very thorough answer and still works... and still needed in 2014. Kinda ridiculous that it's still not automatically done by the GUI tools.
                      – allprog
                      Apr 3 '14 at 8:30






                    • 4




                      @byf-ferdy The kernel is an essential part of the OS, if the newest version somehow does not fully work with your hardware, then you can still select a different one to boot from. A nice feature would probably be something that removes all automatically installed kernels older than a month (except for the latest two).
                      – Lekensteyn
                      Nov 1 '14 at 14:23














                    • 15




                      Fantastic answer. One further piece of info would help: How can you tell (for sure) which of the kernels you're using? Presumably you can't just assume it's the last one... Edit: And it looks like the answer is uname -a. Probably best to ensure you don't have a pending restart-to-install-new-kernel pending (as I did; but I noted the mismatch between uname -a and the "latest" kernel).
                      – T.J. Crowder
                      Jun 14 '12 at 8:39








                    • 5




                      @freddyb Done. Note that the commands prints/removes kernels other than the loaded/booted one.
                      – Lekensteyn
                      Aug 13 '12 at 13:57






                    • 8




                      If apt-get purge fails because of unmet dependencies then you can follow the advice at askubuntu.com/questions/171209/…
                      – svandragt
                      Aug 7 '13 at 8:33






                    • 10




                      Very thorough answer and still works... and still needed in 2014. Kinda ridiculous that it's still not automatically done by the GUI tools.
                      – allprog
                      Apr 3 '14 at 8:30






                    • 4




                      @byf-ferdy The kernel is an essential part of the OS, if the newest version somehow does not fully work with your hardware, then you can still select a different one to boot from. A nice feature would probably be something that removes all automatically installed kernels older than a month (except for the latest two).
                      – Lekensteyn
                      Nov 1 '14 at 14:23








                    15




                    15




                    Fantastic answer. One further piece of info would help: How can you tell (for sure) which of the kernels you're using? Presumably you can't just assume it's the last one... Edit: And it looks like the answer is uname -a. Probably best to ensure you don't have a pending restart-to-install-new-kernel pending (as I did; but I noted the mismatch between uname -a and the "latest" kernel).
                    – T.J. Crowder
                    Jun 14 '12 at 8:39






                    Fantastic answer. One further piece of info would help: How can you tell (for sure) which of the kernels you're using? Presumably you can't just assume it's the last one... Edit: And it looks like the answer is uname -a. Probably best to ensure you don't have a pending restart-to-install-new-kernel pending (as I did; but I noted the mismatch between uname -a and the "latest" kernel).
                    – T.J. Crowder
                    Jun 14 '12 at 8:39






                    5




                    5




                    @freddyb Done. Note that the commands prints/removes kernels other than the loaded/booted one.
                    – Lekensteyn
                    Aug 13 '12 at 13:57




                    @freddyb Done. Note that the commands prints/removes kernels other than the loaded/booted one.
                    – Lekensteyn
                    Aug 13 '12 at 13:57




                    8




                    8




                    If apt-get purge fails because of unmet dependencies then you can follow the advice at askubuntu.com/questions/171209/…
                    – svandragt
                    Aug 7 '13 at 8:33




                    If apt-get purge fails because of unmet dependencies then you can follow the advice at askubuntu.com/questions/171209/…
                    – svandragt
                    Aug 7 '13 at 8:33




                    10




                    10




                    Very thorough answer and still works... and still needed in 2014. Kinda ridiculous that it's still not automatically done by the GUI tools.
                    – allprog
                    Apr 3 '14 at 8:30




                    Very thorough answer and still works... and still needed in 2014. Kinda ridiculous that it's still not automatically done by the GUI tools.
                    – allprog
                    Apr 3 '14 at 8:30




                    4




                    4




                    @byf-ferdy The kernel is an essential part of the OS, if the newest version somehow does not fully work with your hardware, then you can still select a different one to boot from. A nice feature would probably be something that removes all automatically installed kernels older than a month (except for the latest two).
                    – Lekensteyn
                    Nov 1 '14 at 14:23




                    @byf-ferdy The kernel is an essential part of the OS, if the newest version somehow does not fully work with your hardware, then you can still select a different one to boot from. A nice feature would probably be something that removes all automatically installed kernels older than a month (except for the latest two).
                    – Lekensteyn
                    Nov 1 '14 at 14:23













                    207














                    Your boot partition is full. Since this is a kernel update, these files will be copied to the boot partition so you need to clean in out. Here is a blog post that will show you how to clear the old kernel images with one command. I'll give a basic synopsis of the method. Use this command to print out the current version of your kernel:



                    uname -r


                    Then use this command to print out all the kernels you have installed that aren't your newest kernel:



                    dpkg -l linux-{image,headers}-"[0-9]*" | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e '[0-9]'


                    Make sure your current kernel isn't on that list. Notice how this is the majority of the final command (down below). To uninstall and delete these old kernels you will want to pipe these arguments to:



                    sudo apt-get -y purge


                    Now we can do everything we want by combining these last two commands into this unholy mess:



                    dpkg -l linux-{image,headers}-"[0-9]*" | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e '[0-9]' | xargs sudo apt-get -y purge


                    And that one command will take care of everything for you. I will confirm that this does work perfectly but never trust anybody on the internet. :) For more info, the blog post gives a very good explanation of what each part of the command does so read through it so you are satisfied that it does what you want it to do.






                    share|improve this answer



















                    • 6




                      This worked great, thanks.
                      – Michael Durrant
                      Feb 21 '13 at 3:59










                    • this also matches linux-libc-dev:amd64
                      – Frederick Nord
                      Aug 29 '14 at 16:39










                    • what will the unintended removal of "linux-libc-dev:amd64" cause?
                      – ConfusedStack
                      Oct 12 '14 at 0:37










                    • @FrederickNord thanks for the heads up. Fixed this. It would have caused some difficulties compiling c programs.
                      – dward
                      Oct 14 '14 at 19:01






                    • 7




                      The command sounds good, but when I run it I get the same error that I get when I want to install something and it can not do it because boot is full: --------------------------The following packages have unmet dependencies: linux-image-extra-4.2.0-27-generic : Depends: linux-image-4.2.0-27-generic but it is not going to be installed linux-image-extra-4.2.0-30-generic : Depends: linux-image-4.2.0-30-generic but it is not going to be installed
                      – Alex
                      Oct 1 '16 at 3:29


















                    207














                    Your boot partition is full. Since this is a kernel update, these files will be copied to the boot partition so you need to clean in out. Here is a blog post that will show you how to clear the old kernel images with one command. I'll give a basic synopsis of the method. Use this command to print out the current version of your kernel:



                    uname -r


                    Then use this command to print out all the kernels you have installed that aren't your newest kernel:



                    dpkg -l linux-{image,headers}-"[0-9]*" | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e '[0-9]'


                    Make sure your current kernel isn't on that list. Notice how this is the majority of the final command (down below). To uninstall and delete these old kernels you will want to pipe these arguments to:



                    sudo apt-get -y purge


                    Now we can do everything we want by combining these last two commands into this unholy mess:



                    dpkg -l linux-{image,headers}-"[0-9]*" | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e '[0-9]' | xargs sudo apt-get -y purge


                    And that one command will take care of everything for you. I will confirm that this does work perfectly but never trust anybody on the internet. :) For more info, the blog post gives a very good explanation of what each part of the command does so read through it so you are satisfied that it does what you want it to do.






                    share|improve this answer



















                    • 6




                      This worked great, thanks.
                      – Michael Durrant
                      Feb 21 '13 at 3:59










                    • this also matches linux-libc-dev:amd64
                      – Frederick Nord
                      Aug 29 '14 at 16:39










                    • what will the unintended removal of "linux-libc-dev:amd64" cause?
                      – ConfusedStack
                      Oct 12 '14 at 0:37










                    • @FrederickNord thanks for the heads up. Fixed this. It would have caused some difficulties compiling c programs.
                      – dward
                      Oct 14 '14 at 19:01






                    • 7




                      The command sounds good, but when I run it I get the same error that I get when I want to install something and it can not do it because boot is full: --------------------------The following packages have unmet dependencies: linux-image-extra-4.2.0-27-generic : Depends: linux-image-4.2.0-27-generic but it is not going to be installed linux-image-extra-4.2.0-30-generic : Depends: linux-image-4.2.0-30-generic but it is not going to be installed
                      – Alex
                      Oct 1 '16 at 3:29
















                    207












                    207








                    207






                    Your boot partition is full. Since this is a kernel update, these files will be copied to the boot partition so you need to clean in out. Here is a blog post that will show you how to clear the old kernel images with one command. I'll give a basic synopsis of the method. Use this command to print out the current version of your kernel:



                    uname -r


                    Then use this command to print out all the kernels you have installed that aren't your newest kernel:



                    dpkg -l linux-{image,headers}-"[0-9]*" | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e '[0-9]'


                    Make sure your current kernel isn't on that list. Notice how this is the majority of the final command (down below). To uninstall and delete these old kernels you will want to pipe these arguments to:



                    sudo apt-get -y purge


                    Now we can do everything we want by combining these last two commands into this unholy mess:



                    dpkg -l linux-{image,headers}-"[0-9]*" | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e '[0-9]' | xargs sudo apt-get -y purge


                    And that one command will take care of everything for you. I will confirm that this does work perfectly but never trust anybody on the internet. :) For more info, the blog post gives a very good explanation of what each part of the command does so read through it so you are satisfied that it does what you want it to do.






                    share|improve this answer














                    Your boot partition is full. Since this is a kernel update, these files will be copied to the boot partition so you need to clean in out. Here is a blog post that will show you how to clear the old kernel images with one command. I'll give a basic synopsis of the method. Use this command to print out the current version of your kernel:



                    uname -r


                    Then use this command to print out all the kernels you have installed that aren't your newest kernel:



                    dpkg -l linux-{image,headers}-"[0-9]*" | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e '[0-9]'


                    Make sure your current kernel isn't on that list. Notice how this is the majority of the final command (down below). To uninstall and delete these old kernels you will want to pipe these arguments to:



                    sudo apt-get -y purge


                    Now we can do everything we want by combining these last two commands into this unholy mess:



                    dpkg -l linux-{image,headers}-"[0-9]*" | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e '[0-9]' | xargs sudo apt-get -y purge


                    And that one command will take care of everything for you. I will confirm that this does work perfectly but never trust anybody on the internet. :) For more info, the blog post gives a very good explanation of what each part of the command does so read through it so you are satisfied that it does what you want it to do.







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Oct 14 '14 at 19:08

























                    answered Feb 21 '13 at 3:38









                    dward

                    2,270177




                    2,270177








                    • 6




                      This worked great, thanks.
                      – Michael Durrant
                      Feb 21 '13 at 3:59










                    • this also matches linux-libc-dev:amd64
                      – Frederick Nord
                      Aug 29 '14 at 16:39










                    • what will the unintended removal of "linux-libc-dev:amd64" cause?
                      – ConfusedStack
                      Oct 12 '14 at 0:37










                    • @FrederickNord thanks for the heads up. Fixed this. It would have caused some difficulties compiling c programs.
                      – dward
                      Oct 14 '14 at 19:01






                    • 7




                      The command sounds good, but when I run it I get the same error that I get when I want to install something and it can not do it because boot is full: --------------------------The following packages have unmet dependencies: linux-image-extra-4.2.0-27-generic : Depends: linux-image-4.2.0-27-generic but it is not going to be installed linux-image-extra-4.2.0-30-generic : Depends: linux-image-4.2.0-30-generic but it is not going to be installed
                      – Alex
                      Oct 1 '16 at 3:29
















                    • 6




                      This worked great, thanks.
                      – Michael Durrant
                      Feb 21 '13 at 3:59










                    • this also matches linux-libc-dev:amd64
                      – Frederick Nord
                      Aug 29 '14 at 16:39










                    • what will the unintended removal of "linux-libc-dev:amd64" cause?
                      – ConfusedStack
                      Oct 12 '14 at 0:37










                    • @FrederickNord thanks for the heads up. Fixed this. It would have caused some difficulties compiling c programs.
                      – dward
                      Oct 14 '14 at 19:01






                    • 7




                      The command sounds good, but when I run it I get the same error that I get when I want to install something and it can not do it because boot is full: --------------------------The following packages have unmet dependencies: linux-image-extra-4.2.0-27-generic : Depends: linux-image-4.2.0-27-generic but it is not going to be installed linux-image-extra-4.2.0-30-generic : Depends: linux-image-4.2.0-30-generic but it is not going to be installed
                      – Alex
                      Oct 1 '16 at 3:29










                    6




                    6




                    This worked great, thanks.
                    – Michael Durrant
                    Feb 21 '13 at 3:59




                    This worked great, thanks.
                    – Michael Durrant
                    Feb 21 '13 at 3:59












                    this also matches linux-libc-dev:amd64
                    – Frederick Nord
                    Aug 29 '14 at 16:39




                    this also matches linux-libc-dev:amd64
                    – Frederick Nord
                    Aug 29 '14 at 16:39












                    what will the unintended removal of "linux-libc-dev:amd64" cause?
                    – ConfusedStack
                    Oct 12 '14 at 0:37




                    what will the unintended removal of "linux-libc-dev:amd64" cause?
                    – ConfusedStack
                    Oct 12 '14 at 0:37












                    @FrederickNord thanks for the heads up. Fixed this. It would have caused some difficulties compiling c programs.
                    – dward
                    Oct 14 '14 at 19:01




                    @FrederickNord thanks for the heads up. Fixed this. It would have caused some difficulties compiling c programs.
                    – dward
                    Oct 14 '14 at 19:01




                    7




                    7




                    The command sounds good, but when I run it I get the same error that I get when I want to install something and it can not do it because boot is full: --------------------------The following packages have unmet dependencies: linux-image-extra-4.2.0-27-generic : Depends: linux-image-4.2.0-27-generic but it is not going to be installed linux-image-extra-4.2.0-30-generic : Depends: linux-image-4.2.0-30-generic but it is not going to be installed
                    – Alex
                    Oct 1 '16 at 3:29






                    The command sounds good, but when I run it I get the same error that I get when I want to install something and it can not do it because boot is full: --------------------------The following packages have unmet dependencies: linux-image-extra-4.2.0-27-generic : Depends: linux-image-4.2.0-27-generic but it is not going to be installed linux-image-extra-4.2.0-30-generic : Depends: linux-image-4.2.0-30-generic but it is not going to be installed
                    – Alex
                    Oct 1 '16 at 3:29













                    96














                    sudo apt-get autoremove


                    This command is doing the job automatically.






                    share|improve this answer



















                    • 7




                      As the name suggests, apt-get AUTOremove is an automated operation where the system takes its "best guess" what you are trying to achieve. It should not be used as a substitute for common sense system administration. The problem with this approach: If you (or an update) removes a package that is part of this dependency list the auto-remove function wants to remove all other packages in the dependency list, leaving you with a system without working desktop (and sometimes even with a completely broken system).
                      – Rinzwind
                      Nov 5 '12 at 10:09










                    • Reference: 1 of many sources for this comment above: linuxquestions.org/questions/debian-26/…
                      – Rinzwind
                      Nov 5 '12 at 10:10






                    • 7




                      if linux-image-generic is installed and new kernels were not installed explicitly, this will remove old kernels. Common sense is to not accept any changes to the system without reading them first. If common sense has been used prior to using this command then there will be no trouble.
                      – mchid
                      Mar 1 '15 at 23:34






                    • 1




                      @Rinzwind - This command emptied 250 mb of my disk space by removing old 'linux headers'
                      – Chinmaya B
                      Jul 28 '15 at 4:41






                    • 2




                      autoremove works if used before an out-of-space condition exists. However, once apt runs out of space and aborts (and the user finally notices the problem), it's too late to run autremove or any other apt-based solution. If that's the case for you, try one of the dpkg-based solutions.
                      – user535733
                      Feb 2 '17 at 14:25
















                    96














                    sudo apt-get autoremove


                    This command is doing the job automatically.






                    share|improve this answer



















                    • 7




                      As the name suggests, apt-get AUTOremove is an automated operation where the system takes its "best guess" what you are trying to achieve. It should not be used as a substitute for common sense system administration. The problem with this approach: If you (or an update) removes a package that is part of this dependency list the auto-remove function wants to remove all other packages in the dependency list, leaving you with a system without working desktop (and sometimes even with a completely broken system).
                      – Rinzwind
                      Nov 5 '12 at 10:09










                    • Reference: 1 of many sources for this comment above: linuxquestions.org/questions/debian-26/…
                      – Rinzwind
                      Nov 5 '12 at 10:10






                    • 7




                      if linux-image-generic is installed and new kernels were not installed explicitly, this will remove old kernels. Common sense is to not accept any changes to the system without reading them first. If common sense has been used prior to using this command then there will be no trouble.
                      – mchid
                      Mar 1 '15 at 23:34






                    • 1




                      @Rinzwind - This command emptied 250 mb of my disk space by removing old 'linux headers'
                      – Chinmaya B
                      Jul 28 '15 at 4:41






                    • 2




                      autoremove works if used before an out-of-space condition exists. However, once apt runs out of space and aborts (and the user finally notices the problem), it's too late to run autremove or any other apt-based solution. If that's the case for you, try one of the dpkg-based solutions.
                      – user535733
                      Feb 2 '17 at 14:25














                    96












                    96








                    96






                    sudo apt-get autoremove


                    This command is doing the job automatically.






                    share|improve this answer














                    sudo apt-get autoremove


                    This command is doing the job automatically.







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Mar 1 '15 at 23:31









                    mchid

                    22.7k25084




                    22.7k25084










                    answered Nov 5 '12 at 5:58









                    karan

                    97762




                    97762








                    • 7




                      As the name suggests, apt-get AUTOremove is an automated operation where the system takes its "best guess" what you are trying to achieve. It should not be used as a substitute for common sense system administration. The problem with this approach: If you (or an update) removes a package that is part of this dependency list the auto-remove function wants to remove all other packages in the dependency list, leaving you with a system without working desktop (and sometimes even with a completely broken system).
                      – Rinzwind
                      Nov 5 '12 at 10:09










                    • Reference: 1 of many sources for this comment above: linuxquestions.org/questions/debian-26/…
                      – Rinzwind
                      Nov 5 '12 at 10:10






                    • 7




                      if linux-image-generic is installed and new kernels were not installed explicitly, this will remove old kernels. Common sense is to not accept any changes to the system without reading them first. If common sense has been used prior to using this command then there will be no trouble.
                      – mchid
                      Mar 1 '15 at 23:34






                    • 1




                      @Rinzwind - This command emptied 250 mb of my disk space by removing old 'linux headers'
                      – Chinmaya B
                      Jul 28 '15 at 4:41






                    • 2




                      autoremove works if used before an out-of-space condition exists. However, once apt runs out of space and aborts (and the user finally notices the problem), it's too late to run autremove or any other apt-based solution. If that's the case for you, try one of the dpkg-based solutions.
                      – user535733
                      Feb 2 '17 at 14:25














                    • 7




                      As the name suggests, apt-get AUTOremove is an automated operation where the system takes its "best guess" what you are trying to achieve. It should not be used as a substitute for common sense system administration. The problem with this approach: If you (or an update) removes a package that is part of this dependency list the auto-remove function wants to remove all other packages in the dependency list, leaving you with a system without working desktop (and sometimes even with a completely broken system).
                      – Rinzwind
                      Nov 5 '12 at 10:09










                    • Reference: 1 of many sources for this comment above: linuxquestions.org/questions/debian-26/…
                      – Rinzwind
                      Nov 5 '12 at 10:10






                    • 7




                      if linux-image-generic is installed and new kernels were not installed explicitly, this will remove old kernels. Common sense is to not accept any changes to the system without reading them first. If common sense has been used prior to using this command then there will be no trouble.
                      – mchid
                      Mar 1 '15 at 23:34






                    • 1




                      @Rinzwind - This command emptied 250 mb of my disk space by removing old 'linux headers'
                      – Chinmaya B
                      Jul 28 '15 at 4:41






                    • 2




                      autoremove works if used before an out-of-space condition exists. However, once apt runs out of space and aborts (and the user finally notices the problem), it's too late to run autremove or any other apt-based solution. If that's the case for you, try one of the dpkg-based solutions.
                      – user535733
                      Feb 2 '17 at 14:25








                    7




                    7




                    As the name suggests, apt-get AUTOremove is an automated operation where the system takes its "best guess" what you are trying to achieve. It should not be used as a substitute for common sense system administration. The problem with this approach: If you (or an update) removes a package that is part of this dependency list the auto-remove function wants to remove all other packages in the dependency list, leaving you with a system without working desktop (and sometimes even with a completely broken system).
                    – Rinzwind
                    Nov 5 '12 at 10:09




                    As the name suggests, apt-get AUTOremove is an automated operation where the system takes its "best guess" what you are trying to achieve. It should not be used as a substitute for common sense system administration. The problem with this approach: If you (or an update) removes a package that is part of this dependency list the auto-remove function wants to remove all other packages in the dependency list, leaving you with a system without working desktop (and sometimes even with a completely broken system).
                    – Rinzwind
                    Nov 5 '12 at 10:09












                    Reference: 1 of many sources for this comment above: linuxquestions.org/questions/debian-26/…
                    – Rinzwind
                    Nov 5 '12 at 10:10




                    Reference: 1 of many sources for this comment above: linuxquestions.org/questions/debian-26/…
                    – Rinzwind
                    Nov 5 '12 at 10:10




                    7




                    7




                    if linux-image-generic is installed and new kernels were not installed explicitly, this will remove old kernels. Common sense is to not accept any changes to the system without reading them first. If common sense has been used prior to using this command then there will be no trouble.
                    – mchid
                    Mar 1 '15 at 23:34




                    if linux-image-generic is installed and new kernels were not installed explicitly, this will remove old kernels. Common sense is to not accept any changes to the system without reading them first. If common sense has been used prior to using this command then there will be no trouble.
                    – mchid
                    Mar 1 '15 at 23:34




                    1




                    1




                    @Rinzwind - This command emptied 250 mb of my disk space by removing old 'linux headers'
                    – Chinmaya B
                    Jul 28 '15 at 4:41




                    @Rinzwind - This command emptied 250 mb of my disk space by removing old 'linux headers'
                    – Chinmaya B
                    Jul 28 '15 at 4:41




                    2




                    2




                    autoremove works if used before an out-of-space condition exists. However, once apt runs out of space and aborts (and the user finally notices the problem), it's too late to run autremove or any other apt-based solution. If that's the case for you, try one of the dpkg-based solutions.
                    – user535733
                    Feb 2 '17 at 14:25




                    autoremove works if used before an out-of-space condition exists. However, once apt runs out of space and aborts (and the user finally notices the problem), it's too late to run autremove or any other apt-based solution. If that's the case for you, try one of the dpkg-based solutions.
                    – user535733
                    Feb 2 '17 at 14:25











                    39














                    The Synaptic Package Manager can be used to easily select and remove old kernel images.
                    Screenshot of Synaptic Package Manager



                    If you don't already have Synaptic installed:



                    sudo apt-get install synaptic


                    Start the application and select the options shown.



                    You should be able to highlight all the "linux-" packages with the version "2.6.x" where x is between 31 to 38 according to the files in your /boot folder.



                    Right-click each of those linux packages and choose the option "Mark for Complete Removal". Finally click the apply button. This will remove all the files and any associated files. Your /boot folder should now be a bit tidier.






                    share|improve this answer























                    • I'm on 14.04. I have handled this situation in the past via the command line, but I decided to try this method today... for me, my linux images were located under installed (manual), not installed (local or obsolete)
                      – Ryan
                      Jul 9 '16 at 20:32






                    • 6




                      Oh no. I can't install Synaptic because there is no space on /boot!
                      – John McGehee
                      Sep 16 '16 at 20:14










                    • @JohnMcGehee fsck and parted should solve that issue for you.
                      – FlipMcF
                      Apr 3 '17 at 20:10
















                    39














                    The Synaptic Package Manager can be used to easily select and remove old kernel images.
                    Screenshot of Synaptic Package Manager



                    If you don't already have Synaptic installed:



                    sudo apt-get install synaptic


                    Start the application and select the options shown.



                    You should be able to highlight all the "linux-" packages with the version "2.6.x" where x is between 31 to 38 according to the files in your /boot folder.



                    Right-click each of those linux packages and choose the option "Mark for Complete Removal". Finally click the apply button. This will remove all the files and any associated files. Your /boot folder should now be a bit tidier.






                    share|improve this answer























                    • I'm on 14.04. I have handled this situation in the past via the command line, but I decided to try this method today... for me, my linux images were located under installed (manual), not installed (local or obsolete)
                      – Ryan
                      Jul 9 '16 at 20:32






                    • 6




                      Oh no. I can't install Synaptic because there is no space on /boot!
                      – John McGehee
                      Sep 16 '16 at 20:14










                    • @JohnMcGehee fsck and parted should solve that issue for you.
                      – FlipMcF
                      Apr 3 '17 at 20:10














                    39












                    39








                    39






                    The Synaptic Package Manager can be used to easily select and remove old kernel images.
                    Screenshot of Synaptic Package Manager



                    If you don't already have Synaptic installed:



                    sudo apt-get install synaptic


                    Start the application and select the options shown.



                    You should be able to highlight all the "linux-" packages with the version "2.6.x" where x is between 31 to 38 according to the files in your /boot folder.



                    Right-click each of those linux packages and choose the option "Mark for Complete Removal". Finally click the apply button. This will remove all the files and any associated files. Your /boot folder should now be a bit tidier.






                    share|improve this answer














                    The Synaptic Package Manager can be used to easily select and remove old kernel images.
                    Screenshot of Synaptic Package Manager



                    If you don't already have Synaptic installed:



                    sudo apt-get install synaptic


                    Start the application and select the options shown.



                    You should be able to highlight all the "linux-" packages with the version "2.6.x" where x is between 31 to 38 according to the files in your /boot folder.



                    Right-click each of those linux packages and choose the option "Mark for Complete Removal". Finally click the apply button. This will remove all the files and any associated files. Your /boot folder should now be a bit tidier.







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Nov 17 '15 at 12:38









                    mwfearnley

                    9592919




                    9592919










                    answered Dec 24 '11 at 14:34









                    fossfreedom

                    148k37326371




                    148k37326371












                    • I'm on 14.04. I have handled this situation in the past via the command line, but I decided to try this method today... for me, my linux images were located under installed (manual), not installed (local or obsolete)
                      – Ryan
                      Jul 9 '16 at 20:32






                    • 6




                      Oh no. I can't install Synaptic because there is no space on /boot!
                      – John McGehee
                      Sep 16 '16 at 20:14










                    • @JohnMcGehee fsck and parted should solve that issue for you.
                      – FlipMcF
                      Apr 3 '17 at 20:10


















                    • I'm on 14.04. I have handled this situation in the past via the command line, but I decided to try this method today... for me, my linux images were located under installed (manual), not installed (local or obsolete)
                      – Ryan
                      Jul 9 '16 at 20:32






                    • 6




                      Oh no. I can't install Synaptic because there is no space on /boot!
                      – John McGehee
                      Sep 16 '16 at 20:14










                    • @JohnMcGehee fsck and parted should solve that issue for you.
                      – FlipMcF
                      Apr 3 '17 at 20:10
















                    I'm on 14.04. I have handled this situation in the past via the command line, but I decided to try this method today... for me, my linux images were located under installed (manual), not installed (local or obsolete)
                    – Ryan
                    Jul 9 '16 at 20:32




                    I'm on 14.04. I have handled this situation in the past via the command line, but I decided to try this method today... for me, my linux images were located under installed (manual), not installed (local or obsolete)
                    – Ryan
                    Jul 9 '16 at 20:32




                    6




                    6




                    Oh no. I can't install Synaptic because there is no space on /boot!
                    – John McGehee
                    Sep 16 '16 at 20:14




                    Oh no. I can't install Synaptic because there is no space on /boot!
                    – John McGehee
                    Sep 16 '16 at 20:14












                    @JohnMcGehee fsck and parted should solve that issue for you.
                    – FlipMcF
                    Apr 3 '17 at 20:10




                    @JohnMcGehee fsck and parted should solve that issue for you.
                    – FlipMcF
                    Apr 3 '17 at 20:10











                    24














                    Thank you for your detailed post of your problem, this got me going in the right direction. Although it is useful to keep previous kernel files you can remove all of them in one go, check this post:
                    How to Remove All Unused Linux Kernel Headers, Images and Modules



                    Done via command line. If you are doing this via remote use something like WINSCP to open a terminal session and just paste it in, works very well.



                    Here it is copied from article link, I suggest you read the full article:



                    dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/(.*)-([^0-9]+)/1/")"'/d;s/^[^ ]* [^ ]* ([^ ]*).*/1/;/[0-9]/!d' | xargs sudo apt-get -y purge





                    share|improve this answer




























                      24














                      Thank you for your detailed post of your problem, this got me going in the right direction. Although it is useful to keep previous kernel files you can remove all of them in one go, check this post:
                      How to Remove All Unused Linux Kernel Headers, Images and Modules



                      Done via command line. If you are doing this via remote use something like WINSCP to open a terminal session and just paste it in, works very well.



                      Here it is copied from article link, I suggest you read the full article:



                      dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/(.*)-([^0-9]+)/1/")"'/d;s/^[^ ]* [^ ]* ([^ ]*).*/1/;/[0-9]/!d' | xargs sudo apt-get -y purge





                      share|improve this answer


























                        24












                        24








                        24






                        Thank you for your detailed post of your problem, this got me going in the right direction. Although it is useful to keep previous kernel files you can remove all of them in one go, check this post:
                        How to Remove All Unused Linux Kernel Headers, Images and Modules



                        Done via command line. If you are doing this via remote use something like WINSCP to open a terminal session and just paste it in, works very well.



                        Here it is copied from article link, I suggest you read the full article:



                        dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/(.*)-([^0-9]+)/1/")"'/d;s/^[^ ]* [^ ]* ([^ ]*).*/1/;/[0-9]/!d' | xargs sudo apt-get -y purge





                        share|improve this answer














                        Thank you for your detailed post of your problem, this got me going in the right direction. Although it is useful to keep previous kernel files you can remove all of them in one go, check this post:
                        How to Remove All Unused Linux Kernel Headers, Images and Modules



                        Done via command line. If you are doing this via remote use something like WINSCP to open a terminal session and just paste it in, works very well.



                        Here it is copied from article link, I suggest you read the full article:



                        dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/(.*)-([^0-9]+)/1/")"'/d;s/^[^ ]* [^ ]* ([^ ]*).*/1/;/[0-9]/!d' | xargs sudo apt-get -y purge






                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited Mar 27 '13 at 15:12









                        Mateo

                        7,28584871




                        7,28584871










                        answered Jun 1 '12 at 12:53









                        Omni

                        24122




                        24122























                            22














                            This is a new answer to an old question, but an easy way to clean this thing (and more) is to install Ubuntu Tweak. To install it:



                            sudo add-apt-repository ppa:tualatrix/ppa
                            sudo apt-get update
                            sudo apt-get install ubuntu-tweak


                            then you can run Ubuntu Tweak, Going to the "janitor" tab, and from here it's a matter of three clicks:



                            Ubuntu tweak janitor for old kernels



                            It is better to leave the last kernel (you never know) or a well-known working kernel for safety, though; but that's easily customizable.



                            You can use the same tool to clean a lot of things --- just remember that if you clean thumbnail cache or TB cache then the system will have to rebuild them if they are needed.






                            share|improve this answer





















                            • I tried to install Ubuntu tweak and also going to the repository website. It says it is only for 13.10 and before. Do you have an updated version for 15.04?
                              – JayCouture.com
                              May 10 '15 at 13:57










                            • @JayCouture.com The version in the site is for 14.04 (the "for 13.10 and before" is a link to older releases). I ignore if there is a version for 14.10 or 15.04 .
                              – Rmano
                              May 11 '15 at 22:15


















                            22














                            This is a new answer to an old question, but an easy way to clean this thing (and more) is to install Ubuntu Tweak. To install it:



                            sudo add-apt-repository ppa:tualatrix/ppa
                            sudo apt-get update
                            sudo apt-get install ubuntu-tweak


                            then you can run Ubuntu Tweak, Going to the "janitor" tab, and from here it's a matter of three clicks:



                            Ubuntu tweak janitor for old kernels



                            It is better to leave the last kernel (you never know) or a well-known working kernel for safety, though; but that's easily customizable.



                            You can use the same tool to clean a lot of things --- just remember that if you clean thumbnail cache or TB cache then the system will have to rebuild them if they are needed.






                            share|improve this answer





















                            • I tried to install Ubuntu tweak and also going to the repository website. It says it is only for 13.10 and before. Do you have an updated version for 15.04?
                              – JayCouture.com
                              May 10 '15 at 13:57










                            • @JayCouture.com The version in the site is for 14.04 (the "for 13.10 and before" is a link to older releases). I ignore if there is a version for 14.10 or 15.04 .
                              – Rmano
                              May 11 '15 at 22:15
















                            22












                            22








                            22






                            This is a new answer to an old question, but an easy way to clean this thing (and more) is to install Ubuntu Tweak. To install it:



                            sudo add-apt-repository ppa:tualatrix/ppa
                            sudo apt-get update
                            sudo apt-get install ubuntu-tweak


                            then you can run Ubuntu Tweak, Going to the "janitor" tab, and from here it's a matter of three clicks:



                            Ubuntu tweak janitor for old kernels



                            It is better to leave the last kernel (you never know) or a well-known working kernel for safety, though; but that's easily customizable.



                            You can use the same tool to clean a lot of things --- just remember that if you clean thumbnail cache or TB cache then the system will have to rebuild them if they are needed.






                            share|improve this answer












                            This is a new answer to an old question, but an easy way to clean this thing (and more) is to install Ubuntu Tweak. To install it:



                            sudo add-apt-repository ppa:tualatrix/ppa
                            sudo apt-get update
                            sudo apt-get install ubuntu-tweak


                            then you can run Ubuntu Tweak, Going to the "janitor" tab, and from here it's a matter of three clicks:



                            Ubuntu tweak janitor for old kernels



                            It is better to leave the last kernel (you never know) or a well-known working kernel for safety, though; but that's easily customizable.



                            You can use the same tool to clean a lot of things --- just remember that if you clean thumbnail cache or TB cache then the system will have to rebuild them if they are needed.







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Nov 25 '14 at 13:11









                            Rmano

                            25.2k877144




                            25.2k877144












                            • I tried to install Ubuntu tweak and also going to the repository website. It says it is only for 13.10 and before. Do you have an updated version for 15.04?
                              – JayCouture.com
                              May 10 '15 at 13:57










                            • @JayCouture.com The version in the site is for 14.04 (the "for 13.10 and before" is a link to older releases). I ignore if there is a version for 14.10 or 15.04 .
                              – Rmano
                              May 11 '15 at 22:15




















                            • I tried to install Ubuntu tweak and also going to the repository website. It says it is only for 13.10 and before. Do you have an updated version for 15.04?
                              – JayCouture.com
                              May 10 '15 at 13:57










                            • @JayCouture.com The version in the site is for 14.04 (the "for 13.10 and before" is a link to older releases). I ignore if there is a version for 14.10 or 15.04 .
                              – Rmano
                              May 11 '15 at 22:15


















                            I tried to install Ubuntu tweak and also going to the repository website. It says it is only for 13.10 and before. Do you have an updated version for 15.04?
                            – JayCouture.com
                            May 10 '15 at 13:57




                            I tried to install Ubuntu tweak and also going to the repository website. It says it is only for 13.10 and before. Do you have an updated version for 15.04?
                            – JayCouture.com
                            May 10 '15 at 13:57












                            @JayCouture.com The version in the site is for 14.04 (the "for 13.10 and before" is a link to older releases). I ignore if there is a version for 14.10 or 15.04 .
                            – Rmano
                            May 11 '15 at 22:15






                            @JayCouture.com The version in the site is for 14.04 (the "for 13.10 and before" is a link to older releases). I ignore if there is a version for 14.10 or 15.04 .
                            – Rmano
                            May 11 '15 at 22:15













                            17














                            I was able to fix the problem by using dpkg to remove the packages directly. Although the packages are still listed in dpkg -l, the files are removed from /boot, freeing up space.



                            phrogz@planar:/boot$ sudo dpkg --remove linux-image-2.6.32-30-server
                            (Reading database ... 145199 files and directories currently installed.)
                            Removing linux-image-2.6.32-30-server ...
                            Running postrm hook script /usr/sbin/update-grub.
                            Generating grub.cfg ...
                            Found linux image: /boot/vmlinuz-2.6.32-35-server
                            Found linux image: /boot/vmlinuz-2.6.32-34-server
                            Found initrd image: /boot/initrd.img-2.6.32-34-server
                            Found linux image: /boot/vmlinuz-2.6.32-33-server
                            Found initrd image: /boot/initrd.img-2.6.32-33-server
                            Found linux image: /boot/vmlinuz-2.6.32-32-server
                            Found initrd image: /boot/initrd.img-2.6.32-32-server
                            Found linux image: /boot/vmlinuz-2.6.32-31-server
                            Found initrd image: /boot/initrd.img-2.6.32-31-server
                            Found memtest86+ image: /memtest86+.bin
                            done

                            # Repeat for kernels -31 and -32 and -33, up to (but not including)
                            # the version listed by `uname -a`


                            After this, apt-get -f install fixed my dependency problems, and all was well with the world.



                            I'll not be accepting this answer of mine, however, as I still need to know if I should be increasing my /boot size or doing something else.






                            share|improve this answer





















                            • You should either not have a separate /boot partition in the first place, or you should increase its size as 100mb is too small.
                              – psusi
                              Dec 4 '11 at 4:07






                            • 1




                              Thanks, I delete via: sudo dpkg --remove linux-headers-3.5.0-28*
                              – TiloBunt
                              Jul 16 '13 at 17:34








                            • 2




                              and sudo dpkg --remove linux-image-3.5.0-28* for the image, checked via df -h
                              – TiloBunt
                              Jul 16 '13 at 17:57
















                            17














                            I was able to fix the problem by using dpkg to remove the packages directly. Although the packages are still listed in dpkg -l, the files are removed from /boot, freeing up space.



                            phrogz@planar:/boot$ sudo dpkg --remove linux-image-2.6.32-30-server
                            (Reading database ... 145199 files and directories currently installed.)
                            Removing linux-image-2.6.32-30-server ...
                            Running postrm hook script /usr/sbin/update-grub.
                            Generating grub.cfg ...
                            Found linux image: /boot/vmlinuz-2.6.32-35-server
                            Found linux image: /boot/vmlinuz-2.6.32-34-server
                            Found initrd image: /boot/initrd.img-2.6.32-34-server
                            Found linux image: /boot/vmlinuz-2.6.32-33-server
                            Found initrd image: /boot/initrd.img-2.6.32-33-server
                            Found linux image: /boot/vmlinuz-2.6.32-32-server
                            Found initrd image: /boot/initrd.img-2.6.32-32-server
                            Found linux image: /boot/vmlinuz-2.6.32-31-server
                            Found initrd image: /boot/initrd.img-2.6.32-31-server
                            Found memtest86+ image: /memtest86+.bin
                            done

                            # Repeat for kernels -31 and -32 and -33, up to (but not including)
                            # the version listed by `uname -a`


                            After this, apt-get -f install fixed my dependency problems, and all was well with the world.



                            I'll not be accepting this answer of mine, however, as I still need to know if I should be increasing my /boot size or doing something else.






                            share|improve this answer





















                            • You should either not have a separate /boot partition in the first place, or you should increase its size as 100mb is too small.
                              – psusi
                              Dec 4 '11 at 4:07






                            • 1




                              Thanks, I delete via: sudo dpkg --remove linux-headers-3.5.0-28*
                              – TiloBunt
                              Jul 16 '13 at 17:34








                            • 2




                              and sudo dpkg --remove linux-image-3.5.0-28* for the image, checked via df -h
                              – TiloBunt
                              Jul 16 '13 at 17:57














                            17












                            17








                            17






                            I was able to fix the problem by using dpkg to remove the packages directly. Although the packages are still listed in dpkg -l, the files are removed from /boot, freeing up space.



                            phrogz@planar:/boot$ sudo dpkg --remove linux-image-2.6.32-30-server
                            (Reading database ... 145199 files and directories currently installed.)
                            Removing linux-image-2.6.32-30-server ...
                            Running postrm hook script /usr/sbin/update-grub.
                            Generating grub.cfg ...
                            Found linux image: /boot/vmlinuz-2.6.32-35-server
                            Found linux image: /boot/vmlinuz-2.6.32-34-server
                            Found initrd image: /boot/initrd.img-2.6.32-34-server
                            Found linux image: /boot/vmlinuz-2.6.32-33-server
                            Found initrd image: /boot/initrd.img-2.6.32-33-server
                            Found linux image: /boot/vmlinuz-2.6.32-32-server
                            Found initrd image: /boot/initrd.img-2.6.32-32-server
                            Found linux image: /boot/vmlinuz-2.6.32-31-server
                            Found initrd image: /boot/initrd.img-2.6.32-31-server
                            Found memtest86+ image: /memtest86+.bin
                            done

                            # Repeat for kernels -31 and -32 and -33, up to (but not including)
                            # the version listed by `uname -a`


                            After this, apt-get -f install fixed my dependency problems, and all was well with the world.



                            I'll not be accepting this answer of mine, however, as I still need to know if I should be increasing my /boot size or doing something else.






                            share|improve this answer












                            I was able to fix the problem by using dpkg to remove the packages directly. Although the packages are still listed in dpkg -l, the files are removed from /boot, freeing up space.



                            phrogz@planar:/boot$ sudo dpkg --remove linux-image-2.6.32-30-server
                            (Reading database ... 145199 files and directories currently installed.)
                            Removing linux-image-2.6.32-30-server ...
                            Running postrm hook script /usr/sbin/update-grub.
                            Generating grub.cfg ...
                            Found linux image: /boot/vmlinuz-2.6.32-35-server
                            Found linux image: /boot/vmlinuz-2.6.32-34-server
                            Found initrd image: /boot/initrd.img-2.6.32-34-server
                            Found linux image: /boot/vmlinuz-2.6.32-33-server
                            Found initrd image: /boot/initrd.img-2.6.32-33-server
                            Found linux image: /boot/vmlinuz-2.6.32-32-server
                            Found initrd image: /boot/initrd.img-2.6.32-32-server
                            Found linux image: /boot/vmlinuz-2.6.32-31-server
                            Found initrd image: /boot/initrd.img-2.6.32-31-server
                            Found memtest86+ image: /memtest86+.bin
                            done

                            # Repeat for kernels -31 and -32 and -33, up to (but not including)
                            # the version listed by `uname -a`


                            After this, apt-get -f install fixed my dependency problems, and all was well with the world.



                            I'll not be accepting this answer of mine, however, as I still need to know if I should be increasing my /boot size or doing something else.







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Dec 3 '11 at 18:47









                            Phrogz

                            74141125




                            74141125












                            • You should either not have a separate /boot partition in the first place, or you should increase its size as 100mb is too small.
                              – psusi
                              Dec 4 '11 at 4:07






                            • 1




                              Thanks, I delete via: sudo dpkg --remove linux-headers-3.5.0-28*
                              – TiloBunt
                              Jul 16 '13 at 17:34








                            • 2




                              and sudo dpkg --remove linux-image-3.5.0-28* for the image, checked via df -h
                              – TiloBunt
                              Jul 16 '13 at 17:57


















                            • You should either not have a separate /boot partition in the first place, or you should increase its size as 100mb is too small.
                              – psusi
                              Dec 4 '11 at 4:07






                            • 1




                              Thanks, I delete via: sudo dpkg --remove linux-headers-3.5.0-28*
                              – TiloBunt
                              Jul 16 '13 at 17:34








                            • 2




                              and sudo dpkg --remove linux-image-3.5.0-28* for the image, checked via df -h
                              – TiloBunt
                              Jul 16 '13 at 17:57
















                            You should either not have a separate /boot partition in the first place, or you should increase its size as 100mb is too small.
                            – psusi
                            Dec 4 '11 at 4:07




                            You should either not have a separate /boot partition in the first place, or you should increase its size as 100mb is too small.
                            – psusi
                            Dec 4 '11 at 4:07




                            1




                            1




                            Thanks, I delete via: sudo dpkg --remove linux-headers-3.5.0-28*
                            – TiloBunt
                            Jul 16 '13 at 17:34






                            Thanks, I delete via: sudo dpkg --remove linux-headers-3.5.0-28*
                            – TiloBunt
                            Jul 16 '13 at 17:34






                            2




                            2




                            and sudo dpkg --remove linux-image-3.5.0-28* for the image, checked via df -h
                            – TiloBunt
                            Jul 16 '13 at 17:57




                            and sudo dpkg --remove linux-image-3.5.0-28* for the image, checked via df -h
                            – TiloBunt
                            Jul 16 '13 at 17:57











                            13














                            You can stop using a separate /boot partition, then you won't have such limited space there. To do this, unmount the partition, then mount it somewhere else and copy all of the files there to the /boot directory in your root partition, then remove the entry from /etc/fstab and reinstall grub. For example ( you will need to use the correct partition ):



                            sudo -s
                            umount /boot
                            mount /dev/sda2 /mnt
                            cp -a /mnt/* /boot/
                            umount /mnt
                            gedit /etc/fstab
                            grub-install /dev/sda


                            You can then use gparted to delete the old /boot partition, and possibly extend the root partition to use that space. To extend the root partition you will need to boot from the livecd, and the free space needs to be immediately to the right. If the /boot partition is currently to the left of the root partition, then you will need to first move the root partition to the left, then extend it, but this can take a very, very long time, so may not be worth the trouble.






                            share|improve this answer

















                            • 6




                              Moving /boot to my main partition isn't a solution for me since everything but /boot is encrypted. You couldn't know that from my question, sorry.
                              – user6722
                              Dec 24 '11 at 14:15










                            • This is a good solution if the solutions above don't work due to having no space at all on the boot volume, or if you repeatedly have the "out of space" issue. Please read first why it's sometimes required to have a /boot partition though: (help.ubuntu.com/community/DiskSpace)
                              – svandragt
                              Jul 10 '14 at 8:26












                            • @svandragt, there basically is no reason left to need a /boot partition these days. About the only one left is if your bios is broken and can't see the whole disk, and any machine made in the last decade doesn't have such a limitation. Other legacy cases such as using raid or LVM are now handled properly by grub2.
                              – psusi
                              Jul 11 '14 at 1:59










                            • There's a few reasons for having a separate boot partition. But I'm not sure the benefits are worth the increased complexity setup. 1. OS can benefit from faster boot via ext2. 2. Security can be increased by mounting /boot as RO. (rootkits, etc.), or even remain unmounted at os runtime. 3. grub (1) has (had) some issues with ext4 still. 4. Required for running lvm (grubv1). Though this does not apply to the default ubuntu setup.
                              – David Cahill
                              Apr 13 '15 at 17:37












                            • lsblk can be used to determine which partition is what
                              – Mr Purple
                              May 9 '16 at 9:51


















                            13














                            You can stop using a separate /boot partition, then you won't have such limited space there. To do this, unmount the partition, then mount it somewhere else and copy all of the files there to the /boot directory in your root partition, then remove the entry from /etc/fstab and reinstall grub. For example ( you will need to use the correct partition ):



                            sudo -s
                            umount /boot
                            mount /dev/sda2 /mnt
                            cp -a /mnt/* /boot/
                            umount /mnt
                            gedit /etc/fstab
                            grub-install /dev/sda


                            You can then use gparted to delete the old /boot partition, and possibly extend the root partition to use that space. To extend the root partition you will need to boot from the livecd, and the free space needs to be immediately to the right. If the /boot partition is currently to the left of the root partition, then you will need to first move the root partition to the left, then extend it, but this can take a very, very long time, so may not be worth the trouble.






                            share|improve this answer

















                            • 6




                              Moving /boot to my main partition isn't a solution for me since everything but /boot is encrypted. You couldn't know that from my question, sorry.
                              – user6722
                              Dec 24 '11 at 14:15










                            • This is a good solution if the solutions above don't work due to having no space at all on the boot volume, or if you repeatedly have the "out of space" issue. Please read first why it's sometimes required to have a /boot partition though: (help.ubuntu.com/community/DiskSpace)
                              – svandragt
                              Jul 10 '14 at 8:26












                            • @svandragt, there basically is no reason left to need a /boot partition these days. About the only one left is if your bios is broken and can't see the whole disk, and any machine made in the last decade doesn't have such a limitation. Other legacy cases such as using raid or LVM are now handled properly by grub2.
                              – psusi
                              Jul 11 '14 at 1:59










                            • There's a few reasons for having a separate boot partition. But I'm not sure the benefits are worth the increased complexity setup. 1. OS can benefit from faster boot via ext2. 2. Security can be increased by mounting /boot as RO. (rootkits, etc.), or even remain unmounted at os runtime. 3. grub (1) has (had) some issues with ext4 still. 4. Required for running lvm (grubv1). Though this does not apply to the default ubuntu setup.
                              – David Cahill
                              Apr 13 '15 at 17:37












                            • lsblk can be used to determine which partition is what
                              – Mr Purple
                              May 9 '16 at 9:51
















                            13












                            13








                            13






                            You can stop using a separate /boot partition, then you won't have such limited space there. To do this, unmount the partition, then mount it somewhere else and copy all of the files there to the /boot directory in your root partition, then remove the entry from /etc/fstab and reinstall grub. For example ( you will need to use the correct partition ):



                            sudo -s
                            umount /boot
                            mount /dev/sda2 /mnt
                            cp -a /mnt/* /boot/
                            umount /mnt
                            gedit /etc/fstab
                            grub-install /dev/sda


                            You can then use gparted to delete the old /boot partition, and possibly extend the root partition to use that space. To extend the root partition you will need to boot from the livecd, and the free space needs to be immediately to the right. If the /boot partition is currently to the left of the root partition, then you will need to first move the root partition to the left, then extend it, but this can take a very, very long time, so may not be worth the trouble.






                            share|improve this answer












                            You can stop using a separate /boot partition, then you won't have such limited space there. To do this, unmount the partition, then mount it somewhere else and copy all of the files there to the /boot directory in your root partition, then remove the entry from /etc/fstab and reinstall grub. For example ( you will need to use the correct partition ):



                            sudo -s
                            umount /boot
                            mount /dev/sda2 /mnt
                            cp -a /mnt/* /boot/
                            umount /mnt
                            gedit /etc/fstab
                            grub-install /dev/sda


                            You can then use gparted to delete the old /boot partition, and possibly extend the root partition to use that space. To extend the root partition you will need to boot from the livecd, and the free space needs to be immediately to the right. If the /boot partition is currently to the left of the root partition, then you will need to first move the root partition to the left, then extend it, but this can take a very, very long time, so may not be worth the trouble.







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Dec 22 '11 at 16:38









                            psusi

                            31k14987




                            31k14987








                            • 6




                              Moving /boot to my main partition isn't a solution for me since everything but /boot is encrypted. You couldn't know that from my question, sorry.
                              – user6722
                              Dec 24 '11 at 14:15










                            • This is a good solution if the solutions above don't work due to having no space at all on the boot volume, or if you repeatedly have the "out of space" issue. Please read first why it's sometimes required to have a /boot partition though: (help.ubuntu.com/community/DiskSpace)
                              – svandragt
                              Jul 10 '14 at 8:26












                            • @svandragt, there basically is no reason left to need a /boot partition these days. About the only one left is if your bios is broken and can't see the whole disk, and any machine made in the last decade doesn't have such a limitation. Other legacy cases such as using raid or LVM are now handled properly by grub2.
                              – psusi
                              Jul 11 '14 at 1:59










                            • There's a few reasons for having a separate boot partition. But I'm not sure the benefits are worth the increased complexity setup. 1. OS can benefit from faster boot via ext2. 2. Security can be increased by mounting /boot as RO. (rootkits, etc.), or even remain unmounted at os runtime. 3. grub (1) has (had) some issues with ext4 still. 4. Required for running lvm (grubv1). Though this does not apply to the default ubuntu setup.
                              – David Cahill
                              Apr 13 '15 at 17:37












                            • lsblk can be used to determine which partition is what
                              – Mr Purple
                              May 9 '16 at 9:51
















                            • 6




                              Moving /boot to my main partition isn't a solution for me since everything but /boot is encrypted. You couldn't know that from my question, sorry.
                              – user6722
                              Dec 24 '11 at 14:15










                            • This is a good solution if the solutions above don't work due to having no space at all on the boot volume, or if you repeatedly have the "out of space" issue. Please read first why it's sometimes required to have a /boot partition though: (help.ubuntu.com/community/DiskSpace)
                              – svandragt
                              Jul 10 '14 at 8:26












                            • @svandragt, there basically is no reason left to need a /boot partition these days. About the only one left is if your bios is broken and can't see the whole disk, and any machine made in the last decade doesn't have such a limitation. Other legacy cases such as using raid or LVM are now handled properly by grub2.
                              – psusi
                              Jul 11 '14 at 1:59










                            • There's a few reasons for having a separate boot partition. But I'm not sure the benefits are worth the increased complexity setup. 1. OS can benefit from faster boot via ext2. 2. Security can be increased by mounting /boot as RO. (rootkits, etc.), or even remain unmounted at os runtime. 3. grub (1) has (had) some issues with ext4 still. 4. Required for running lvm (grubv1). Though this does not apply to the default ubuntu setup.
                              – David Cahill
                              Apr 13 '15 at 17:37












                            • lsblk can be used to determine which partition is what
                              – Mr Purple
                              May 9 '16 at 9:51










                            6




                            6




                            Moving /boot to my main partition isn't a solution for me since everything but /boot is encrypted. You couldn't know that from my question, sorry.
                            – user6722
                            Dec 24 '11 at 14:15




                            Moving /boot to my main partition isn't a solution for me since everything but /boot is encrypted. You couldn't know that from my question, sorry.
                            – user6722
                            Dec 24 '11 at 14:15












                            This is a good solution if the solutions above don't work due to having no space at all on the boot volume, or if you repeatedly have the "out of space" issue. Please read first why it's sometimes required to have a /boot partition though: (help.ubuntu.com/community/DiskSpace)
                            – svandragt
                            Jul 10 '14 at 8:26






                            This is a good solution if the solutions above don't work due to having no space at all on the boot volume, or if you repeatedly have the "out of space" issue. Please read first why it's sometimes required to have a /boot partition though: (help.ubuntu.com/community/DiskSpace)
                            – svandragt
                            Jul 10 '14 at 8:26














                            @svandragt, there basically is no reason left to need a /boot partition these days. About the only one left is if your bios is broken and can't see the whole disk, and any machine made in the last decade doesn't have such a limitation. Other legacy cases such as using raid or LVM are now handled properly by grub2.
                            – psusi
                            Jul 11 '14 at 1:59




                            @svandragt, there basically is no reason left to need a /boot partition these days. About the only one left is if your bios is broken and can't see the whole disk, and any machine made in the last decade doesn't have such a limitation. Other legacy cases such as using raid or LVM are now handled properly by grub2.
                            – psusi
                            Jul 11 '14 at 1:59












                            There's a few reasons for having a separate boot partition. But I'm not sure the benefits are worth the increased complexity setup. 1. OS can benefit from faster boot via ext2. 2. Security can be increased by mounting /boot as RO. (rootkits, etc.), or even remain unmounted at os runtime. 3. grub (1) has (had) some issues with ext4 still. 4. Required for running lvm (grubv1). Though this does not apply to the default ubuntu setup.
                            – David Cahill
                            Apr 13 '15 at 17:37






                            There's a few reasons for having a separate boot partition. But I'm not sure the benefits are worth the increased complexity setup. 1. OS can benefit from faster boot via ext2. 2. Security can be increased by mounting /boot as RO. (rootkits, etc.), or even remain unmounted at os runtime. 3. grub (1) has (had) some issues with ext4 still. 4. Required for running lvm (grubv1). Though this does not apply to the default ubuntu setup.
                            – David Cahill
                            Apr 13 '15 at 17:37














                            lsblk can be used to determine which partition is what
                            – Mr Purple
                            May 9 '16 at 9:51






                            lsblk can be used to determine which partition is what
                            – Mr Purple
                            May 9 '16 at 9:51













                            5














                            Taking the best from the answers above, my tried-and-true approach is this:





                            • uname -a to find the running kernel.


                            • dpkg -l linux-{headers,image}-* | grep ^ii to list all currently installed kernel-related packages. This will include the running kernel.


                            • sudo apt-get purge linux-{image,headers}-3.16.0-{xx,yy,zz} to remove the old kernels. Replace xx,yy,zz with a list of the kernel builds you want to remove—these are all the builds listed by the previous command which are older than the currently running kernel. Make sure you don't remove the currently running kernel—your system will become unbootable. You may also need to change the kernel version from 3.16.0 to whatever is installed on your system.

                            • Optionally, do an additional sudo apt-get autoremove—this will remove any leftover dependencies of the old kernels which are no longer needed by the current one, freeing up some more space.


                            You may have header files without matching kernel versions installed, or vice versa—just include all of these versions in the command. APT will complain that some packages can't be removed because they are not installed, but that will do no harm.



                            If something fails...




                            • If the apt command fails due to a no space left on device error, use the corresponding dpkg command instead: sudo dpkg --purge linux-{image,headers}-3.16.0-{xx,yy,zz}.

                            • If the dpkg command still doesn’t work because the linux-image packages are required by the linux-headers packages of the same version (which you also want to uninstall), dpkg may have failed to resolve that. Re-examine the output of dpkg -l and specify any package name suffixes on the command line. For example, on one of my systems the command that eventually worked was sudo dpkg --purge linux-{image,headers}-3.16.0-{xx,yy,zz}-generic-pae.

                            • If you get any other error, seek help—you may have a different problem than you thought.






                            share|improve this answer























                            • @user535733 the usual case (at least the one I keep running into) is that there’s still some space on /boot, just not enough for another kernel package. In those cases the above has worked well. Feel free, though, to add the corresponding dpkg command. As for purge, no, it’s not a kind of ‘force-remove’. What it does, differently from remove, is that it deletes configuration files as well. Since/as long as kernel packages install no config files, remove and purge will do the same for kernel packages.
                              – user149408
                              Feb 3 '17 at 23:55










                            • Added fourth bullet with the corresponding dpkg command.
                              – user535733
                              Feb 4 '17 at 0:02
















                            5














                            Taking the best from the answers above, my tried-and-true approach is this:





                            • uname -a to find the running kernel.


                            • dpkg -l linux-{headers,image}-* | grep ^ii to list all currently installed kernel-related packages. This will include the running kernel.


                            • sudo apt-get purge linux-{image,headers}-3.16.0-{xx,yy,zz} to remove the old kernels. Replace xx,yy,zz with a list of the kernel builds you want to remove—these are all the builds listed by the previous command which are older than the currently running kernel. Make sure you don't remove the currently running kernel—your system will become unbootable. You may also need to change the kernel version from 3.16.0 to whatever is installed on your system.

                            • Optionally, do an additional sudo apt-get autoremove—this will remove any leftover dependencies of the old kernels which are no longer needed by the current one, freeing up some more space.


                            You may have header files without matching kernel versions installed, or vice versa—just include all of these versions in the command. APT will complain that some packages can't be removed because they are not installed, but that will do no harm.



                            If something fails...




                            • If the apt command fails due to a no space left on device error, use the corresponding dpkg command instead: sudo dpkg --purge linux-{image,headers}-3.16.0-{xx,yy,zz}.

                            • If the dpkg command still doesn’t work because the linux-image packages are required by the linux-headers packages of the same version (which you also want to uninstall), dpkg may have failed to resolve that. Re-examine the output of dpkg -l and specify any package name suffixes on the command line. For example, on one of my systems the command that eventually worked was sudo dpkg --purge linux-{image,headers}-3.16.0-{xx,yy,zz}-generic-pae.

                            • If you get any other error, seek help—you may have a different problem than you thought.






                            share|improve this answer























                            • @user535733 the usual case (at least the one I keep running into) is that there’s still some space on /boot, just not enough for another kernel package. In those cases the above has worked well. Feel free, though, to add the corresponding dpkg command. As for purge, no, it’s not a kind of ‘force-remove’. What it does, differently from remove, is that it deletes configuration files as well. Since/as long as kernel packages install no config files, remove and purge will do the same for kernel packages.
                              – user149408
                              Feb 3 '17 at 23:55










                            • Added fourth bullet with the corresponding dpkg command.
                              – user535733
                              Feb 4 '17 at 0:02














                            5












                            5








                            5






                            Taking the best from the answers above, my tried-and-true approach is this:





                            • uname -a to find the running kernel.


                            • dpkg -l linux-{headers,image}-* | grep ^ii to list all currently installed kernel-related packages. This will include the running kernel.


                            • sudo apt-get purge linux-{image,headers}-3.16.0-{xx,yy,zz} to remove the old kernels. Replace xx,yy,zz with a list of the kernel builds you want to remove—these are all the builds listed by the previous command which are older than the currently running kernel. Make sure you don't remove the currently running kernel—your system will become unbootable. You may also need to change the kernel version from 3.16.0 to whatever is installed on your system.

                            • Optionally, do an additional sudo apt-get autoremove—this will remove any leftover dependencies of the old kernels which are no longer needed by the current one, freeing up some more space.


                            You may have header files without matching kernel versions installed, or vice versa—just include all of these versions in the command. APT will complain that some packages can't be removed because they are not installed, but that will do no harm.



                            If something fails...




                            • If the apt command fails due to a no space left on device error, use the corresponding dpkg command instead: sudo dpkg --purge linux-{image,headers}-3.16.0-{xx,yy,zz}.

                            • If the dpkg command still doesn’t work because the linux-image packages are required by the linux-headers packages of the same version (which you also want to uninstall), dpkg may have failed to resolve that. Re-examine the output of dpkg -l and specify any package name suffixes on the command line. For example, on one of my systems the command that eventually worked was sudo dpkg --purge linux-{image,headers}-3.16.0-{xx,yy,zz}-generic-pae.

                            • If you get any other error, seek help—you may have a different problem than you thought.






                            share|improve this answer














                            Taking the best from the answers above, my tried-and-true approach is this:





                            • uname -a to find the running kernel.


                            • dpkg -l linux-{headers,image}-* | grep ^ii to list all currently installed kernel-related packages. This will include the running kernel.


                            • sudo apt-get purge linux-{image,headers}-3.16.0-{xx,yy,zz} to remove the old kernels. Replace xx,yy,zz with a list of the kernel builds you want to remove—these are all the builds listed by the previous command which are older than the currently running kernel. Make sure you don't remove the currently running kernel—your system will become unbootable. You may also need to change the kernel version from 3.16.0 to whatever is installed on your system.

                            • Optionally, do an additional sudo apt-get autoremove—this will remove any leftover dependencies of the old kernels which are no longer needed by the current one, freeing up some more space.


                            You may have header files without matching kernel versions installed, or vice versa—just include all of these versions in the command. APT will complain that some packages can't be removed because they are not installed, but that will do no harm.



                            If something fails...




                            • If the apt command fails due to a no space left on device error, use the corresponding dpkg command instead: sudo dpkg --purge linux-{image,headers}-3.16.0-{xx,yy,zz}.

                            • If the dpkg command still doesn’t work because the linux-image packages are required by the linux-headers packages of the same version (which you also want to uninstall), dpkg may have failed to resolve that. Re-examine the output of dpkg -l and specify any package name suffixes on the command line. For example, on one of my systems the command that eventually worked was sudo dpkg --purge linux-{image,headers}-3.16.0-{xx,yy,zz}-generic-pae.

                            • If you get any other error, seek help—you may have a different problem than you thought.







                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Mar 12 '18 at 14:43

























                            answered Jul 9 '15 at 20:24









                            user149408

                            561715




                            561715












                            • @user535733 the usual case (at least the one I keep running into) is that there’s still some space on /boot, just not enough for another kernel package. In those cases the above has worked well. Feel free, though, to add the corresponding dpkg command. As for purge, no, it’s not a kind of ‘force-remove’. What it does, differently from remove, is that it deletes configuration files as well. Since/as long as kernel packages install no config files, remove and purge will do the same for kernel packages.
                              – user149408
                              Feb 3 '17 at 23:55










                            • Added fourth bullet with the corresponding dpkg command.
                              – user535733
                              Feb 4 '17 at 0:02


















                            • @user535733 the usual case (at least the one I keep running into) is that there’s still some space on /boot, just not enough for another kernel package. In those cases the above has worked well. Feel free, though, to add the corresponding dpkg command. As for purge, no, it’s not a kind of ‘force-remove’. What it does, differently from remove, is that it deletes configuration files as well. Since/as long as kernel packages install no config files, remove and purge will do the same for kernel packages.
                              – user149408
                              Feb 3 '17 at 23:55










                            • Added fourth bullet with the corresponding dpkg command.
                              – user535733
                              Feb 4 '17 at 0:02
















                            @user535733 the usual case (at least the one I keep running into) is that there’s still some space on /boot, just not enough for another kernel package. In those cases the above has worked well. Feel free, though, to add the corresponding dpkg command. As for purge, no, it’s not a kind of ‘force-remove’. What it does, differently from remove, is that it deletes configuration files as well. Since/as long as kernel packages install no config files, remove and purge will do the same for kernel packages.
                            – user149408
                            Feb 3 '17 at 23:55




                            @user535733 the usual case (at least the one I keep running into) is that there’s still some space on /boot, just not enough for another kernel package. In those cases the above has worked well. Feel free, though, to add the corresponding dpkg command. As for purge, no, it’s not a kind of ‘force-remove’. What it does, differently from remove, is that it deletes configuration files as well. Since/as long as kernel packages install no config files, remove and purge will do the same for kernel packages.
                            – user149408
                            Feb 3 '17 at 23:55












                            Added fourth bullet with the corresponding dpkg command.
                            – user535733
                            Feb 4 '17 at 0:02




                            Added fourth bullet with the corresponding dpkg command.
                            – user535733
                            Feb 4 '17 at 0:02











                            4














                            For me both apt-get purge and dpkg --remove both failed. So I had to deleted a couple of older kernel images from /boot with rm -f.






                            share|improve this answer

















                            • 4




                              This is not a good way to remove packages. While this answer isn't very specific about why removing them the correct way failed, I'm sure if that information was given (in a separate question of course) we'd be able to try and figure out the cause of the problem.
                              – thomasrutter
                              Aug 29 '14 at 9:55






                            • 2




                              I believe it was failed, because /boot partition was full. This commands try first to upgrade kernel to recent and crash with No space left on device while generating initrd.img
                              – vp_arth
                              Dec 3 '15 at 15:50






                            • 1




                              WARNING, directly removing files can lead to problems, as an update of the linux-firmware package can recreate the initrd.img file for every version it thinks is installed based on package information. See: askubuntu.com/questions/865577/…
                              – kgrittn
                              Jan 5 '17 at 13:57










                            • thanks, this is the life-saving final solution when nothing else works.
                              – Jeff Puckett
                              Aug 17 '17 at 3:28
















                            4














                            For me both apt-get purge and dpkg --remove both failed. So I had to deleted a couple of older kernel images from /boot with rm -f.






                            share|improve this answer

















                            • 4




                              This is not a good way to remove packages. While this answer isn't very specific about why removing them the correct way failed, I'm sure if that information was given (in a separate question of course) we'd be able to try and figure out the cause of the problem.
                              – thomasrutter
                              Aug 29 '14 at 9:55






                            • 2




                              I believe it was failed, because /boot partition was full. This commands try first to upgrade kernel to recent and crash with No space left on device while generating initrd.img
                              – vp_arth
                              Dec 3 '15 at 15:50






                            • 1




                              WARNING, directly removing files can lead to problems, as an update of the linux-firmware package can recreate the initrd.img file for every version it thinks is installed based on package information. See: askubuntu.com/questions/865577/…
                              – kgrittn
                              Jan 5 '17 at 13:57










                            • thanks, this is the life-saving final solution when nothing else works.
                              – Jeff Puckett
                              Aug 17 '17 at 3:28














                            4












                            4








                            4






                            For me both apt-get purge and dpkg --remove both failed. So I had to deleted a couple of older kernel images from /boot with rm -f.






                            share|improve this answer












                            For me both apt-get purge and dpkg --remove both failed. So I had to deleted a couple of older kernel images from /boot with rm -f.







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Oct 14 '13 at 9:22









                            orkoden

                            16914




                            16914








                            • 4




                              This is not a good way to remove packages. While this answer isn't very specific about why removing them the correct way failed, I'm sure if that information was given (in a separate question of course) we'd be able to try and figure out the cause of the problem.
                              – thomasrutter
                              Aug 29 '14 at 9:55






                            • 2




                              I believe it was failed, because /boot partition was full. This commands try first to upgrade kernel to recent and crash with No space left on device while generating initrd.img
                              – vp_arth
                              Dec 3 '15 at 15:50






                            • 1




                              WARNING, directly removing files can lead to problems, as an update of the linux-firmware package can recreate the initrd.img file for every version it thinks is installed based on package information. See: askubuntu.com/questions/865577/…
                              – kgrittn
                              Jan 5 '17 at 13:57










                            • thanks, this is the life-saving final solution when nothing else works.
                              – Jeff Puckett
                              Aug 17 '17 at 3:28














                            • 4




                              This is not a good way to remove packages. While this answer isn't very specific about why removing them the correct way failed, I'm sure if that information was given (in a separate question of course) we'd be able to try and figure out the cause of the problem.
                              – thomasrutter
                              Aug 29 '14 at 9:55






                            • 2




                              I believe it was failed, because /boot partition was full. This commands try first to upgrade kernel to recent and crash with No space left on device while generating initrd.img
                              – vp_arth
                              Dec 3 '15 at 15:50






                            • 1




                              WARNING, directly removing files can lead to problems, as an update of the linux-firmware package can recreate the initrd.img file for every version it thinks is installed based on package information. See: askubuntu.com/questions/865577/…
                              – kgrittn
                              Jan 5 '17 at 13:57










                            • thanks, this is the life-saving final solution when nothing else works.
                              – Jeff Puckett
                              Aug 17 '17 at 3:28








                            4




                            4




                            This is not a good way to remove packages. While this answer isn't very specific about why removing them the correct way failed, I'm sure if that information was given (in a separate question of course) we'd be able to try and figure out the cause of the problem.
                            – thomasrutter
                            Aug 29 '14 at 9:55




                            This is not a good way to remove packages. While this answer isn't very specific about why removing them the correct way failed, I'm sure if that information was given (in a separate question of course) we'd be able to try and figure out the cause of the problem.
                            – thomasrutter
                            Aug 29 '14 at 9:55




                            2




                            2




                            I believe it was failed, because /boot partition was full. This commands try first to upgrade kernel to recent and crash with No space left on device while generating initrd.img
                            – vp_arth
                            Dec 3 '15 at 15:50




                            I believe it was failed, because /boot partition was full. This commands try first to upgrade kernel to recent and crash with No space left on device while generating initrd.img
                            – vp_arth
                            Dec 3 '15 at 15:50




                            1




                            1




                            WARNING, directly removing files can lead to problems, as an update of the linux-firmware package can recreate the initrd.img file for every version it thinks is installed based on package information. See: askubuntu.com/questions/865577/…
                            – kgrittn
                            Jan 5 '17 at 13:57




                            WARNING, directly removing files can lead to problems, as an update of the linux-firmware package can recreate the initrd.img file for every version it thinks is installed based on package information. See: askubuntu.com/questions/865577/…
                            – kgrittn
                            Jan 5 '17 at 13:57












                            thanks, this is the life-saving final solution when nothing else works.
                            – Jeff Puckett
                            Aug 17 '17 at 3:28




                            thanks, this is the life-saving final solution when nothing else works.
                            – Jeff Puckett
                            Aug 17 '17 at 3:28











                            2















                            I already deleted old kernel packages (linux-headers...)




                            linux-headers-* aren't kernels. Kernel packages are the ones named linux-image-*. The ones named linux-headers-* are development packages for compiling kernel modules: they don't live in the /boot directory and are not required for general day to day use of your system.



                            The files you listed in /boot do include several old kernel images (vmlinuz*) and compiled initrd images (initrd.img*) for those kernels, which is an indication that you still have a lot of old kernel packages installed.



                            You should be able to list your installed kernels with



                            aptitude search ~ilinux-image


                            (Note that this will probably return packages that aren't kernels, too).



                            There is usually no need for more than two kernels to be installed - the one currently in use and the previous one to that (as a fallback). So you can start removing the older ones, one by one, like this:



                            sudo apt-get autoremove linux-image-3.2.0-23-generic


                            Make sure you substitute "3.2.0-23-generic" with the actual kernel version you want to remove! Also, don't remove packages such as linux-image-generic. You have to be really careful not to remove the currently running kernel or you won't be able to boot (Ubuntu may or may not warn you about doing this).



                            You can find your currently running kernel with:



                            uname -r





                            share|improve this answer




























                              2















                              I already deleted old kernel packages (linux-headers...)




                              linux-headers-* aren't kernels. Kernel packages are the ones named linux-image-*. The ones named linux-headers-* are development packages for compiling kernel modules: they don't live in the /boot directory and are not required for general day to day use of your system.



                              The files you listed in /boot do include several old kernel images (vmlinuz*) and compiled initrd images (initrd.img*) for those kernels, which is an indication that you still have a lot of old kernel packages installed.



                              You should be able to list your installed kernels with



                              aptitude search ~ilinux-image


                              (Note that this will probably return packages that aren't kernels, too).



                              There is usually no need for more than two kernels to be installed - the one currently in use and the previous one to that (as a fallback). So you can start removing the older ones, one by one, like this:



                              sudo apt-get autoremove linux-image-3.2.0-23-generic


                              Make sure you substitute "3.2.0-23-generic" with the actual kernel version you want to remove! Also, don't remove packages such as linux-image-generic. You have to be really careful not to remove the currently running kernel or you won't be able to boot (Ubuntu may or may not warn you about doing this).



                              You can find your currently running kernel with:



                              uname -r





                              share|improve this answer


























                                2












                                2








                                2







                                I already deleted old kernel packages (linux-headers...)




                                linux-headers-* aren't kernels. Kernel packages are the ones named linux-image-*. The ones named linux-headers-* are development packages for compiling kernel modules: they don't live in the /boot directory and are not required for general day to day use of your system.



                                The files you listed in /boot do include several old kernel images (vmlinuz*) and compiled initrd images (initrd.img*) for those kernels, which is an indication that you still have a lot of old kernel packages installed.



                                You should be able to list your installed kernels with



                                aptitude search ~ilinux-image


                                (Note that this will probably return packages that aren't kernels, too).



                                There is usually no need for more than two kernels to be installed - the one currently in use and the previous one to that (as a fallback). So you can start removing the older ones, one by one, like this:



                                sudo apt-get autoremove linux-image-3.2.0-23-generic


                                Make sure you substitute "3.2.0-23-generic" with the actual kernel version you want to remove! Also, don't remove packages such as linux-image-generic. You have to be really careful not to remove the currently running kernel or you won't be able to boot (Ubuntu may or may not warn you about doing this).



                                You can find your currently running kernel with:



                                uname -r





                                share|improve this answer















                                I already deleted old kernel packages (linux-headers...)




                                linux-headers-* aren't kernels. Kernel packages are the ones named linux-image-*. The ones named linux-headers-* are development packages for compiling kernel modules: they don't live in the /boot directory and are not required for general day to day use of your system.



                                The files you listed in /boot do include several old kernel images (vmlinuz*) and compiled initrd images (initrd.img*) for those kernels, which is an indication that you still have a lot of old kernel packages installed.



                                You should be able to list your installed kernels with



                                aptitude search ~ilinux-image


                                (Note that this will probably return packages that aren't kernels, too).



                                There is usually no need for more than two kernels to be installed - the one currently in use and the previous one to that (as a fallback). So you can start removing the older ones, one by one, like this:



                                sudo apt-get autoremove linux-image-3.2.0-23-generic


                                Make sure you substitute "3.2.0-23-generic" with the actual kernel version you want to remove! Also, don't remove packages such as linux-image-generic. You have to be really careful not to remove the currently running kernel or you won't be able to boot (Ubuntu may or may not warn you about doing this).



                                You can find your currently running kernel with:



                                uname -r






                                share|improve this answer














                                share|improve this answer



                                share|improve this answer








                                edited Aug 29 '14 at 9:43

























                                answered Aug 29 '14 at 9:15









                                thomasrutter

                                26.4k46389




                                26.4k46389























                                    1














                                    I had this problem and more as I removed some initrd-img-xxx files manually from the /boot and I had a problem that these old versions keep generated and filling in the /boot folder. To fix it I followed the following:




                                    • I removed the generated old kernel version manually so to free space.


                                    • You’ll be editing a text configuration file as superuser, so paste the following into a terminal:



                                      sudo gedit /etc/initramfs-tools/update-initramfs.conf



                                    • Locate the line update_initramfs=yes and change it to update_initramfs=no. Save and exit the file, then run:



                                      sudo dpkg --configure -a



                                    That solved my problem. That was based on this blog



                                    Hopefully, everything should be fine when you reboot, and later you can try changing the no back to yes in update-initramfs.conf.






                                    share|improve this answer




























                                      1














                                      I had this problem and more as I removed some initrd-img-xxx files manually from the /boot and I had a problem that these old versions keep generated and filling in the /boot folder. To fix it I followed the following:




                                      • I removed the generated old kernel version manually so to free space.


                                      • You’ll be editing a text configuration file as superuser, so paste the following into a terminal:



                                        sudo gedit /etc/initramfs-tools/update-initramfs.conf



                                      • Locate the line update_initramfs=yes and change it to update_initramfs=no. Save and exit the file, then run:



                                        sudo dpkg --configure -a



                                      That solved my problem. That was based on this blog



                                      Hopefully, everything should be fine when you reboot, and later you can try changing the no back to yes in update-initramfs.conf.






                                      share|improve this answer


























                                        1












                                        1








                                        1






                                        I had this problem and more as I removed some initrd-img-xxx files manually from the /boot and I had a problem that these old versions keep generated and filling in the /boot folder. To fix it I followed the following:




                                        • I removed the generated old kernel version manually so to free space.


                                        • You’ll be editing a text configuration file as superuser, so paste the following into a terminal:



                                          sudo gedit /etc/initramfs-tools/update-initramfs.conf



                                        • Locate the line update_initramfs=yes and change it to update_initramfs=no. Save and exit the file, then run:



                                          sudo dpkg --configure -a



                                        That solved my problem. That was based on this blog



                                        Hopefully, everything should be fine when you reboot, and later you can try changing the no back to yes in update-initramfs.conf.






                                        share|improve this answer














                                        I had this problem and more as I removed some initrd-img-xxx files manually from the /boot and I had a problem that these old versions keep generated and filling in the /boot folder. To fix it I followed the following:




                                        • I removed the generated old kernel version manually so to free space.


                                        • You’ll be editing a text configuration file as superuser, so paste the following into a terminal:



                                          sudo gedit /etc/initramfs-tools/update-initramfs.conf



                                        • Locate the line update_initramfs=yes and change it to update_initramfs=no. Save and exit the file, then run:



                                          sudo dpkg --configure -a



                                        That solved my problem. That was based on this blog



                                        Hopefully, everything should be fine when you reboot, and later you can try changing the no back to yes in update-initramfs.conf.







                                        share|improve this answer














                                        share|improve this answer



                                        share|improve this answer








                                        edited Mar 23 '17 at 9:05









                                        muru

                                        1




                                        1










                                        answered Mar 23 '17 at 8:59









                                        aibrahim

                                        826




                                        826























                                            1














                                            List all kernels:



                                            dpkg --list 'linux-image*'


                                            Display current kernel:



                                            uname -r


                                            List all kernels EXCEPT current one:



                                            dpkg -l linux-{image,headers}-"[0-9]*" | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e '[0-9]'


                                            Make sure your current kernel isn't on that list.



                                            Remove all kernels EXCEPT current one:



                                            dpkg -l linux-{image,headers}-"[0-9]*" | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e '[0-9]' | xargs sudo apt-get -y purge


                                            Clear other stuff:



                                            sudo apt-get autoremove


                                            If it still gives you boot disk space error for installing/uninstalling files then directly remove one of OLD image from /boot directory,



                                            ls -lh /boot/*-3.13.0-119*;

                                            rm /boot/*-3.13.0-119*;


                                            NOTE: Please review current kernel image again before deleting any image.






                                            share|improve this answer


























                                              1














                                              List all kernels:



                                              dpkg --list 'linux-image*'


                                              Display current kernel:



                                              uname -r


                                              List all kernels EXCEPT current one:



                                              dpkg -l linux-{image,headers}-"[0-9]*" | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e '[0-9]'


                                              Make sure your current kernel isn't on that list.



                                              Remove all kernels EXCEPT current one:



                                              dpkg -l linux-{image,headers}-"[0-9]*" | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e '[0-9]' | xargs sudo apt-get -y purge


                                              Clear other stuff:



                                              sudo apt-get autoremove


                                              If it still gives you boot disk space error for installing/uninstalling files then directly remove one of OLD image from /boot directory,



                                              ls -lh /boot/*-3.13.0-119*;

                                              rm /boot/*-3.13.0-119*;


                                              NOTE: Please review current kernel image again before deleting any image.






                                              share|improve this answer
























                                                1












                                                1








                                                1






                                                List all kernels:



                                                dpkg --list 'linux-image*'


                                                Display current kernel:



                                                uname -r


                                                List all kernels EXCEPT current one:



                                                dpkg -l linux-{image,headers}-"[0-9]*" | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e '[0-9]'


                                                Make sure your current kernel isn't on that list.



                                                Remove all kernels EXCEPT current one:



                                                dpkg -l linux-{image,headers}-"[0-9]*" | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e '[0-9]' | xargs sudo apt-get -y purge


                                                Clear other stuff:



                                                sudo apt-get autoremove


                                                If it still gives you boot disk space error for installing/uninstalling files then directly remove one of OLD image from /boot directory,



                                                ls -lh /boot/*-3.13.0-119*;

                                                rm /boot/*-3.13.0-119*;


                                                NOTE: Please review current kernel image again before deleting any image.






                                                share|improve this answer












                                                List all kernels:



                                                dpkg --list 'linux-image*'


                                                Display current kernel:



                                                uname -r


                                                List all kernels EXCEPT current one:



                                                dpkg -l linux-{image,headers}-"[0-9]*" | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e '[0-9]'


                                                Make sure your current kernel isn't on that list.



                                                Remove all kernels EXCEPT current one:



                                                dpkg -l linux-{image,headers}-"[0-9]*" | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e '[0-9]' | xargs sudo apt-get -y purge


                                                Clear other stuff:



                                                sudo apt-get autoremove


                                                If it still gives you boot disk space error for installing/uninstalling files then directly remove one of OLD image from /boot directory,



                                                ls -lh /boot/*-3.13.0-119*;

                                                rm /boot/*-3.13.0-119*;


                                                NOTE: Please review current kernel image again before deleting any image.







                                                share|improve this answer












                                                share|improve this answer



                                                share|improve this answer










                                                answered Jul 10 '18 at 10:35









                                                Hemant Thorat

                                                1312




                                                1312























                                                    1














                                                    Super helpful utility that will clear out your boot partition



                                                    git clone https://github.com/erichs/bootnukem.git
                                                    cd bootnukem
                                                    sudo ./install.sh


                                                    Use at your own risk, but it worked for me:



                                                    sudo bootnukem





                                                    share|improve this answer























                                                    • Why the downvote?
                                                      – Jonathan
                                                      Feb 8 '17 at 2:30
















                                                    1














                                                    Super helpful utility that will clear out your boot partition



                                                    git clone https://github.com/erichs/bootnukem.git
                                                    cd bootnukem
                                                    sudo ./install.sh


                                                    Use at your own risk, but it worked for me:



                                                    sudo bootnukem





                                                    share|improve this answer























                                                    • Why the downvote?
                                                      – Jonathan
                                                      Feb 8 '17 at 2:30














                                                    1












                                                    1








                                                    1






                                                    Super helpful utility that will clear out your boot partition



                                                    git clone https://github.com/erichs/bootnukem.git
                                                    cd bootnukem
                                                    sudo ./install.sh


                                                    Use at your own risk, but it worked for me:



                                                    sudo bootnukem





                                                    share|improve this answer














                                                    Super helpful utility that will clear out your boot partition



                                                    git clone https://github.com/erichs/bootnukem.git
                                                    cd bootnukem
                                                    sudo ./install.sh


                                                    Use at your own risk, but it worked for me:



                                                    sudo bootnukem






                                                    share|improve this answer














                                                    share|improve this answer



                                                    share|improve this answer








                                                    edited Oct 3 '18 at 1:23

























                                                    answered Aug 14 '16 at 20:08









                                                    Jonathan

                                                    1,24531527




                                                    1,24531527












                                                    • Why the downvote?
                                                      – Jonathan
                                                      Feb 8 '17 at 2:30


















                                                    • Why the downvote?
                                                      – Jonathan
                                                      Feb 8 '17 at 2:30
















                                                    Why the downvote?
                                                    – Jonathan
                                                    Feb 8 '17 at 2:30




                                                    Why the downvote?
                                                    – Jonathan
                                                    Feb 8 '17 at 2:30











                                                    0














                                                    In aptitude or synaptic there is a section "old or manually installed packaged". There should be the old linux packages there.






                                                    share|improve this answer


























                                                      0














                                                      In aptitude or synaptic there is a section "old or manually installed packaged". There should be the old linux packages there.






                                                      share|improve this answer
























                                                        0












                                                        0








                                                        0






                                                        In aptitude or synaptic there is a section "old or manually installed packaged". There should be the old linux packages there.






                                                        share|improve this answer












                                                        In aptitude or synaptic there is a section "old or manually installed packaged". There should be the old linux packages there.







                                                        share|improve this answer












                                                        share|improve this answer



                                                        share|improve this answer










                                                        answered Dec 22 '11 at 11:59









                                                        Martin Ueding

                                                        3,878104076




                                                        3,878104076























                                                            0














                                                            There's a bash script which I wrote give below that makes the process a bit more user-friendly.



                                                            YMMV - it was made for Mint 14. Still learning BASH so it's probably a bit clunky. Use at own risk, but it works for me!



                                                            #!/bin/bash

                                                            endCol='e[0m'
                                                            bold_red='e[1;31m'
                                                            bold_green='e[1;32m'
                                                            bold_yellow='e[1;33m'

                                                            title_color='e[0;30;47m'

                                                            function show_kernel_info {
                                                            clear
                                                            current_kernel=$(uname -r)
                                                            echo "Current ACTIVE kernel is:"
                                                            echo -e " "$bold_yellow$current_kernel$endCol
                                                            echo "This kernel will be TOTALLY EXCLUDED from all actions in this script."
                                                            echo "Also, one fallback non-active kernel will be always left untouched."
                                                            echo ""
                                                            echo "These are the non-active kernels stored in /boot:"
                                                            count_of_old_kernels_in_boot=$(ls -o /boot/initrd* | grep -c -v "$current_kernel")
                                                            if [ $count_of_old_kernels_in_boot = 0 ]; then
                                                            echo " * No non-active kernels found! *"
                                                            else
                                                            ls -o /boot/initrd* | grep -v "$current_kernel"
                                                            fi
                                                            echo ""
                                                            list_of_old_kernels=$(dpkg --list | grep linux-image | awk -F' ' '{ print $2 }' | grep -v "$current_kernel" | grep -v "linux-image-generic")
                                                            current_old_kernel=$(dpkg --list | grep linux-image | awk -F' ' '{ print $2 }' | grep -v "$current_kernel" | grep -v "linux-image-generic" | head -n 1)
                                                            count_of_old_kernels_installed=$(dpkg --list | grep linux-image | awk -F' ' '{ print $2 }' | grep -v "$current_kernel" | grep -c -v "linux-image-generic")
                                                            echo "Listing of all unused kernels still installed in the system (these may not exist in /boot):"
                                                            if [ $count_of_old_kernels_installed = 0 ]; then
                                                            echo " * No unused kernel installs found! *"
                                                            else
                                                            dpkg --list | grep linux-image | awk -F' ' '{ print $2 }' | grep -v "$current_kernel" | grep -v "linux-image-generic"
                                                            fi
                                                            echo ""
                                                            }

                                                            function exit_script {
                                                            free_space_after=$(df -BM /boot | tail -n 1 | awk -F' ' '{ print $4 }' | tr -d M)
                                                            let freed_space=$free_space_after-$free_space_before
                                                            echo ""
                                                            echo "Results (in MB)"
                                                            echo "---------------"
                                                            echo "Free space in /boot before script was run: "$free_space_before
                                                            echo "Free space now: "$free_space_after
                                                            echo ""
                                                            echo "Amount of space freed up = "$freed_space
                                                            echo ""
                                                            echo "Press any key to exit."
                                                            read -s -n 1
                                                            echo ""
                                                            exit
                                                            }

                                                            # Main code
                                                            echo ""
                                                            echo -e $title_color" --------------------------- "$endCol
                                                            echo -e $title_color" - Kernel Cleanup v1.0 - "$endCol
                                                            echo -e $title_color" --------------------------- "$endCol
                                                            echo ""
                                                            echo "Maximise this window for readability."
                                                            echo "Press any key to continue."
                                                            read -s -n 1
                                                            echo ""
                                                            echo "This script will remove old unused kernels, but it will prompt you before removing each one."
                                                            echo "It will never remove the current running kernel, and will also leave one fallback kernel."
                                                            echo "It can also remove source files from /usr/src for each kernel removed."
                                                            echo "This is normally safe to do and will free up lots more space."
                                                            echo ""
                                                            echo "Do you want that done as well? (y/n, enter=yes)"
                                                            valid_input=0
                                                            while [ "$valid_input" = "0" ]; do
                                                            read -s -n 1 YesNo_input
                                                            if [ "$YesNo_input" = "" ]; then
                                                            YesNo_input="y"
                                                            fi
                                                            case $YesNo_input
                                                            in
                                                            y)
                                                            RemoveSource="y"
                                                            valid_input=1
                                                            ;;

                                                            Y)
                                                            RemoveSource="y"
                                                            valid_input=1
                                                            ;;

                                                            n)
                                                            RemoveSource="n"
                                                            valid_input=1
                                                            ;;

                                                            N)
                                                            RemoveSource="N"
                                                            valid_input=1
                                                            ;;
                                                            esac
                                                            done

                                                            free_space_before=$(df -h /boot | tail -n 1 | awk -F' ' '{ print $4 }' | tr -d M)
                                                            show_kernel_info
                                                            while [ $count_of_old_kernels_in_boot -gt 1 ]; do
                                                            # failsafe check if somehow the current kernel is about to be removed!
                                                            if [ "$current_old_kernel" = "$current_kernel" ]; then
                                                            echo -e $bold_red"ERROR!"$endCol" Somehow the current kernel has crept into the removal process!"
                                                            echo "I refuse to do that! Aborting script."
                                                            exit_script
                                                            fi
                                                            # failsafe check if somehow a linux-image-generic entry is about to be removed
                                                            if [ "$current_old_kernel" = "linux-image-generic" ]; then
                                                            echo -e $bold_red"ERROR!"$endCol" Somehow one of the linux-image-generic entries has crept into the removal process!"
                                                            echo "I refuse to do that! Aborting script."
                                                            exit_script
                                                            fi
                                                            echo "Command about to be executed is:"
                                                            echo " $ sudo apt-get purge "$current_old_kernel""
                                                            check_in_boot=$(echo $current_old_kernel | sed 's/linux-image/initrd.img/g')
                                                            if [ -e /boot/$check_in_boot ]; then
                                                            echo -e $bold_yellow"Note:"$endCol" This kernel exists in /boot but it NON-active, so it's OK to remove."
                                                            else
                                                            echo -e $bold_green"Totally safe to remove:"$endCol" This kernel does NOT exist in /boot."
                                                            fi
                                                            echo ""
                                                            echo "Are you sure you want to remove this kernel?"
                                                            echo "(*upper case* Y=yes / any other key will exit the script)"
                                                            read -s -n 1 yes_no
                                                            echo ""
                                                            # Only entering a single upper case Y will work!
                                                            if [ "$yes_no" != "Y" ]; then
                                                            echo "Aborting script."
                                                            exit_script
                                                            fi
                                                            echo "Removing kernel "$current_old_kernel"..."
                                                            sleep 1
                                                            sudo apt-get -y purge $current_old_kernel
                                                            if [ "$RemoveSource" = "y" ]; then
                                                            current_old_source=$(echo $current_old_kernel | sed 's/linux-image/linux-headers/g')
                                                            current_old_source=$(echo $current_old_source | sed 's/-generic//g')
                                                            current_old_source=$(echo $current_old_source | sed 's/-pae//g')
                                                            sudo apt-get -y purge $current_old_source
                                                            fi
                                                            show_kernel_info
                                                            done

                                                            if [ $count_of_old_kernels_in_boot = 0 ]; then
                                                            echo -e $bold_red"There are no NON-active kernels to remove!"$endCol
                                                            else
                                                            echo -e $bold_red"There is only one NON-active kernel left in /boot!"$endCol
                                                            echo "This script will not remove the last non-active kernel so that you have at least one backup kernel."
                                                            fi
                                                            echo "Aborting script."
                                                            exit_script





                                                            share|improve this answer




























                                                              0














                                                              There's a bash script which I wrote give below that makes the process a bit more user-friendly.



                                                              YMMV - it was made for Mint 14. Still learning BASH so it's probably a bit clunky. Use at own risk, but it works for me!



                                                              #!/bin/bash

                                                              endCol='e[0m'
                                                              bold_red='e[1;31m'
                                                              bold_green='e[1;32m'
                                                              bold_yellow='e[1;33m'

                                                              title_color='e[0;30;47m'

                                                              function show_kernel_info {
                                                              clear
                                                              current_kernel=$(uname -r)
                                                              echo "Current ACTIVE kernel is:"
                                                              echo -e " "$bold_yellow$current_kernel$endCol
                                                              echo "This kernel will be TOTALLY EXCLUDED from all actions in this script."
                                                              echo "Also, one fallback non-active kernel will be always left untouched."
                                                              echo ""
                                                              echo "These are the non-active kernels stored in /boot:"
                                                              count_of_old_kernels_in_boot=$(ls -o /boot/initrd* | grep -c -v "$current_kernel")
                                                              if [ $count_of_old_kernels_in_boot = 0 ]; then
                                                              echo " * No non-active kernels found! *"
                                                              else
                                                              ls -o /boot/initrd* | grep -v "$current_kernel"
                                                              fi
                                                              echo ""
                                                              list_of_old_kernels=$(dpkg --list | grep linux-image | awk -F' ' '{ print $2 }' | grep -v "$current_kernel" | grep -v "linux-image-generic")
                                                              current_old_kernel=$(dpkg --list | grep linux-image | awk -F' ' '{ print $2 }' | grep -v "$current_kernel" | grep -v "linux-image-generic" | head -n 1)
                                                              count_of_old_kernels_installed=$(dpkg --list | grep linux-image | awk -F' ' '{ print $2 }' | grep -v "$current_kernel" | grep -c -v "linux-image-generic")
                                                              echo "Listing of all unused kernels still installed in the system (these may not exist in /boot):"
                                                              if [ $count_of_old_kernels_installed = 0 ]; then
                                                              echo " * No unused kernel installs found! *"
                                                              else
                                                              dpkg --list | grep linux-image | awk -F' ' '{ print $2 }' | grep -v "$current_kernel" | grep -v "linux-image-generic"
                                                              fi
                                                              echo ""
                                                              }

                                                              function exit_script {
                                                              free_space_after=$(df -BM /boot | tail -n 1 | awk -F' ' '{ print $4 }' | tr -d M)
                                                              let freed_space=$free_space_after-$free_space_before
                                                              echo ""
                                                              echo "Results (in MB)"
                                                              echo "---------------"
                                                              echo "Free space in /boot before script was run: "$free_space_before
                                                              echo "Free space now: "$free_space_after
                                                              echo ""
                                                              echo "Amount of space freed up = "$freed_space
                                                              echo ""
                                                              echo "Press any key to exit."
                                                              read -s -n 1
                                                              echo ""
                                                              exit
                                                              }

                                                              # Main code
                                                              echo ""
                                                              echo -e $title_color" --------------------------- "$endCol
                                                              echo -e $title_color" - Kernel Cleanup v1.0 - "$endCol
                                                              echo -e $title_color" --------------------------- "$endCol
                                                              echo ""
                                                              echo "Maximise this window for readability."
                                                              echo "Press any key to continue."
                                                              read -s -n 1
                                                              echo ""
                                                              echo "This script will remove old unused kernels, but it will prompt you before removing each one."
                                                              echo "It will never remove the current running kernel, and will also leave one fallback kernel."
                                                              echo "It can also remove source files from /usr/src for each kernel removed."
                                                              echo "This is normally safe to do and will free up lots more space."
                                                              echo ""
                                                              echo "Do you want that done as well? (y/n, enter=yes)"
                                                              valid_input=0
                                                              while [ "$valid_input" = "0" ]; do
                                                              read -s -n 1 YesNo_input
                                                              if [ "$YesNo_input" = "" ]; then
                                                              YesNo_input="y"
                                                              fi
                                                              case $YesNo_input
                                                              in
                                                              y)
                                                              RemoveSource="y"
                                                              valid_input=1
                                                              ;;

                                                              Y)
                                                              RemoveSource="y"
                                                              valid_input=1
                                                              ;;

                                                              n)
                                                              RemoveSource="n"
                                                              valid_input=1
                                                              ;;

                                                              N)
                                                              RemoveSource="N"
                                                              valid_input=1
                                                              ;;
                                                              esac
                                                              done

                                                              free_space_before=$(df -h /boot | tail -n 1 | awk -F' ' '{ print $4 }' | tr -d M)
                                                              show_kernel_info
                                                              while [ $count_of_old_kernels_in_boot -gt 1 ]; do
                                                              # failsafe check if somehow the current kernel is about to be removed!
                                                              if [ "$current_old_kernel" = "$current_kernel" ]; then
                                                              echo -e $bold_red"ERROR!"$endCol" Somehow the current kernel has crept into the removal process!"
                                                              echo "I refuse to do that! Aborting script."
                                                              exit_script
                                                              fi
                                                              # failsafe check if somehow a linux-image-generic entry is about to be removed
                                                              if [ "$current_old_kernel" = "linux-image-generic" ]; then
                                                              echo -e $bold_red"ERROR!"$endCol" Somehow one of the linux-image-generic entries has crept into the removal process!"
                                                              echo "I refuse to do that! Aborting script."
                                                              exit_script
                                                              fi
                                                              echo "Command about to be executed is:"
                                                              echo " $ sudo apt-get purge "$current_old_kernel""
                                                              check_in_boot=$(echo $current_old_kernel | sed 's/linux-image/initrd.img/g')
                                                              if [ -e /boot/$check_in_boot ]; then
                                                              echo -e $bold_yellow"Note:"$endCol" This kernel exists in /boot but it NON-active, so it's OK to remove."
                                                              else
                                                              echo -e $bold_green"Totally safe to remove:"$endCol" This kernel does NOT exist in /boot."
                                                              fi
                                                              echo ""
                                                              echo "Are you sure you want to remove this kernel?"
                                                              echo "(*upper case* Y=yes / any other key will exit the script)"
                                                              read -s -n 1 yes_no
                                                              echo ""
                                                              # Only entering a single upper case Y will work!
                                                              if [ "$yes_no" != "Y" ]; then
                                                              echo "Aborting script."
                                                              exit_script
                                                              fi
                                                              echo "Removing kernel "$current_old_kernel"..."
                                                              sleep 1
                                                              sudo apt-get -y purge $current_old_kernel
                                                              if [ "$RemoveSource" = "y" ]; then
                                                              current_old_source=$(echo $current_old_kernel | sed 's/linux-image/linux-headers/g')
                                                              current_old_source=$(echo $current_old_source | sed 's/-generic//g')
                                                              current_old_source=$(echo $current_old_source | sed 's/-pae//g')
                                                              sudo apt-get -y purge $current_old_source
                                                              fi
                                                              show_kernel_info
                                                              done

                                                              if [ $count_of_old_kernels_in_boot = 0 ]; then
                                                              echo -e $bold_red"There are no NON-active kernels to remove!"$endCol
                                                              else
                                                              echo -e $bold_red"There is only one NON-active kernel left in /boot!"$endCol
                                                              echo "This script will not remove the last non-active kernel so that you have at least one backup kernel."
                                                              fi
                                                              echo "Aborting script."
                                                              exit_script





                                                              share|improve this answer


























                                                                0












                                                                0








                                                                0






                                                                There's a bash script which I wrote give below that makes the process a bit more user-friendly.



                                                                YMMV - it was made for Mint 14. Still learning BASH so it's probably a bit clunky. Use at own risk, but it works for me!



                                                                #!/bin/bash

                                                                endCol='e[0m'
                                                                bold_red='e[1;31m'
                                                                bold_green='e[1;32m'
                                                                bold_yellow='e[1;33m'

                                                                title_color='e[0;30;47m'

                                                                function show_kernel_info {
                                                                clear
                                                                current_kernel=$(uname -r)
                                                                echo "Current ACTIVE kernel is:"
                                                                echo -e " "$bold_yellow$current_kernel$endCol
                                                                echo "This kernel will be TOTALLY EXCLUDED from all actions in this script."
                                                                echo "Also, one fallback non-active kernel will be always left untouched."
                                                                echo ""
                                                                echo "These are the non-active kernels stored in /boot:"
                                                                count_of_old_kernels_in_boot=$(ls -o /boot/initrd* | grep -c -v "$current_kernel")
                                                                if [ $count_of_old_kernels_in_boot = 0 ]; then
                                                                echo " * No non-active kernels found! *"
                                                                else
                                                                ls -o /boot/initrd* | grep -v "$current_kernel"
                                                                fi
                                                                echo ""
                                                                list_of_old_kernels=$(dpkg --list | grep linux-image | awk -F' ' '{ print $2 }' | grep -v "$current_kernel" | grep -v "linux-image-generic")
                                                                current_old_kernel=$(dpkg --list | grep linux-image | awk -F' ' '{ print $2 }' | grep -v "$current_kernel" | grep -v "linux-image-generic" | head -n 1)
                                                                count_of_old_kernels_installed=$(dpkg --list | grep linux-image | awk -F' ' '{ print $2 }' | grep -v "$current_kernel" | grep -c -v "linux-image-generic")
                                                                echo "Listing of all unused kernels still installed in the system (these may not exist in /boot):"
                                                                if [ $count_of_old_kernels_installed = 0 ]; then
                                                                echo " * No unused kernel installs found! *"
                                                                else
                                                                dpkg --list | grep linux-image | awk -F' ' '{ print $2 }' | grep -v "$current_kernel" | grep -v "linux-image-generic"
                                                                fi
                                                                echo ""
                                                                }

                                                                function exit_script {
                                                                free_space_after=$(df -BM /boot | tail -n 1 | awk -F' ' '{ print $4 }' | tr -d M)
                                                                let freed_space=$free_space_after-$free_space_before
                                                                echo ""
                                                                echo "Results (in MB)"
                                                                echo "---------------"
                                                                echo "Free space in /boot before script was run: "$free_space_before
                                                                echo "Free space now: "$free_space_after
                                                                echo ""
                                                                echo "Amount of space freed up = "$freed_space
                                                                echo ""
                                                                echo "Press any key to exit."
                                                                read -s -n 1
                                                                echo ""
                                                                exit
                                                                }

                                                                # Main code
                                                                echo ""
                                                                echo -e $title_color" --------------------------- "$endCol
                                                                echo -e $title_color" - Kernel Cleanup v1.0 - "$endCol
                                                                echo -e $title_color" --------------------------- "$endCol
                                                                echo ""
                                                                echo "Maximise this window for readability."
                                                                echo "Press any key to continue."
                                                                read -s -n 1
                                                                echo ""
                                                                echo "This script will remove old unused kernels, but it will prompt you before removing each one."
                                                                echo "It will never remove the current running kernel, and will also leave one fallback kernel."
                                                                echo "It can also remove source files from /usr/src for each kernel removed."
                                                                echo "This is normally safe to do and will free up lots more space."
                                                                echo ""
                                                                echo "Do you want that done as well? (y/n, enter=yes)"
                                                                valid_input=0
                                                                while [ "$valid_input" = "0" ]; do
                                                                read -s -n 1 YesNo_input
                                                                if [ "$YesNo_input" = "" ]; then
                                                                YesNo_input="y"
                                                                fi
                                                                case $YesNo_input
                                                                in
                                                                y)
                                                                RemoveSource="y"
                                                                valid_input=1
                                                                ;;

                                                                Y)
                                                                RemoveSource="y"
                                                                valid_input=1
                                                                ;;

                                                                n)
                                                                RemoveSource="n"
                                                                valid_input=1
                                                                ;;

                                                                N)
                                                                RemoveSource="N"
                                                                valid_input=1
                                                                ;;
                                                                esac
                                                                done

                                                                free_space_before=$(df -h /boot | tail -n 1 | awk -F' ' '{ print $4 }' | tr -d M)
                                                                show_kernel_info
                                                                while [ $count_of_old_kernels_in_boot -gt 1 ]; do
                                                                # failsafe check if somehow the current kernel is about to be removed!
                                                                if [ "$current_old_kernel" = "$current_kernel" ]; then
                                                                echo -e $bold_red"ERROR!"$endCol" Somehow the current kernel has crept into the removal process!"
                                                                echo "I refuse to do that! Aborting script."
                                                                exit_script
                                                                fi
                                                                # failsafe check if somehow a linux-image-generic entry is about to be removed
                                                                if [ "$current_old_kernel" = "linux-image-generic" ]; then
                                                                echo -e $bold_red"ERROR!"$endCol" Somehow one of the linux-image-generic entries has crept into the removal process!"
                                                                echo "I refuse to do that! Aborting script."
                                                                exit_script
                                                                fi
                                                                echo "Command about to be executed is:"
                                                                echo " $ sudo apt-get purge "$current_old_kernel""
                                                                check_in_boot=$(echo $current_old_kernel | sed 's/linux-image/initrd.img/g')
                                                                if [ -e /boot/$check_in_boot ]; then
                                                                echo -e $bold_yellow"Note:"$endCol" This kernel exists in /boot but it NON-active, so it's OK to remove."
                                                                else
                                                                echo -e $bold_green"Totally safe to remove:"$endCol" This kernel does NOT exist in /boot."
                                                                fi
                                                                echo ""
                                                                echo "Are you sure you want to remove this kernel?"
                                                                echo "(*upper case* Y=yes / any other key will exit the script)"
                                                                read -s -n 1 yes_no
                                                                echo ""
                                                                # Only entering a single upper case Y will work!
                                                                if [ "$yes_no" != "Y" ]; then
                                                                echo "Aborting script."
                                                                exit_script
                                                                fi
                                                                echo "Removing kernel "$current_old_kernel"..."
                                                                sleep 1
                                                                sudo apt-get -y purge $current_old_kernel
                                                                if [ "$RemoveSource" = "y" ]; then
                                                                current_old_source=$(echo $current_old_kernel | sed 's/linux-image/linux-headers/g')
                                                                current_old_source=$(echo $current_old_source | sed 's/-generic//g')
                                                                current_old_source=$(echo $current_old_source | sed 's/-pae//g')
                                                                sudo apt-get -y purge $current_old_source
                                                                fi
                                                                show_kernel_info
                                                                done

                                                                if [ $count_of_old_kernels_in_boot = 0 ]; then
                                                                echo -e $bold_red"There are no NON-active kernels to remove!"$endCol
                                                                else
                                                                echo -e $bold_red"There is only one NON-active kernel left in /boot!"$endCol
                                                                echo "This script will not remove the last non-active kernel so that you have at least one backup kernel."
                                                                fi
                                                                echo "Aborting script."
                                                                exit_script





                                                                share|improve this answer














                                                                There's a bash script which I wrote give below that makes the process a bit more user-friendly.



                                                                YMMV - it was made for Mint 14. Still learning BASH so it's probably a bit clunky. Use at own risk, but it works for me!



                                                                #!/bin/bash

                                                                endCol='e[0m'
                                                                bold_red='e[1;31m'
                                                                bold_green='e[1;32m'
                                                                bold_yellow='e[1;33m'

                                                                title_color='e[0;30;47m'

                                                                function show_kernel_info {
                                                                clear
                                                                current_kernel=$(uname -r)
                                                                echo "Current ACTIVE kernel is:"
                                                                echo -e " "$bold_yellow$current_kernel$endCol
                                                                echo "This kernel will be TOTALLY EXCLUDED from all actions in this script."
                                                                echo "Also, one fallback non-active kernel will be always left untouched."
                                                                echo ""
                                                                echo "These are the non-active kernels stored in /boot:"
                                                                count_of_old_kernels_in_boot=$(ls -o /boot/initrd* | grep -c -v "$current_kernel")
                                                                if [ $count_of_old_kernels_in_boot = 0 ]; then
                                                                echo " * No non-active kernels found! *"
                                                                else
                                                                ls -o /boot/initrd* | grep -v "$current_kernel"
                                                                fi
                                                                echo ""
                                                                list_of_old_kernels=$(dpkg --list | grep linux-image | awk -F' ' '{ print $2 }' | grep -v "$current_kernel" | grep -v "linux-image-generic")
                                                                current_old_kernel=$(dpkg --list | grep linux-image | awk -F' ' '{ print $2 }' | grep -v "$current_kernel" | grep -v "linux-image-generic" | head -n 1)
                                                                count_of_old_kernels_installed=$(dpkg --list | grep linux-image | awk -F' ' '{ print $2 }' | grep -v "$current_kernel" | grep -c -v "linux-image-generic")
                                                                echo "Listing of all unused kernels still installed in the system (these may not exist in /boot):"
                                                                if [ $count_of_old_kernels_installed = 0 ]; then
                                                                echo " * No unused kernel installs found! *"
                                                                else
                                                                dpkg --list | grep linux-image | awk -F' ' '{ print $2 }' | grep -v "$current_kernel" | grep -v "linux-image-generic"
                                                                fi
                                                                echo ""
                                                                }

                                                                function exit_script {
                                                                free_space_after=$(df -BM /boot | tail -n 1 | awk -F' ' '{ print $4 }' | tr -d M)
                                                                let freed_space=$free_space_after-$free_space_before
                                                                echo ""
                                                                echo "Results (in MB)"
                                                                echo "---------------"
                                                                echo "Free space in /boot before script was run: "$free_space_before
                                                                echo "Free space now: "$free_space_after
                                                                echo ""
                                                                echo "Amount of space freed up = "$freed_space
                                                                echo ""
                                                                echo "Press any key to exit."
                                                                read -s -n 1
                                                                echo ""
                                                                exit
                                                                }

                                                                # Main code
                                                                echo ""
                                                                echo -e $title_color" --------------------------- "$endCol
                                                                echo -e $title_color" - Kernel Cleanup v1.0 - "$endCol
                                                                echo -e $title_color" --------------------------- "$endCol
                                                                echo ""
                                                                echo "Maximise this window for readability."
                                                                echo "Press any key to continue."
                                                                read -s -n 1
                                                                echo ""
                                                                echo "This script will remove old unused kernels, but it will prompt you before removing each one."
                                                                echo "It will never remove the current running kernel, and will also leave one fallback kernel."
                                                                echo "It can also remove source files from /usr/src for each kernel removed."
                                                                echo "This is normally safe to do and will free up lots more space."
                                                                echo ""
                                                                echo "Do you want that done as well? (y/n, enter=yes)"
                                                                valid_input=0
                                                                while [ "$valid_input" = "0" ]; do
                                                                read -s -n 1 YesNo_input
                                                                if [ "$YesNo_input" = "" ]; then
                                                                YesNo_input="y"
                                                                fi
                                                                case $YesNo_input
                                                                in
                                                                y)
                                                                RemoveSource="y"
                                                                valid_input=1
                                                                ;;

                                                                Y)
                                                                RemoveSource="y"
                                                                valid_input=1
                                                                ;;

                                                                n)
                                                                RemoveSource="n"
                                                                valid_input=1
                                                                ;;

                                                                N)
                                                                RemoveSource="N"
                                                                valid_input=1
                                                                ;;
                                                                esac
                                                                done

                                                                free_space_before=$(df -h /boot | tail -n 1 | awk -F' ' '{ print $4 }' | tr -d M)
                                                                show_kernel_info
                                                                while [ $count_of_old_kernels_in_boot -gt 1 ]; do
                                                                # failsafe check if somehow the current kernel is about to be removed!
                                                                if [ "$current_old_kernel" = "$current_kernel" ]; then
                                                                echo -e $bold_red"ERROR!"$endCol" Somehow the current kernel has crept into the removal process!"
                                                                echo "I refuse to do that! Aborting script."
                                                                exit_script
                                                                fi
                                                                # failsafe check if somehow a linux-image-generic entry is about to be removed
                                                                if [ "$current_old_kernel" = "linux-image-generic" ]; then
                                                                echo -e $bold_red"ERROR!"$endCol" Somehow one of the linux-image-generic entries has crept into the removal process!"
                                                                echo "I refuse to do that! Aborting script."
                                                                exit_script
                                                                fi
                                                                echo "Command about to be executed is:"
                                                                echo " $ sudo apt-get purge "$current_old_kernel""
                                                                check_in_boot=$(echo $current_old_kernel | sed 's/linux-image/initrd.img/g')
                                                                if [ -e /boot/$check_in_boot ]; then
                                                                echo -e $bold_yellow"Note:"$endCol" This kernel exists in /boot but it NON-active, so it's OK to remove."
                                                                else
                                                                echo -e $bold_green"Totally safe to remove:"$endCol" This kernel does NOT exist in /boot."
                                                                fi
                                                                echo ""
                                                                echo "Are you sure you want to remove this kernel?"
                                                                echo "(*upper case* Y=yes / any other key will exit the script)"
                                                                read -s -n 1 yes_no
                                                                echo ""
                                                                # Only entering a single upper case Y will work!
                                                                if [ "$yes_no" != "Y" ]; then
                                                                echo "Aborting script."
                                                                exit_script
                                                                fi
                                                                echo "Removing kernel "$current_old_kernel"..."
                                                                sleep 1
                                                                sudo apt-get -y purge $current_old_kernel
                                                                if [ "$RemoveSource" = "y" ]; then
                                                                current_old_source=$(echo $current_old_kernel | sed 's/linux-image/linux-headers/g')
                                                                current_old_source=$(echo $current_old_source | sed 's/-generic//g')
                                                                current_old_source=$(echo $current_old_source | sed 's/-pae//g')
                                                                sudo apt-get -y purge $current_old_source
                                                                fi
                                                                show_kernel_info
                                                                done

                                                                if [ $count_of_old_kernels_in_boot = 0 ]; then
                                                                echo -e $bold_red"There are no NON-active kernels to remove!"$endCol
                                                                else
                                                                echo -e $bold_red"There is only one NON-active kernel left in /boot!"$endCol
                                                                echo "This script will not remove the last non-active kernel so that you have at least one backup kernel."
                                                                fi
                                                                echo "Aborting script."
                                                                exit_script






                                                                share|improve this answer














                                                                share|improve this answer



                                                                share|improve this answer








                                                                edited Mar 8 '14 at 7:31









                                                                Stormvirux

                                                                3,7661831




                                                                3,7661831










                                                                answered Mar 8 '14 at 6:33









                                                                wibbynut

                                                                1




                                                                1























                                                                    0














                                                                    [As an AskUbuntu noob I can't comment until reputation = 50 so don't down-vote because of this.]



                                                                    My server was doing this, too. Literally none of the expected answers here worked since these require some working room on /boot for them to complete. If the boot partition is full, it will abruptly end without deleting any of the images.



                                                                    The only thing that worked for me was to review the current image, then to manually sudo rm filename for the oldest image files (each had -3.16.0-30 in their names). Once that was done, then sudo apt-get autoremove had the wiggle-room it needed to do its job. It did highlight some errors associated with that version, for example: "depmod: FATAL: could not load /boot/System.map-3.16.0-30-generic: No such file or directory" but that is to be expected.



                                                                    When finished, the df returned a 42% in use for /boot to indicate that it's healthy again.






                                                                    share|improve this answer





















                                                                    • The post you're looking for is askubuntu.com/questions/171209/…
                                                                      – muru
                                                                      Feb 8 '17 at 2:02










                                                                    • @muru Well, yes... I would suggest that the original poster would need this advice, too. Once /boot is full, these scripted versions which attempt to fix it also fail since, well, /boot is full.
                                                                      – Justin Case
                                                                      Feb 8 '17 at 18:36












                                                                    • Well, there are two similar problems: a) where the system warns that your disk is getting full, but apt-get has enough space to go on, and b), where apt-get fails because the disk is too full. That's the other post.
                                                                      – muru
                                                                      Feb 9 '17 at 4:56


















                                                                    0














                                                                    [As an AskUbuntu noob I can't comment until reputation = 50 so don't down-vote because of this.]



                                                                    My server was doing this, too. Literally none of the expected answers here worked since these require some working room on /boot for them to complete. If the boot partition is full, it will abruptly end without deleting any of the images.



                                                                    The only thing that worked for me was to review the current image, then to manually sudo rm filename for the oldest image files (each had -3.16.0-30 in their names). Once that was done, then sudo apt-get autoremove had the wiggle-room it needed to do its job. It did highlight some errors associated with that version, for example: "depmod: FATAL: could not load /boot/System.map-3.16.0-30-generic: No such file or directory" but that is to be expected.



                                                                    When finished, the df returned a 42% in use for /boot to indicate that it's healthy again.






                                                                    share|improve this answer





















                                                                    • The post you're looking for is askubuntu.com/questions/171209/…
                                                                      – muru
                                                                      Feb 8 '17 at 2:02










                                                                    • @muru Well, yes... I would suggest that the original poster would need this advice, too. Once /boot is full, these scripted versions which attempt to fix it also fail since, well, /boot is full.
                                                                      – Justin Case
                                                                      Feb 8 '17 at 18:36












                                                                    • Well, there are two similar problems: a) where the system warns that your disk is getting full, but apt-get has enough space to go on, and b), where apt-get fails because the disk is too full. That's the other post.
                                                                      – muru
                                                                      Feb 9 '17 at 4:56
















                                                                    0












                                                                    0








                                                                    0






                                                                    [As an AskUbuntu noob I can't comment until reputation = 50 so don't down-vote because of this.]



                                                                    My server was doing this, too. Literally none of the expected answers here worked since these require some working room on /boot for them to complete. If the boot partition is full, it will abruptly end without deleting any of the images.



                                                                    The only thing that worked for me was to review the current image, then to manually sudo rm filename for the oldest image files (each had -3.16.0-30 in their names). Once that was done, then sudo apt-get autoremove had the wiggle-room it needed to do its job. It did highlight some errors associated with that version, for example: "depmod: FATAL: could not load /boot/System.map-3.16.0-30-generic: No such file or directory" but that is to be expected.



                                                                    When finished, the df returned a 42% in use for /boot to indicate that it's healthy again.






                                                                    share|improve this answer












                                                                    [As an AskUbuntu noob I can't comment until reputation = 50 so don't down-vote because of this.]



                                                                    My server was doing this, too. Literally none of the expected answers here worked since these require some working room on /boot for them to complete. If the boot partition is full, it will abruptly end without deleting any of the images.



                                                                    The only thing that worked for me was to review the current image, then to manually sudo rm filename for the oldest image files (each had -3.16.0-30 in their names). Once that was done, then sudo apt-get autoremove had the wiggle-room it needed to do its job. It did highlight some errors associated with that version, for example: "depmod: FATAL: could not load /boot/System.map-3.16.0-30-generic: No such file or directory" but that is to be expected.



                                                                    When finished, the df returned a 42% in use for /boot to indicate that it's healthy again.







                                                                    share|improve this answer












                                                                    share|improve this answer



                                                                    share|improve this answer










                                                                    answered Feb 8 '17 at 0:44









                                                                    Justin Case

                                                                    464




                                                                    464












                                                                    • The post you're looking for is askubuntu.com/questions/171209/…
                                                                      – muru
                                                                      Feb 8 '17 at 2:02










                                                                    • @muru Well, yes... I would suggest that the original poster would need this advice, too. Once /boot is full, these scripted versions which attempt to fix it also fail since, well, /boot is full.
                                                                      – Justin Case
                                                                      Feb 8 '17 at 18:36












                                                                    • Well, there are two similar problems: a) where the system warns that your disk is getting full, but apt-get has enough space to go on, and b), where apt-get fails because the disk is too full. That's the other post.
                                                                      – muru
                                                                      Feb 9 '17 at 4:56




















                                                                    • The post you're looking for is askubuntu.com/questions/171209/…
                                                                      – muru
                                                                      Feb 8 '17 at 2:02










                                                                    • @muru Well, yes... I would suggest that the original poster would need this advice, too. Once /boot is full, these scripted versions which attempt to fix it also fail since, well, /boot is full.
                                                                      – Justin Case
                                                                      Feb 8 '17 at 18:36












                                                                    • Well, there are two similar problems: a) where the system warns that your disk is getting full, but apt-get has enough space to go on, and b), where apt-get fails because the disk is too full. That's the other post.
                                                                      – muru
                                                                      Feb 9 '17 at 4:56


















                                                                    The post you're looking for is askubuntu.com/questions/171209/…
                                                                    – muru
                                                                    Feb 8 '17 at 2:02




                                                                    The post you're looking for is askubuntu.com/questions/171209/…
                                                                    – muru
                                                                    Feb 8 '17 at 2:02












                                                                    @muru Well, yes... I would suggest that the original poster would need this advice, too. Once /boot is full, these scripted versions which attempt to fix it also fail since, well, /boot is full.
                                                                    – Justin Case
                                                                    Feb 8 '17 at 18:36






                                                                    @muru Well, yes... I would suggest that the original poster would need this advice, too. Once /boot is full, these scripted versions which attempt to fix it also fail since, well, /boot is full.
                                                                    – Justin Case
                                                                    Feb 8 '17 at 18:36














                                                                    Well, there are two similar problems: a) where the system warns that your disk is getting full, but apt-get has enough space to go on, and b), where apt-get fails because the disk is too full. That's the other post.
                                                                    – muru
                                                                    Feb 9 '17 at 4:56






                                                                    Well, there are two similar problems: a) where the system warns that your disk is getting full, but apt-get has enough space to go on, and b), where apt-get fails because the disk is too full. That's the other post.
                                                                    – muru
                                                                    Feb 9 '17 at 4:56













                                                                    0














                                                                    I wrote this bash script to selective purge old kernels all at once:



                                                                    rm kernels real size



                                                                    All the bash code and instructions are included in the link.






                                                                    share|improve this answer


























                                                                      0














                                                                      I wrote this bash script to selective purge old kernels all at once:



                                                                      rm kernels real size



                                                                      All the bash code and instructions are included in the link.






                                                                      share|improve this answer
























                                                                        0












                                                                        0








                                                                        0






                                                                        I wrote this bash script to selective purge old kernels all at once:



                                                                        rm kernels real size



                                                                        All the bash code and instructions are included in the link.






                                                                        share|improve this answer












                                                                        I wrote this bash script to selective purge old kernels all at once:



                                                                        rm kernels real size



                                                                        All the bash code and instructions are included in the link.







                                                                        share|improve this answer












                                                                        share|improve this answer



                                                                        share|improve this answer










                                                                        answered Jul 30 '17 at 23:46









                                                                        WinEunuuchs2Unix

                                                                        44k1077166




                                                                        44k1077166























                                                                            0














                                                                            I show that still in 2017 this question has new comments and answers but missing one answer that I think is very useful here:



                                                                            Ubuntu as a desktop OS of simple everyday usage has no reason to be installed with separate boot partition and something like this will NOT offer something to a "common user"... So a solution is a fresh install without boot partition and this way you will never have such a problem



                                                                            PS: My answer can be deleted or added in the accepted answer... (I think it will help some people this way)






                                                                            share|improve this answer


























                                                                              0














                                                                              I show that still in 2017 this question has new comments and answers but missing one answer that I think is very useful here:



                                                                              Ubuntu as a desktop OS of simple everyday usage has no reason to be installed with separate boot partition and something like this will NOT offer something to a "common user"... So a solution is a fresh install without boot partition and this way you will never have such a problem



                                                                              PS: My answer can be deleted or added in the accepted answer... (I think it will help some people this way)






                                                                              share|improve this answer
























                                                                                0












                                                                                0








                                                                                0






                                                                                I show that still in 2017 this question has new comments and answers but missing one answer that I think is very useful here:



                                                                                Ubuntu as a desktop OS of simple everyday usage has no reason to be installed with separate boot partition and something like this will NOT offer something to a "common user"... So a solution is a fresh install without boot partition and this way you will never have such a problem



                                                                                PS: My answer can be deleted or added in the accepted answer... (I think it will help some people this way)






                                                                                share|improve this answer












                                                                                I show that still in 2017 this question has new comments and answers but missing one answer that I think is very useful here:



                                                                                Ubuntu as a desktop OS of simple everyday usage has no reason to be installed with separate boot partition and something like this will NOT offer something to a "common user"... So a solution is a fresh install without boot partition and this way you will never have such a problem



                                                                                PS: My answer can be deleted or added in the accepted answer... (I think it will help some people this way)







                                                                                share|improve this answer












                                                                                share|improve this answer



                                                                                share|improve this answer










                                                                                answered Aug 20 '17 at 6:58









                                                                                koleygr

                                                                                14210




                                                                                14210























                                                                                    0














                                                                                    Save this script as /usr/local/bin/remove_kernels.sh (remember to give execute permissions sudo chmod 755 /usr/local/bin/remove_kernels.sh ):



                                                                                    #!/bin/sh
                                                                                    if test $(id -u) != 0; then
                                                                                    echo Error: You must be root to run this script!
                                                                                    exit 1
                                                                                    fi
                                                                                    apt purge $( dpkg --list | grep -P -o "linux-image-dS+" | grep -v $(uname -r | grep -P -o ".+d") )
                                                                                    update-grub


                                                                                    Then to remove all old kernels just type: sudo remove_kernels.sh






                                                                                    share|improve this answer


























                                                                                      0














                                                                                      Save this script as /usr/local/bin/remove_kernels.sh (remember to give execute permissions sudo chmod 755 /usr/local/bin/remove_kernels.sh ):



                                                                                      #!/bin/sh
                                                                                      if test $(id -u) != 0; then
                                                                                      echo Error: You must be root to run this script!
                                                                                      exit 1
                                                                                      fi
                                                                                      apt purge $( dpkg --list | grep -P -o "linux-image-dS+" | grep -v $(uname -r | grep -P -o ".+d") )
                                                                                      update-grub


                                                                                      Then to remove all old kernels just type: sudo remove_kernels.sh






                                                                                      share|improve this answer
























                                                                                        0












                                                                                        0








                                                                                        0






                                                                                        Save this script as /usr/local/bin/remove_kernels.sh (remember to give execute permissions sudo chmod 755 /usr/local/bin/remove_kernels.sh ):



                                                                                        #!/bin/sh
                                                                                        if test $(id -u) != 0; then
                                                                                        echo Error: You must be root to run this script!
                                                                                        exit 1
                                                                                        fi
                                                                                        apt purge $( dpkg --list | grep -P -o "linux-image-dS+" | grep -v $(uname -r | grep -P -o ".+d") )
                                                                                        update-grub


                                                                                        Then to remove all old kernels just type: sudo remove_kernels.sh






                                                                                        share|improve this answer












                                                                                        Save this script as /usr/local/bin/remove_kernels.sh (remember to give execute permissions sudo chmod 755 /usr/local/bin/remove_kernels.sh ):



                                                                                        #!/bin/sh
                                                                                        if test $(id -u) != 0; then
                                                                                        echo Error: You must be root to run this script!
                                                                                        exit 1
                                                                                        fi
                                                                                        apt purge $( dpkg --list | grep -P -o "linux-image-dS+" | grep -v $(uname -r | grep -P -o ".+d") )
                                                                                        update-grub


                                                                                        Then to remove all old kernels just type: sudo remove_kernels.sh







                                                                                        share|improve this answer












                                                                                        share|improve this answer



                                                                                        share|improve this answer










                                                                                        answered Oct 8 '18 at 16:27









                                                                                        Anthony Kelly

                                                                                        113




                                                                                        113























                                                                                            -1














                                                                                            If you cannot remove more unused files and if you have other partition with/or free space on same device, you can resize of /boot partition by parted/gparted. (It is included on installation media, too.)



                                                                                            Warning: Resizing of partition is dangerous operation, save your important data on other media before doing it!






                                                                                            share|improve this answer





















                                                                                            • Most sufferers of small separate /boot partitions chose 'whole disk encryption' upon install, which requires LVM. This solution will seems to cause more problems than it solves for those users.
                                                                                              – user535733
                                                                                              Feb 2 '17 at 14:40
















                                                                                            -1














                                                                                            If you cannot remove more unused files and if you have other partition with/or free space on same device, you can resize of /boot partition by parted/gparted. (It is included on installation media, too.)



                                                                                            Warning: Resizing of partition is dangerous operation, save your important data on other media before doing it!






                                                                                            share|improve this answer





















                                                                                            • Most sufferers of small separate /boot partitions chose 'whole disk encryption' upon install, which requires LVM. This solution will seems to cause more problems than it solves for those users.
                                                                                              – user535733
                                                                                              Feb 2 '17 at 14:40














                                                                                            -1












                                                                                            -1








                                                                                            -1






                                                                                            If you cannot remove more unused files and if you have other partition with/or free space on same device, you can resize of /boot partition by parted/gparted. (It is included on installation media, too.)



                                                                                            Warning: Resizing of partition is dangerous operation, save your important data on other media before doing it!






                                                                                            share|improve this answer












                                                                                            If you cannot remove more unused files and if you have other partition with/or free space on same device, you can resize of /boot partition by parted/gparted. (It is included on installation media, too.)



                                                                                            Warning: Resizing of partition is dangerous operation, save your important data on other media before doing it!







                                                                                            share|improve this answer












                                                                                            share|improve this answer



                                                                                            share|improve this answer










                                                                                            answered Jan 2 '15 at 21:42









                                                                                            Rudolf Dovičín

                                                                                            573




                                                                                            573












                                                                                            • Most sufferers of small separate /boot partitions chose 'whole disk encryption' upon install, which requires LVM. This solution will seems to cause more problems than it solves for those users.
                                                                                              – user535733
                                                                                              Feb 2 '17 at 14:40


















                                                                                            • Most sufferers of small separate /boot partitions chose 'whole disk encryption' upon install, which requires LVM. This solution will seems to cause more problems than it solves for those users.
                                                                                              – user535733
                                                                                              Feb 2 '17 at 14:40
















                                                                                            Most sufferers of small separate /boot partitions chose 'whole disk encryption' upon install, which requires LVM. This solution will seems to cause more problems than it solves for those users.
                                                                                            – user535733
                                                                                            Feb 2 '17 at 14:40




                                                                                            Most sufferers of small separate /boot partitions chose 'whole disk encryption' upon install, which requires LVM. This solution will seems to cause more problems than it solves for those users.
                                                                                            – user535733
                                                                                            Feb 2 '17 at 14:40





                                                                                            protected by Community May 4 '14 at 15:22



                                                                                            Thank you for your interest in this question.
                                                                                            Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



                                                                                            Would you like to answer one of these unanswered questions instead?



                                                                                            Popular posts from this blog

                                                                                            數位音樂下載

                                                                                            When can things happen in Etherscan, such as the picture below?

                                                                                            格利澤436b