• 4
name Punditsdkoslkdosdkoskdo

How do I Free Up more Space in /boots?

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
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.


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]+//')")
  • 0
Reply Report


dpkg -l linux-image*
uname -r
sudo apt-get remove linux-image-2.6.32-{21,37,38,39,40,41,42,43,44}-server
sudo apt-get autoremove

This morning, I noticed New Relic that the /boot disk was almost full on several of our servers. It turns out that when the old kernel images are left on the disk after a kernel update. The solution is to delete old kernels that we don't need anymore.

1. Find packages to delete.

You can safely delete all but the latest package that matches the pattern linux-image-2.6.32-[0-9][0-9]-server. Leave linux-image-2.6.32-45-server on your system because you will need it to reboot!

$ dpkg -l linux-image*
| Status=Not/Inst/Cfg-files/Unpacked/Failed-cfg/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                                          Version                                       Description
un  linux-image                                   <none>                                        (no description available)
un  linux-image-2.6                               <none>                                        (no description available)
ii  linux-image-2.6.32-21-server                  2.6.32-21.32                                  Linux kernel image for version 2.6.32 on x86_64
ii  linux-image-2.6.32-37-server                  2.6.32-37.81                                  Linux kernel image for version 2.6.32 on x86_64
ii  linux-image-2.6.32-38-server                  2.6.32-38.83                                  Linux kernel image for version 2.6.32 on x86_64
ii  linux-image-2.6.32-39-server                  2.6.32-39.86                                  Linux kernel image for version 2.6.32 on x86_64
ii  linux-image-2.6.32-40-server                  2.6.32-40.87                                  Linux kernel image for version 2.6.32 on x86_64
ii  linux-image-2.6.32-41-server                  2.6.32-41.91                                  Linux kernel image for version 2.6.32 on x86_64
ii  linux-image-2.6.32-42-server                  2.6.32-42.96                                  Linux kernel image for version 2.6.32 on x86_64
ii  linux-image-2.6.32-43-server                  2.6.32-43.97                                  Linux kernel image for version 2.6.32 on x86_64
ii  linux-image-2.6.32-44-server                  2.6.32-44.98                                  Linux kernel image for version 2.6.32 on x86_64
ii  linux-image-2.6.32-45-server                  2.6.32-45.104                                 Linux kernel image for version 2.6.32 on x86_64
ii  linux-image-server                                                    Linux kernel image on Server Equipment.

2. Identify the kernel version you are currenlty running

DON'T delete this kernel image! And if it's not the latest, don't delete the latest one either.

$ uname -r

3. Delete the old kernels.

Removing the old kernels is the same as removing any other package. I'm using shell expansion for the version numbers to save typing. It will prompt you with a list of packages that will be removed, so you can double check the list before continuing.

sudo apt-get remove linux-image-2.6.32-{21,37,38,39,40,41,42,43,44}-server

4. Remove dependencies.

There are some dependencies left on the system after removing the old kernels. Fortunately, you can easily clean these up, too.

sudo apt-get autoremove
  • 0
Reply Report