Disk Cleanup โ Ubuntu System Cleanup Guide
Last reviewed: 2026-05-29
Purpose: Step-by-step guide for identifying and reclaiming disk space on Ubuntu systems, focusing on Docker container artifacts and KVM/libvirt virtual machine storage.
Overview
This folder contains a single comprehensive Markdown guide (UbuntuDiskCleanUp.md, 4 KB) that covers the complete workflow for diagnosing disk space issues and recovering storage on Ubuntu servers โ particularly those running Docker containers and KVM/libvirt virtual machines.
Contents
| File | Description |
|---|---|
UbuntuDiskCleanUp.md |
Full disk cleanup guide with commands and strategies |
Topics Covered
1. Disk Usage Identification
du -h / --max-depth=1for top-level analysis- Deep-dive into
/varand/var/libdirectories
2. Docker Cleanup
docker system prune -a -fto remove unused images, containers, and volumes- Truncating container log files to reclaim space
- Configuring Docker log rotation (
daemon.jsonwithmax-size: 100m,max-file: 3)
3. KVM/libvirt Management
- Identifying VM disk usage with
virsh list --allandqemu-img info - Deleting unused VMs with
virsh undefine --remove-all-storage - Compacting qcow2 disk images via zero-fill and
qemu-img convert - Finding orphaned disk images no longer attached to any VM
4. System Logs & Cache
journalctl --vacuum-time=7d/--vacuum-size=500Mapt cleanto clear apt cache- Snap package revision cleanup
5. Tools & Quick Script
ncduinteractive disk analyzer recommendation- One-liner quick cleanup script for routine maintenance
Key Takeaway
The biggest disk gains come from deleting unused VMs, cleaning inside running VMs, and pruning Docker โ not from logs, which are rarely the issue at TB scale.