提升 Debian 磁盘回收效率的实用方案
一 核心清理动作
二 容器与镜像的专项回收
三 存储与文件系统优化
四 自动化与监控
#!/usr/bin/env bash
set -e
apt-get clean
apt-get autoclean
apt-get autoremove --purge -y
journalctl --rotate
journalctl --vacuum-time=7d
journalctl --vacuum-size=50M
rm -rf /tmp/*
find /var/log -type f -mtime +30 -delete 2>/dev/null || true
if command -v docker >/dev/null 2>&1; then
docker system prune -a -f --volumes
fi
五 安全与回退建议