我在本地电脑安装Debian 12的时候发现,如果无论是什么安装方式(网络安装或者DVD ISO刻录U盘安装),只要在安装过程中选择了网络更新都会体验到奇慢的内容下载速度甚至是安装失败,哪怕是在安装过程中使用了Debian列出的中国大陆地区的认证的软件源。具体的原因是debian.org默认的软件源deb.debian.org用的是海外CDN供应商,边缘节点在中国大陆地区几乎没有,所以大陆用户访问很慢;此外默认情况下选择中国大陆地区的软件源默认只会加速非security内容,因为一般来说,为了更及时地获得安全更新,不推荐使用镜像站安全更新软件源,因为镜像站往往有同步延迟。参考Debian security FAQ。
相比Ubuntu、CentOS等Linux系统的流畅安装体验,新手安装Debian的体验非常差,很容易因为潜在的网络问题安装失败或者几小时也安装不完!!!
解决方式
方式一:先离线安装再补充中国大陆地区的源
关键步骤
安装过程中的关键就是直接下载完整的DVD ISO刻录为U盘,然后安装时直接不访问软件源,直接进行离线安装。选项如下:
在安装过程中,我们在Configure the package manager
时,选择No
,千万不要轻易的选择Yes
。因为它会先引导你选择各个国家和地区的软件源地址,虽然你会选中国大陆地区的源,但是security相关的源依然是deb.debian.org,这个地方很容易因为网络原因导致安装卡住或者失败!!!
后面的安装选择就很方便了,因为我使用服务器用途,所以我不需要安装GUI界面,只需要最基础的组件和SSH服务就行
中国地区的源配置
离线安装的方式,其实没有配置软件源,哪怕是默认的deb.debian.org也没有,我们在使用apt进行其他软件的网络安装时,会遇到错误,比如apt update -y && apt upgrade -y
也会报错:
那么我们直接补充中国大陆地区的软件源,这样比debian.org的软件源快很多,我们需要修改Debian中的/etc/apt/sources.list
来实现,具体的内容如下:
我们可以参考清华软件源 Debian 软件仓库镜像使用帮助来设置,目前清华的文档是最详细而且贴地气的
# 这一行需要屏蔽,离线安装方式成功后默认是打开的,这样我们只能在DVD里面查找软件,不能在互联网上查找软件
#deb cdrom:[Debian GNU/Linux 12.2.0 _Bookworm_ - Official amd64 DVD Binary-1 with firmware 20231007-10:29]/ bookworm main non-free-firmware
# 使用清华的软件源,默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
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/ 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.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
# 屏蔽security.debian.org的软件源,因为前面已经使用了清华的源。security.debian.org在中国大陆非常慢而且不稳定,不如用中国大陆地区的其他源
# deb https://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware
# deb-src https://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware
我们修改源后,重新尝试使用apt update -y && apt upgrade -y
来检查下即可
方式二:安装过程中直接修改为中国大陆地区的security源
我们在Configure the package manager
时,选择Yes
,但是不直接进行下一步
我们需要按CTRL+ALT+F2
进入终端界面,修改安全源地址。文件路径为/target/etc/apt/sources.list
,内容为
# 安全更新也使用清华软件源
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
修改好后保存文件,按CTRL+ALT+F5
退出终端界面,回到按照图形化按照界面继续安装。在后续的安装过程中,会要求你选择一些各个国家和地区的本地软件源,你可以选择中国大陆的软件源并直接安装。安装过程中请在遇到网络包更新卡顿的时候,继续使用CTRL+ALT+F2
和CTRL+ALT+F5
来检查下/target/etc/apt/sources.list
或者/etc/apt/sources.list
中软件源的设置。
还是推荐使用第一种方式,最简单最可靠。