Disk Cleanup

Procedures for freeing disk space on MEGATRON when root or network storage is running low.

Quick Assessment

# Root filesystem usage
df -h /

# Largest directories under /home
du -sh /home/lucas/*/ 2>/dev/null | sort -rh | head -20

# Docker disk usage
docker system df

# K3s / containerd images
crictl images | sort -k3 -h

# Stale containers
docker ps -a --filter "status=exited" --format "table {{.Names}}\t{{.Size}}\t{{.Status}}"

Cleanup Targets

Docker (typical savings: 5-50 GB)

# Remove stopped containers
docker container prune

# Remove unused images
docker image prune -a

# Remove unused volumes (CAUTION: verify no needed data)
docker volume prune

# Full cleanup
docker system prune -a --volumes

Conda Environments (~/miniconda3/ = 44 GB)

# List environments
conda env list

# Remove unused environments
conda env remove -n <env-name>

# Clean package cache
conda clean --all

Research Data (~/Papers/ = 234 GB)

# Find large checkpoint files
find ~/Papers/ -name "*.pt" -o -name "*.pth" -o -name "*.ckpt" | xargs du -sh | sort -rh | head -20

# Find large log directories
find ~/Papers/ -name "logs" -type d | xargs du -sh | sort -rh | head -10

System Logs

# Check journal size
journalctl --disk-usage

# Vacuum old logs (keep 1 week)
sudo journalctl --vacuum-time=7d

SMB Share Cleanup (90% full)

# Largest directories
du -sh /mnt/sunny/*/ 2>/dev/null | sort -rh | head -20

# Files not accessed in 6+ months
find /mnt/sunny -atime +180 -size +1G -ls 2>/dev/null | head -30

TODO: expand with automated cleanup scripts and monitoring thresholds.