Linux

Removing Old Ubuntu Kernels: Free Up Space in /boot

Learn how to safely remove unused Linux kernels in Ubuntu via the terminal. Free up gigabytes in your /boot partition and resolve update errors.

Updated at April 4, 2026
5-15 min
Easy
FixPedia Team
Применимо к:Ubuntu 20.04 LTSUbuntu 22.04 LTSUbuntu 24.04 LTS

Why Remove Old Linux Kernels

Every time Ubuntu updates, it retains the previous Linux kernel version as a fallback. This is useful for rolling back after a failure, but over time, the /boot partition fills up. As a result, you may encounter errors when installing new updates, experience delayed GRUB menu loading, and run out of space for initramfs files. Regularly cleaning up outdated versions resolves these issues and restores system stability.

Prerequisites and Preparation

Before you begin, ensure you have terminal access and sudo privileges. The process does not require installing additional software, as Ubuntu's built-in utilities are fully capable of handling the task.

⚠️ Important: Never remove the kernel currently in use, and always keep at least one fallback version.

Step 1: Check Current and Installed Versions

Open a terminal (Ctrl+Alt+T) and check which kernel your system is currently running:

uname -r

Note the output. Next, retrieve a complete list of all installed kernel packages to assess the scope of the task:

dpkg --list | grep linux-image

The command will display lines with an ii status (installed). Any versions that differ from the uname -r output are candidates for removal.

Step 2: Automated System Cleanup

Ubuntu can automatically track outdated dependencies. Try running the built-in cleanup utility with the option to completely remove configuration files:

sudo apt update
sudo apt autoremove --purge

The package manager will analyze dependencies, display a list of packages marked for removal, and prompt for confirmation. Type Y and press Enter. If the system detects outdated kernels, they will be removed along with their associated boot files.

Step 3: Manually Remove Specific Versions

If autoremove didn't suggest removing old kernels (which can happen if they were installed manually), remove them directly. Use the exact package name from the dpkg output:

sudo apt remove --purge linux-image-5.15.0-XX-generic linux-modules-5.15.0-XX-generic

💡 Tip: Remove both the linux-image and linux-modules packages in a single command so the package manager can correctly recalculate dependencies.

After manual removal, run:

sudo apt autoremove --purge

This will clean up any remaining orphaned files and dependencies.

Step 4: Update the Bootloader and Verify Results

Even after removing kernel files, the GRUB menu may still contain old entries. Update the bootloader configuration:

sudo update-grub

Check how much space has been freed up on the boot partition:

df -h /boot

If the value in the Use% column has dropped significantly or /boot is no longer at 100% capacity, the task is complete. Reboot your machine to verify that the system boots successfully on the retained kernel.

Potential Issues During Cleanup

"dpkg: error processing package" Error This usually occurs if a previous update was interrupted. Restore the package manager state before proceeding with removal:

sudo dpkg --configure -a
sudo apt install -f

"Package not found" During Manual Removal Ensure you are copying the full package name from the dpkg --list output. In newer Ubuntu versions, package names may include suffixes like -oem, -hwe, or -generic. Only remove packages that do not match your currently running kernel.

GRUB Does Not Update Automatically In certain configurations with a dedicated /boot partition or when using grub-customizer, the update-grub command might require superuser privileges and an explicit output path. If the standard command fails, use sudo grub-mkconfig -o /boot/grub/grub.cfg.

F.A.Q.

Is it safe to remove kernels if the system is running stably?
Will configuration files be removed during cleanup?
Why doesn't `apt autoremove` sometimes remove old kernels?

Hints

Check Current and Installed Versions
Automatic Cleanup via Package Manager
Manually Remove Specific Kernel Packages
Update Bootloader and Check Free Space

Did this article help you solve the problem?

FixPedia

Free encyclopedia for fixing errors. Step-by-step guides for Windows, Linux, macOS and more.

© 2026 FixPedia. All materials are available for free.

Made with for the community