一、问题背景
在维护一台基于 Debian Buster (10) 的 ARM64 设备(Linaro ALIP)时,发现 apt update
命令无法正常更新软件包列表,报错 404 Not Found
。经过排查,确认问题源于 Debian Buster 已结束官方支持(EOL),主流镜像站(如清华源、官方源)已移除其仓库文件。
二、问题复现
1. 初始错误
执行 sudo apt update
时,报错如下:
bash
|--------------------------------------------------------------------------------------------|
| E: 仓库 "http://deb.debian.org/debian buster Release" 没有 Release 文件。
|
| E: 仓库 "http://security.debian.org/debian-security buster/updates Release" 没有 Release 文件。
|
原因:Debian Buster 已于 2022 年 9 月停止维护,官方镜像站不再提供其软件源。
2. 尝试切换清华源
修改 /etc/apt/sources.list
为清华镜像站:
bash
|-------------------------------------------------------------------------------------------------|
| deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster main contrib non-free
|
| deb https://mirrors.tuna.tsinghua.edu.cn/debian-security buster/updates main contrib non-free
|
但 apt update
仍报 404
,说明清华源也已移除 Buster 仓库。
3. 验证软件源状态
通过 curl
检查 Release 文件是否存在:
bash
|----------------------------------------------------------------------------|
| curl -I https://mirrors.tuna.tsinghua.edu.cn/debian/dists/buster/Release
|
| # 返回 HTTP/2 404,确认源已失效
|
三、解决方案
方法 1:使用 Debian 官方存档源(推荐临时使用)
Debian 将旧版本移至 archive.debian.org,需手动修改 sources.list
并禁用安全检查。
步骤 1:修改软件源
bash
|--------------------------------------------------------------------------------------|
| sudo bash -c 'cat > /etc/apt/sources.list' <<EOF
|
| deb http://archive.debian.org/debian buster main contrib non-free
|
| deb http://archive.debian.org/debian-security buster/updates main contrib non-free
|
| deb http://archive.debian.org/debian buster-updates main contrib non-free
|
| EOF
|
步骤 2:禁用 APT 的过期仓库检查
bash
|-------------------------------------------------------|
| sudo apt update -o Acquire::Check-Valid-Until=false
|
说明 :Acquire::Check-Valid-Until=false
允许使用已过期的仓库元数据。
步骤 3(可选):允许非安全源
如果仍报错,可临时允许未认证的源(不推荐长期使用):
bash
|----------------------------------------------------------------------------------------------|
| sudo apt -o Acquire::Check-Valid-Until=false -o APT::Get::AllowUnauthenticated=true update
|
方法 2:升级到受支持的 Debian 版本(推荐长期方案)
由于 Buster 已停止维护,建议升级到 Debian 11 (Bullseye) 或 Debian 12 (Bookworm)。
步骤 1:修改软件源为 Bullseye
bash
|------------------------------------------------------------------------------------------|
| sudo bash -c 'cat > /etc/apt/sources.list' <<EOF
|
| deb http://deb.debian.org/debian bullseye main contrib non-free
|
| deb http://security.debian.org/debian-security bullseye-security main contrib non-free
|
| deb http://deb.debian.org/debian bullseye-updates main contrib non-free
|
| EOF
|
步骤 2:执行完整升级
bash
|-----------------------------------------------|
| sudo apt update && sudo apt full-upgrade -y
|
| sudo reboot
|
说明 :full-upgrade
会处理依赖关系变更,确保系统平滑升级。
方法 3:使用第三方镜像(不推荐)
部分第三方镜像(如中科大)可能保留旧版本,但存在安全风险。示例配置:
bash
|--------------------------------------------------------------------------------------|
| deb https://mirrors.ustc.edu.cn/debian-archive/debian buster main contrib non-free
|
警告:第三方源可能随时失效,且不提供安全更新。
四、其他问题修复
1. NTP 时间同步失败
错误日志:
bash
|----------------------------------------------------|
| ntpdate[1459]: the NTP socket is in use, exiting
|
解决方案:
-
停止
ntp
服务并强制使用 UDP 端口:bash
|--------------------------------|
|sudo systemctl stop ntp
|
|sudo ntpdate -u pool.ntp.org
| -
或改用
systemd-timesyncd
:bash
|---------------------------------|
|sudo timedatectl set-ntp true
|
2. 清理残留配置
bash
|--------------------------|
| sudo apt clean
|
| sudo apt autoremove -y
|
五、总结与建议
- Debian Buster 已 EOL:主流镜像站不再提供支持,需切换到存档源或升级版本。
- 推荐升级:长期方案应选择 Debian 11/12,以获得安全更新和功能改进。
- 谨慎使用第三方源:避免引入未知风险,尤其是涉及安全更新的软件。
六、附录:完整操作记录
1. 检查当前架构
bash
|-----------------------------------------|
| dpkg --print-architecture # 输出: arm64
|
2. 验证软件源状态
bash
|----------------------------------------------------------------------------|
| curl -I https://mirrors.tuna.tsinghua.edu.cn/debian/dists/buster/Release
|
| # HTTP/2 404 Not Found
|
3. 切换到存档源并更新
bash
|-----------------------------------------------------------------------------|
| sudo sed -i 's|deb.debian.org|archive.debian.org|g' /etc/apt/sources.list
|
| sudo apt update -o Acquire::Check-Valid-Until=false
|
4. 升级到 Debian Bullseye(示例)
bash
|-----------------------------------------------------------|
| sudo sed -i 's/buster/bullseye/g' /etc/apt/sources.list
|
| sudo apt update && sudo apt full-upgrade -y
|