Debian 的“缓存报错”通常不是单一原因,最常见的是 APT 缓存或软件源配置问题。下面按常见场景 + 应对方法给你一个排查清单,你可以对照看看属于哪一种。
E: 无法下载 / 无法解析 / Hash 校验失败E: Failed to fetch http://... Hash Sum mismatch
E: Unable to fetch some archives
sudo apt clean
sudo apt update
或更彻底一点:
sudo rm -rf /var/lib/apt/lists/*
sudo apt update
✅ 这是最推荐的第一步
检查 /etc/apt/sources.list 或 /etc/apt/sources.list.d/*.list
Debian 12(bookworm)示例:
deb https://deb.debian.org/debian bookworm main
deb https://deb.debian.org/debian bookworm-updates main
deb https://security.debian.org/debian-security bookworm-security main
然后:
sudo apt update
如果卡在 0% [Connecting to ...],多半是:
国内用户常见问题:
✅ 建议换为:
https://mirrors.tuna.tsinghua.edu.cn/debian/
https://mirrors.aliyun.com/debian/
修改后:
sudo apt update
apt-get install 报缓存相关错误E: Unable to locate package xxx
E: The cache is not available
sudo apt update
sudo apt-get install -f
或:
sudo dpkg --configure -a
sudo apt install -f
Permission denied
检查:
ls -ld /var/cache/apt
修复:
sudo chown -R root:root /var/cache/apt
sudo chmod -R 755 /var/cache/apt
df -h
如果 /var 或 / 满了:
sudo apt autoremove
sudo apt clean
E: Release file is not valid yet
原因:系统时间不对 ❗
解决:
sudo apt install ntpdate
sudo ntpdate cn.pool.ntp.org
sudo apt update
你可以直接贴出:
cat /etc/os-release)我可以精准定位是哪一种缓存问题,而不是泛泛而谈。