/boot Partition 100% Full on Debian/Ubuntu? How to Safely Purge Old Linux Kernels and Automate Cleanup
The Panic of the Full /boot Partition: A Sysadmin Classic
You log into a production Debian GNU/Linux or Ubuntu server to perform routine security maintenance. You run apt update && apt upgrade -y.
Halfway through the installation of a new security update, the terminal halts with a terrifying red wall of errors:
update-initramfs: Generating /boot/initrd.img-6.1.0-28-amd64
cpio: write error: No space left on device
dpkg: error processing package linux-image-6.1.0-28-amd64 (--configure):
installed linux-image-6.1.0-28-amd64 package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
linux-image-6.1.0-28-amd64
E: Sub-process /usr/bin/dpkg returned an error code (1)
You check disk allocations with df -h:
Filesystem Size Used Avail Use% Mounted on
/dev/nvme0n1p2 1.8T 120G 1.6T 7% /
/dev/nvme0n1p1 488M 488M 0 100% /boot
THE 100% FULL /BOOT RECURSIVE DPKG DEADLOCK
- /boot Partition is 100.0% Full (0 Bytes Available)
- APT Attempts Kernel Upgrade: Spawns
update-initramfs - Kernel writes 20MB of new initrd → DISK FULL ERROR! (Crash!)
- DPKG enters “Half-Installed / Broken” State!
- Cannot run
apt install→ Blocked by broken package! - Cannot run
apt remove→ Blocked because post-removal scripts fail! - Cannot run
apt -f install→ Tries to finish initramfs and crashes again!
Your root filesystem has 1.6 Terabytes of free space, but because /boot was provisioned on its own dedicated 500MB partition during installation, your entire package management system is locked in a recursive dead-end.
If the server reboots right now, it risks dropping into a Grub rescue prompt or failing to initialize hardware because the active kernel’s initramfs was truncated.
Through our managed hosting and proactive maintenance services, we handle these partition deadlocks with zero downtime and configure automated safeguards to ensure /boot never chokes again.
The Anatomy of /boot: Why Kernel Files Accumulate
To safely resolve the deadlock, you must understand what files live inside /boot and how much space each kernel version consumes:
CONTENTS OF A SINGLE LINUX KERNEL VERSION
- Single Kernel Suite: linux-image-6.1.0-25-amd64 (~90MB Total) vmlinuz-6.1.0-25-amd64 (~8MB - Compressed Linux Kernel) initrd.img-6.1.0-25-amd64 (~65MB - Compressed Initial RAM Disk)
- System.map-6.1.0-25-amd64 (~6MB - Kernel Symbol Lookup Table) config-6.1.0-25-amd64 (~260KB - Kernel Build Options)
When cloud providers or installers partition bare-metal drives, they routinely assign 512MB to /boot. Because each kernel suite consumes approximately 80MB to 95MB:
- Kernel 1 (Original OS Install): 85MB
- Kernel 2 (First Security Patch): 85MB
- Kernel 3 (Quarterly Update): 85MB
- Kernel 4 (Emergency CVE Fix): 85MB
- Kernel 5 (Current Running Kernel): 85MB
- Kernel 6 (New Pending Kernel): Fails to write! Partition reaches 100%!
The Safe 5-Step Recovery Procedure: Breaking the DPKG Lock
Never run rm -rf /boot/*! Doing so will delete your currently running kernel and bootloader configuration, converting a minor package manager hiccup into an unbootable bare-metal disaster.
Follow this deterministic recovery sequence:
Step 1: Identify Your Current Running Kernel
Before removing anything, verify which kernel is currently loaded into RAM:
# Check the exact active running kernel version
uname -r
Output:
6.1.0-25-amd64
CRITICAL RULE: You must NEVER delete or remove the kernel version printed by uname -r.
Step 2: List All Installed Kernel Packages
Inspect what kernel packages dpkg currently tracks:
# List all linux-image packages on the host
dpkg -l | grep -E "linux-image|linux-headers"
Look for older versions marked ii (Installed) that are older than your running version (e.g., linux-image-6.1.0-20-amd64 and linux-image-6.1.0-21-amd64).
KERNEL INVENTORY & PURGE CANDIDATES
- Kernel Version
- Status Action
- linux-image-6.1.0-20-amd64 ii (Installed) → SAFE TO PURGE (Obsolete) linux-image-6.1.0-21-amd64 ii (Installed) → SAFE TO PURGE (Obsolete) linux-image-6.1.0-25-amd64 ii (Installed) → KEEP! (Currently Running: uname -r) linux-image-6.1.0-28-amd64 iF (Half-Config) → REPAIR AFTER FREEING SPACE!
Step 3: Temporarily Evacuate Space (The Emergency Valve)
Because dpkg requires free space in /boot to even execute a removal script, we must manually move one old initrd file out of /boot into /var/tmp/:
# Create temporary quarantine directory in root partition (plenty of space)
mkdir -p /var/tmp/boot-rescue
# Move the initrd of an OBSOLETE, NON-RUNNING kernel out of /boot
mv /boot/initrd.img-6.1.0-20-amd64 /var/tmp/boot-rescue/
This single command immediately frees 65MB to 90MB of space in /boot!
Step 4: Purge Obsolete Kernels with DPKG
Now that /boot has breathing room, use dpkg --purge (NOT apt remove) to cleanly remove the obsolete package and update the package database:
# Purge the old kernel package cleanly
dpkg --purge linux-image-6.1.0-20-amd64 linux-headers-6.1.0-20-amd64
Repeat this command for any other obsolete kernels (e.g., version 21).
Step 5: Repair the Broken DPKG State and Update GRUB
Now that /boot has 150MB+ of free space, tell APT to repair the interrupted package installation:
# Complete the configuration of the pending new kernel
apt-get -f install
# Reconfigure all pending packages
dpkg --configure -a
# Ensure GRUB bootloader configuration is completely rebuilt
update-grub
Finally, inspect your disk space again:
df -h /boot
You will see /boot usage drop from 100% down to a healthy 40–50%. You can now safely delete the temporary rescue folder: rm -rf /var/tmp/boot-rescue.
Automating Kernel Hygiene: Never Suffer a Full /boot Again
Fixing a server manually is acceptable once. Allowing it to happen a second time is poor engineering. Modern Debian and Ubuntu systems feature built-in automation to purge obsolete kernels automatically.
1. Configure Automatic Kernel Pruning in APT
Verify that APT’s automated kernel cleanup is active inside /etc/apt/apt.conf.d/01autoremove-kernels:
# Display auto-removal kernel patterns
cat /etc/apt/apt.conf.d/01autoremove-kernels
This file instructs APT to protect the currently running kernel and the newest available kernel, marking all older versions as eligible for apt autoremove.
2. Configure Unattended Upgrades to Autoremove
If you use automated security patches, edit /etc/apt/apt.conf.d/50unattended-upgrades to purge obsolete kernels immediately:
// Automatically remove unused kernel packages during nightly updates
Unattended-Upgrade::Remove-Unused-Kernel-Packages "true";
// Do not require manual reboot to trigger package cleanup
Unattended-Upgrade::Remove-Unused-Dependencies "true";
3. Deploying a Systemd Safety Pruning Timer
For mission-critical production servers where unattended-upgrades might be disabled, deploy a lightweight systemd timer that runs weekly:
# /etc/systemd/system/kernel-prune.service
[Unit]
Description=Automated Weekly Linux Kernel Pruning
After=network.target
[Service]
Type=oneshot
ExecStart=/usr/bin/apt-get autoremove --purge -y
# /etc/systemd/system/kernel-prune.timer
[Unit]
Description=Run kernel cleanup every Sunday night
[Timer]
OnCalendar=Sun *-*-* 03:30:00
Persistent=true
[Install]
WantedBy=timers.target
Enable your safety net:
systemctl daemon-reload
systemctl enable --now kernel-prune.timer
PERMANENT AUTOMATED KERNEL HYGIENE CYCLE
- Weekly Systemd Timer Fires → Runs: apt-get autoremove –purge -y
- APT Consults 01autoremove-kernels: Running Kernel (uname -r) → PROTECTED!
- Latest Installed Kernel → PROTECTED!
- Previous Backup Kernel → PROTECTED!
- Obsolete 4th & 5th Kernels → AUTOMATICALLY PURGED!
- /boot Partition Permanently Stabilized at ~45% Capacity!
By understanding package management internals and applying proactive systemd hygiene, you eliminate one of the most frustrating legacy Linux headaches. Pair this with our technical consulting to build bulletproof server maintenance regimes that run silently and reliably year-round. Check out community sysadmin maintenance scripts on GitHub for additional automation patterns.
Alongside our operational work at Webxtek Studio, we apply these exact architectural standards across specialized sectors including devops & cloud architecture specialists and cloud computing & iaas providers. Whether you are modernizing core workflows through managed hosting for websites and apps and technical consulting before you build, connecting sector-specific requirements to disciplined execution is what turns technical theory into compounding commercial advantage.
[+] [ INDEX_DIRECTORY ] 20 topics ▼
- The Panic of the Full /boot Partition: A Sysadmin Classic
- The Anatomy of /boot: Why Kernel Files Accumulate
- The Safe 5-Step Recovery Procedure: Breaking the DPKG Lock
- Step 1: Identify Your Current Running Kernel
- Step 2: List All Installed Kernel Packages
- Step 3: Temporarily Evacuate Space (The Emergency Valve)
- Step 4: Purge Obsolete Kernels with DPKG
- Step 5: Repair the Broken DPKG State and Update GRUB
- Automating Kernel Hygiene: Never Suffer a Full /boot Again
- 1. Configure Automatic Kernel Pruning in APT
- 2. Configure Unattended Upgrades to Autoremove
- 3. Deploying a Systemd Safety Pruning Timer
- Author
- Frequently Asked Questions
- Why does the /boot partition fill up automatically on Debian and Ubuntu?
- What happens when /boot reaches 100% capacity during an APT kernel update?
- Why is running rm -rf /boot/*-old an extremely dangerous mistake?
- How do you permanently automate old kernel removal in modern Debian?
- Related Nodes
- Path Sequence
Frequently Asked Questions
Why does the /boot partition fill up automatically on Debian and Ubuntu?
Automated security updates (`unattended-upgrades`) regularly install new Linux kernel packages (`linux-image-*` and `linux-headers-*`). Each kernel version includes a compressed vmlinuz image, a System.map file, and a large initramfs RAM disk (often 50–90MB). If old kernel packages are not pruned, a standard 500MB `/boot` partition fills completely within 4 to 6 update cycles.
What happens when /boot reaches 100% capacity during an APT kernel update?
The `update-initramfs` script attempts to write a new initial RAM disk to `/boot`, fails with `No space left on device`, and leaves `dpkg` in an interrupted, unconfigured error state (`status: half-installed`). Any subsequent `apt install`, `apt upgrade`, or `apt remove` command will abort with exit code 1.
Why is running rm -rf /boot/*-old an extremely dangerous mistake?
Manually deleting kernel files from `/boot` frees disk space, but leaves the Debian package database (`/var/lib/dpkg/status`) believing the packages are still installed. When you subsequently run `apt`, it triggers package post-removal maintainer scripts that expect the deleted files to exist, compounding the corruption.
How do you permanently automate old kernel removal in modern Debian?
In `/etc/apt/apt.conf.d/01autoremove-kernels`, Debian automatically tracks installed kernels. Ensuring that `Unattended-Upgrade::Remove-Unused-Kernel-Packages "true";` is configured in `/etc/apt/apt.conf.d/50unattended-upgrades` ensures that obsolete kernel images are purged automatically immediately following successful reboots.
[ RELATED_NODES ]
> START_PROJECT
Need a website that earns trust, ranks in search, and gives your business a stronger digital presence? Start the conversation here.