Cleaning Gentoo Kernels
March 7, 2026
Over time, /boot can fill up with old kernel files, especially on systems with small boot partitions. Each kernel installation leaves behind vmlinuz, System.map, config, initramfs, and module files. The eclean-kernel tool safely removes old kernels while preserving the ones you need.
Installation
Install the eclean-kernel package:
emerge -av app-admin/eclean-kernel
Backup Boot First
Before cleaning kernels, it's wise to maintain a backup of /boot. This cron job syncs /boot to /boot2 every 15 minutes:
crontab -e
*/15 * * * * mount /boot > /dev/null 2>&1; rsync -arq /boot/ /boot2/
This ensures you can recover if something goes wrong during kernel cleanup.
List Available Kernels
Before removing anything, see what kernels are installed:
eclean-kernel --list-kernels
5.15.11-gentoo-2021-12-28-0944 [5.15.11-gentoo-2021-12-28-0944]
- systemmap: /boot/System.map-5.15.11-gentoo-2021-12-28-0944
- config: /boot/config-5.15.11-gentoo-2021-12-28-0944
- vmlinuz: /boot/vmlinuz-5.15.11-gentoo-2021-12-28-0944
- modules: /lib/modules/5.15.11-gentoo-2021-12-28-0944
- build: /usr/src/linux-5.15.11-gentoo
- last modified: 2021-12-28 15:59:43
5.15.11-gentoo-2021-12-28-0944 [CIFS]
- systemmap: /boot/System.map-5.15.11-gentoo-2021-12-28-0944
- config: /boot/config-5.15.11-gentoo-2021-12-28-0944
- vmlinuz: /boot/initramfs-5.15.11-gentoo-2021-12-28-0944.img
- last modified: 2021-12-28 15:59:43
5.10.76-gentoo-r1-2021-12-19-2051 [CIFS]
- systemmap: /boot/System.map-5.10.76-gentoo-r1-2021-12-19-2051
- config: /boot/config-5.10.76-gentoo-r1-2021-12-19-2051
- vmlinuz: /boot/initramfs-5.10.76-gentoo-r1-2021-12-19-2051.img
- last modified: 2021-12-20 03:09:54
5.10.76-gentoo-r1-2021-12-19-2051 [5.10.76-gentoo-r1-2021-12-19-2051]
- systemmap: /boot/System.map-5.10.76-gentoo-r1-2021-12-19-2051
- config: /boot/config-5.10.76-gentoo-r1-2021-12-19-2051
- vmlinuz: /boot/vmlinuz-5.10.76-gentoo-r1-2021-12-19-2051
- modules: /lib/modules/5.10.76-gentoo-r1-2021-12-19-2051
- build: /usr/src/linux-5.10.76-gentoo-r1
- last modified: 2021-12-20 03:09:54
This shows all kernel-related files, their locations, and when they were last modified.
Clean Old Kernels
Keep only the most recent kernel and prompt before deletion:
eclean-kernel --num 1 --ask
The --num 1 flag keeps only the newest kernel, and --ask prompts for confirmation before removing files. This protects you from accidentally removing the kernel you're currently running.
Best Practices
- Always keep at least 2 kernels (
--num 2) so you have a fallback if the newest kernel has issues - Test boot after cleaning to ensure grub configuration is still correct
- Run after kernel updates to prevent
/bootfrom filling up - Verify running kernel with
uname -rbefore cleaning to understand which will be kept