How To Free /boot Disk Space In Linux

By default the size of a /boot partition in Linux is not that big, 512mb or so is quite a typical default. This space is used to store different versions of the Linux kernel that you have concurrently installed at the same time.

If this space fills up you may not be able to perform a kernel upgrade in future so it is important to not let it fill and free up space in /boot.

If your server does not have its own partition for /boot then this will be less of a problem for you, as you will have the full space of the file system at your disposal, however if this space becomes full then you’ll face the same problem.

Why Multiple Kernels?

Multiple versions of the Linux kernel are installed at once by default so that you can rollback to a previous version if there are any problems. For example in the past a test server of mine had unexpectedly powered off in the middle of a kernel upgrade via yum, upon attempting to start it back up, it would kernel panic and fail to boot. I had to use a live CD, mount the disk, and modify the boot configuration to use one of the previous versions of the kernel installed in order to boot properly, and then correctly apply the update again.

The kernel is one of the few packages that does not overwrite the existing version when an update is applied, instead the whole kernel is installed again separately, mainly for this reason of allowing us to perform a rollback if required.

Manually Removing Old Kernels

To remove an older kernel, we first need to view the list of kernel versions that are currently installed. This can be done with the ‘yum list installed’ command as shown below.

[root@centos7 ~]# yum list installed | grep kernel
kernel.x86_64                          3.10.0-229.el7                  @anaconda
kernel.x86_64                          3.10.0-229.7.2.el7              @updates
kernel.x86_64                          3.10.0-229.11.1.el7             @updates
kernel.x86_64                          3.10.0-229.14.1.el7             @updates
kernel.x86_64                          3.10.0-229.20.1.el7             @updates
kernel.x86_64                          3.10.0-327.3.1.el7              @updates

In this example we have 6 different versions of the Linux kernel currently installed. Each of these has files stored within /boot.

In this case the package ‘kernel-3.10.0-229.el7.x86_64’ is the oldest version installed, so we can manually remove it as shown below.

[root@centos7 ~]# yum remove kernel-3.10.0-229.el7.x86_64
Loaded plugins: fastestmirror, langpacks
Resolving Dependencies
--> Running transaction check
---> Package kernel.x86_64 0:3.10.0-229.el7 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

 Package                                               Arch                                                  Version                                                          Repository                                                Size
 kernel                                                x86_64                                                3.10.0-229.el7                                                   @anaconda                                                131 M

Transaction Summary
Remove  1 Package

Installed size: 131 M
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Erasing    : kernel-3.10.0-229.el7.x86_64                                                                                                                                                                                              1/1
warning: file /lib/modules/3.10.0-229.el7.x86_64/modules.softdep: remove failed: No such file or directory
warning: file /lib/modules/3.10.0-229.el7.x86_64/modules.devname: remove failed: No such file or directory
  Verifying  : kernel-3.10.0-229.el7.x86_64                                                                                                                                                                                              1/1

  kernel.x86_64 0:3.10.0-229.el7


Removing the oldest kernel first is generally the best way to go, you do not want to attempt to uninstall the current version of the kernel that you are running. You can view your current kernel version with the ‘uname -r’ command as shown below.

[root@centos7 ~]# uname -r

We still have 5 different versions of the Linux kernel installed which is plenty, generally having at least 3 installed is good. After removing this version of the Linux kernel we freed up 10% of our 500mb /boot partition.

Specify The Amount Of Concurrently Installed Kernels

We can specify how many Linux kernels are allowed to be installed at any one time. By default the amount of Linux kernels that can be installed at the same time is 5. If you already have 5 different versions of the Linux kernel installed and you perform a ‘yum update’ and install a newer kernel, the oldest kernel will be uninstalled to make room for the newest one.

This is done in the /etc/yum.conf file as shown below.


In this particular example this was set to 6, as we had 6 kernels installed at once before the oldest was manually removed. You can edit this file to something else such as 3, it will not automatically remove the oldest kernels until a newer kernel is available for update and is installed. At this point yum will check the installation limit for the kernel and remove the oldest first.

You can optionally make use of ‘package-cleanup’ and remove a specified number of older kernels, as shown below.

package-cleanup --oldkernels --assumeyes --count=3

After running this command, yum will uninstall the oldest kernels first and keep only the 3 most recent installed. If package-cleanup is not available, you can first install the ‘yum-utils’ package which provides it.


Low /boot space in Linux is typically mostly used by having multiple kernel versions installed concurrently, we can uninstall older kernel versions that are no longer required to clear up and reduce the disk space. The yum configuration can also be modified so that only a specified number of kernels are installed at any one time which can help prevent /boot filling up automatically.

Without sufficient free space in /boot newer versions of the kernel will not be able to install correctly, so it is important to not let it fill up.

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>