一、备份配置文件

修改前务必备份,防止配置错误导致系统不可用:

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

二、编辑原配置文件

使用 nano 或 vim 编辑器打开文件:

sudo nano /etc/apt/sources.list

三、替换国内镜像站

1.版本匹配

将配置中的 bookworm 替换为实际Debian版本代号(如Debian 11为 bullseye),可通过以下命令查询:

lsb_release -cs

阿里云镜像源(推荐)

deb https://mirrors.aliyun.com/debian/ bookworm main non-free non-free-firmware contrib
deb-src https://mirrors.aliyun.com/debian/ bookworm main non-free non-free-firmware contrib
deb https://mirrors.aliyun.com/debian-security/ bookworm-security main
deb-src https://mirrors.aliyun.com/debian-security/ bookworm-security main
deb https://mirrors.aliyun.com/debian/ bookworm-updates main non-free non-free-firmware contrib
deb-src https://mirrors.aliyun.com/debian/ bookworm-updates main non-free non-free-firmware contrib
deb https://mirrors.aliyun.com/debian/ bookworm-backports main non-free non-free-firmware contrib
deb-src https://mirrors.aliyun.com/debian/ bookworm-backports main non-free non-free-firmware contrib

清华大学镜像源

deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware
deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware

中科大镜像源

deb https://mirrors.ustc.edu.cn/debian/ bookworm main contrib non-free non-free-firmware
deb-src https://mirrors.ustc.edu.cn/debian/ bookworm main contrib non-free non-free-firmware
deb https://mirrors.ustc.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware
deb-src https://mirrors.ustc.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware

三、常见问题

证书错误

运行以下命令更新CA证书:

sudo apt install ca-certificates

历史残留冲突

执行以下命令清理缓存:

sudo apt clean && sudo apt autoremove

恢复默认源

若需恢复官方源,用备份文件覆盖即可:

sudo cp /etc/apt/sources.list.bak /etc/apt/sources.listsudo apt update

虽然选择了国内的源但安装速度依旧慢

导致这一问题的核心原因是:虽然选择的了国内源,但软件源中的安全源地址仍然是官方源。

知道了问题所在那就好办了!

在安装进行到选择桌面环境和软件时,按CTRL+ALT+F2切换到终端界面,修改安全源地址即可,可以修改成前面选择的国内源的地址。
如:

# deb https://mirrors.tuna.tsinghua.edu.cn/debian-security trixie-security main contrib non-free non-free-firmwarenano /target/etc/apt/sources.list

修改完成后保存,按CTRL+ALT+F5回到图形界面,继续剩余的安装步骤。