Over time, as you update yourLinux kernel, old kernel versions accumulate and take up space.

What Is Boot Partition on Linux?

Mainly, it contains the kernel, the initrd, and thebootloader.

The main page of the Homepage homelab dashboard with services running on it.

The boot partition is usually mounted at /boot/.

The boot partition is helpful for runningmultiple operating systems on a single machineor system.

It allows each operating system to have its own bootloader.

A Linux Terminal.

Hannah Stryker / How-To Geek

You should clean your boot partition periodically to remove old and unused kernels.

These old kernels take up a lot of space and cause problems whenupdating the system.

This can also prevent further updates and even slow down the boot process.

showing boot partition space available

Some old kernels may contain bugs or vulnerabilities that can expose your Linux system to threats.

Do not delete thecurrent kernelor the files needed by the bootloader.

Otherwise, your system will not boot.

command that automatically remove unused packages and files

Before you attempt to modify the boot partition, back up your data and check disk health.

Check Boot Partition Usage

Before freeing up space, you must check the boot partition usage.

This will give you an idea of how low your system is on boot partition space.

uname command to check running kernel

It will also help to identify the space that boot partition needs.

To check the boot partition usage you’re free to run thedf -hcommand.

These accumulatedolder kernel versionscan consume valuable disk space in the boot partition.

command to list boot directory files and kernels

you could use theapt autoremovecommand to automatically remove the unused kernels.

This command also removes the unused associated dependencies.

You should press Y to proceed.

command that list all limux kernel installed in boot partition

Theautoremovemethod will only work if you have some space left in the /boot partition.

If your /boot partition is full, you have to manually remove some old kernels first.

it’s possible for you to find the currently running kernel version using theunamecommand.

command that removes kernel name image-5.15.0-25-generic

you could use thedpkgcommandto list all the installed packages that have “linux-image” in their package names.

It specifically targets packages related to the Linux kernel, including different kernel versions and related modules.

The ones labeled with the status “ii” are installed.

command to remove the kernel inux-image-6.2.0-26-generic

Those marked as “rc” have been removed but still have residual configuration files.

The kernels 5.15.0-25-generic and 6.2.0-26-generic are the older kernel versions.

The newest version is 6.2.0-32-generic, and the one before that is 6.2.0-31-generic.

packages not removed after using sudo auto remove

You may have noticed that thels -l/bootcommand doesnt display the kernels 5.15.0-25-generic and 6.2.0-26-generic.

This is because both these kernels are already deleted and labeled as “rc” by thedpkgcommand.

It’s recommended to keep at least one or two previous kernels as backups.

purge command to remove kernel permanetly

you could use the previous kernel to boot your system if the latest one fails.

It also avoids data loss or any need to reinstall the operating system.

The kernel 6.2.0-32-generic is the current one, so we don’t want to delete it.

removing the linux-image-6.2.0-26-generic using purge command

Here, it’s possible for you to specify the kernel you want to remove.

Confirm the action by pressing Y.

This is because theapt removecommand is more cautious about not removing packages that might be required by other packages.

Update GRUB bootloader

you might use thedpkg purgecommand to completely remove the package and its related configuration files from your system.

When you rundpkg –purge, it doesn’t check for dependencies.

Now the package will no longer appear in thedpkg -llist.

command to install synaptic

you’ve got the option to also use thermcommandto remove the old kernels from the boot partition.

you’re free to also specify multiple naming patterns to delete all of them at once.

The comma (,) in between the command specifies multiple values within a brace expansion.

Launch Synaptic from Application Menu

It requires typing complex commands and knowing the exact names of the kernel packages.

you might easily remove old kernels using a GUI-based package manager tool called Synaptic.

Using Synaptic, it’s possible for you to selectively remove the older unused kernels.

Finding unused Kernel and modules from section window

You should always keep the current kernel and the previous one as a backup for the system.

This will improve your system performance andsave disk space.

First, you oughta install Synaptic on your system.

search for unused kernel manually

In the Synaptic window, hit the “Sections” button.

Now select “Kernel and Modules”.

This will display all theinstalled kernel versionson your system.

