LinuxCommandLibrary

eclean-kernel

Remove old kernel versions

TLDR

List all kernel files

$ sudo eclean-kernel [[-l|--list-kernels]]
copy

Remove all kernels except for the two newest ones
$ sudo eclean-kernel [[-n|--num]] 2
copy

Remove all kernels except for the two newest ones and ask before removal
$ sudo eclean-kernel [[-a|--all]] [[-n|--num]] 2
copy

SYNOPSIS

eclean-kernel [options]

PARAMETERS

--all
    Removes all kernel sources, except the currently running one.

--ask
    Prompts the user for confirmation before removing each kernel source.

--dry-run or -n
    Shows what eclean-kernel would do without actually removing anything.

--package
    Clean also orphaned kernel module packages.

--config-file
    Specify the location of the configuration file. Defaults to /etc/eclean-kernel.conf

--exclude
    A comma separated list of kernel versions to exclude from cleaning

--only-kernels
    Operate only on this comma separated list of kernels

--help
    Displays the help message.

--version
    Displays the version information.

--verbose or -v
    Be more verbose, printing kernel versions to be cleaned.

DESCRIPTION

The eclean-kernel command is a utility designed to remove old kernel source code and modules from your system. It's primarily used on systems managed with Portage (Gentoo's package management system). It examines the /usr/src/linux directory and any installed kernel modules, compares them against currently installed kernels, and removes any versions that are no longer needed. This frees up disk space and reduces clutter. It's especially useful after upgrading your kernel. eclean-kernel ensures that your system only retains the necessary files for booting and running your current kernel(s). This cleanup helps maintain system stability and efficiency by preventing the accumulation of outdated and potentially conflicting kernel files. The command uses the eselect kernel tool to identify the active kernels.

CAVEATS

This command requires root privileges to function correctly. Be cautious when using the --all option. Ensure you have a working kernel before using eclean-kernel. Incorrect usage can lead to an unbootable system. It's highly recommended to run eclean-kernel --dry-run first.

CONFIGURATION

The behavior of eclean-kernel can be customized through the /etc/eclean-kernel.conf file. This file allows you to specify settings such as the number of kernels to keep, directories to exclude from cleaning, and other options. Consult the configuration file for detailed settings.

EXAMPLE USAGE

To perform a dry run cleaning, use: eclean-kernel --dry-run
To remove all kernels except the running one, prompting for confirmation: eclean-kernel --all --ask
To clean orphaned packages: eclean-kernel --package

HISTORY

eclean-kernel was created as a tool to simplify the process of removing old kernel sources and modules, a common task on Gentoo Linux systems due to its source-based nature. As Gentoo users frequently compile and install new kernels, managing the resulting files became cumbersome, leading to the development of this utility. It has been actively maintained and improved over time.

SEE ALSO

eselect(1), emerge(1)

Copied to clipboard