Tired of cluttered kernel lists eating up your precious disk space? Learn how to safely clean up old kernels using the Linux Mint terminal.
Why Remove Old Kernels?
Kernel updates are essential for security and hardware support, but they can accumulate over time, consuming valuable space in your /boot
partition. Keeping 2-3 recent kernels is sufficient - your current one plus a backup in case of issues.
🛑 Before You Begin: Safety First
Always keep at least 2 kernels - never remove your currently running kernel. Check your current kernel with:
bash
uname -r
Method 1: The Automatic Cleanup
Using apt autoremove (Safest)
bash
sudo apt autoremove
sudo apt autoclean
This removes packages that are no longer needed, including some old kernels.
Method 2: Manual Removal (Most Control)
Step 1: Identify Installed Kernels
bash
dpkg --list | grep -E 'linux-image|linux-headers' | grep -v $(uname -r)
Step 2: Remove Specific Kernels
bash
# Example: Remove specific kernel versions
sudo apt remove linux-image-5.15.0-76-generic linux-headers-5.15.0-76
Step 3: Clean Up
bash
sudo apt autoremove
sudo apt autoclean
Method 3: Using purge-old-kernels
Install and Use:
bash
sudo apt install byobu
sudo purge-old-kernels
Remove when done:
bash
sudo apt remove byobu pastebinit run-one tmux python3-newt libutempter0
sudo apt autoremove
📊 Checking Your Results
Verify boot space:
bash
df -h /boot/
List remaining kernels:
bash
ls /boot/ | grep vmlinuz
💡 Pro Tips
Update Manager vs Actual Installation: Update Manager shows available updates, not necessarily what's installed. Don't worry if you still see old kernels listed there.
Package Status Codes:
ii
= Installedrc
= Removed but config files remainiU
= Will be installed
Always reboot after kernel changes to ensure stability
🔄 When to Clean Kernels
When
/boot
partition is nearly fullAfter major system updates
Periodically (every few months)
❌ What NOT to Do
Never remove your current running kernel
Don't use
rm
on files in/boot/
directlyAvoid keeping only one kernel
Troubleshooting
If you encounter "Could not get lock" errors, wait for automatic updates to complete or use:
bash
sudo killall apt apt-get
sudo rm /var/lib/apt/lists/lock
sudo rm /var/cache/apt/archives/lock
Final Thoughts
Regular kernel maintenance is like digital housekeeping - it keeps your system lean and efficient. With these terminal commands, you can confidently manage your kernels without GUI tools.
Remember: A clean system is a happy system! 🐧
My Favorite Tips Using Linux
As a Linux enthusiast, I constantly seek ways to enhance my experience with this versatile operating system. Here are some of my favorite tips from two valuable resources: cleaning up Linux Mint and encrypting a USB stick.
LAPTOP SLEEVES / LAPTOP SLEEVE - 13" $36.00
https://society6.com/product/xz7_laptop-sleeve#58=428 Only! $36.00
How to Verify File Integrity
If you’ve downloaded a file and want to make sure it’s authentic and hasn’t been tampered with, you can verify its checksum. Here’s how to do it step by step on Linux Mint.