Mart any old kernel for removal

you’re free to also use the “Search” option to find older kernels.

jot down linux-image and click “Search”.

This will display all the installed kernel packages on your system partitions.

deleting selected kernel by clicking the apply button

it’s possible for you to run theuname -rcommand in a terminal window to find the current kernel version.

Now, tap on “Apply” to start deleting the selected kernel version.

You will see a summary of the actions about to be taken.

Summary of the processes which are going to be done.

Confirm the removal of the selected packages by clicking the “Apply” button.

The selected kernel package files and their associated dependencies will be deleted.

It will free up some disk space on the boot partition.

unused kernel started for deleting

But removing old kernels is not a permanent solution.

Your Ubuntu system boot partition could still fill up thanks to the packages you install.

you’ve got the option to easily resize the boot partition using theGParted toolon Ubuntu.

GParted ISO file download page

Before resizing your boot partition, confirm toback up your important data.

Begin bycreating a bootable USB drivecontaining the GParted tool ISO file.

GParted is a portable version of the Ubuntu system that can manage partitions.

Select optical as first drive to boot GParted

Firstdownload the GParted ISOfile required for creating the bootable drive.

you might enter the BIOS after restarting the system.

you’re gonna wanna press a specific key toaccess the BIOS mode on your system.

Select the Ubuntu VDI in GParted SATA settings

The key may be different depending on the system model and manufacturer.

you might also check your system manual or on-screen instructions for which key to press.

Change the boot order to prioritize the USB drive.

Boot GParted with default settings

Move the GParted USB drive to the top of the list or select it as the first boot rig.

you’re free to also press “Enter” to directly boot GParted from the USB drive.

This will boot your system from the USB drive or CD/DVD that contains GParted.

GParted language and keymap selection

While setting the GParted virtual machine, do not create a virtual hard disk for it.

Promoting the optical disk option to the top means setting the virtual optical drive as the first boot equipment.

The VDI file represents your Ubuntu virtual machine’s storage.

Gparted front window

The GParted window will open showing all partitions on your system.

Identify a non-system partition (/dev/sda3) and unmount it before proceeding.

This will detach the partition from file system and can be safely modified.

Unmount the non-system partition

If you see a Gray “Mount” option, it means the partition is already unmounted.

First, shrink the non-system partition to get some unallocated space.

Right-opt for non-system or root partition and select “Resize/Move”.

Resizing Non-System Partition

you’re free to also specify the size in the “New Size” field.

Click “Resize/Move” to apply the changes.

A warning message will prompt, showing that your system might fail to boot after moving the partition.

Adjust Root Partition Size

Hit “OK” to continue.

A new unallocated partition will be created right next to the boot partition.

Next, you’re able to resize the boot partition after assigning it the unallocated space.

Warning Message asking for final permission to resize partition

Right-hit the boot partition and go for the “Resize/Move” option.

Click “Resize/Move” to apply the changes.

stash your change by clicking the green checkmark icon and selecting “Apply” from the new menu.

unallocated partition

Now wait for the operation to complete.

GParted will shrink the dev/sda3 partition by 500 MiB and allocate this to the boot partition.

When the boot partition is resized, a completed operation message will appear.

Resizing Boot Partition

you’ve got the option to verify the new boot partition size from GParted.

Reboot your Ubuntu system.

ensure you choose the default Ubuntu system as your boot option.

apply the changes

For virtual machines, boot from the default Ubuntu virtual machine.

After rebooting, trigger the command df -h to confirm the new size of the boot partition.

In our example, the boot partition has been expanded from 500 MiB to 1011 MiB.

boot partition resizing start

Active monitoring includes keeping your system up to date, regularly purging old kernels, andmonitoring disk space usage.

Like the GParted tool, you’re able to also use thefdiskcommandto actively manage Linux partitions.

Thefdiskcommand will give you precise control over disk partitions.

Boot partition resized complete

you’re free to view existing partitions, create new ones, and set their file system types.

you’re able to also change partition attributes and manage the layout of disk drives efficiently.

Boot Partition Size Increased

Reboot Ubuntu System

verify the boot partition using df command