基本信息
- PVE 版本:8.0.3
- debian 版本:12 (bookworm)
- 目标源:中科大 USTC 源
清华源的 https://mirrors.tuna.tsinghua.edu.cn/ceph/debian-quincy/dists/ 里还没有 bookworm 的数据,因此不太能用
APT 换源
需修改文件
- /etc/apt/sources.list
- /etc/apt/sources.list.d/ceph.list
- /etc/apt/sources.list.d/pve-enterprise.list
修改前先备份,以防万一:
mkdir /etc/apt/sources_backup
cp /etc/apt/sources.list /etc/apt/sources_backup/sources.list.bak
cp /etc/apt/sources.list.d/ceph.list /etc/apt/sources_backup/ceph.list.bak
cp /etc/apt/sources.list.d/pve-enterprise.list /etc/apt/sources_backup/pve-enterprise.list.bak
可以参考 中科大 proxmox 镜像的文档,不过这个文档里的操作应该是适配旧版 proxmox 的,有些地方需要改改适配下
TL;DR
太长不看,指令如下:
# sources.list
sed -i 's|^deb http://ftp.debian.org|deb https://mirrors.ustc.edu.cn|g' /etc/apt/sources.list
sed -i 's|^deb http://security.debian.org|deb https://mirrors.ustc.edu.cn/debian-security|g' /etc/apt/sources.list
# ceph.list
echo "deb https://mirrors.ustc.edu.cn/proxmox/debian/ceph-quincy bookworm no-subscription" > /etc/apt/sources.list.d/ceph.list
# pve-enterprise.list
echo "" > /etc/apt/sources.list.d/pve-enterprise.list
sources.list
期望执行如下链接的替换
原链接 | 新链接 |
---|---|
http://ftp.debian.org | https://mirrors.ustc.edu.cn |
http://security.debian.org | https://mirrors.ustc.edu.cn/debian-security |
指令:
sed -i 's|^deb http://ftp.debian.org|deb https://mirrors.ustc.edu.cn|g' /etc/apt/sources.list
sed -i 's|^deb http://security.debian.org|deb https://mirrors.ustc.edu.cn/debian-security|g' /etc/apt/sources.list
文件变化:
--- a/etc/apt/sources_backup/sources.list.bak
+++ b/etc/apt/sources.list
@@ -1,6 +1,6 @@
-deb http://ftp.debian.org/debian bookworm main contrib
+deb https://mirrors.ustc.edu.cn/debian bookworm main contrib
-deb http://ftp.debian.org/debian bookworm-updates main contrib
+deb https://mirrors.ustc.edu.cn/debian bookworm-updates main contrib
# security updates
-deb http://security.debian.org bookworm-security main contrib
+deb https://mirrors.ustc.edu.cn/debian-security bookworm-security main contrib
ceph.list
这个原文件就一行,直接覆盖了完事
指令:
echo "deb https://mirrors.ustc.edu.cn/proxmox/debian/ceph-quincy bookworm no-subscription" > /etc/apt/sources.list.d/ceph.list
这里,我这里用了 no-subscription,但中科大文档里用的是 pve-no-subscription,原因是 中科院源里 里只有叫个 no-subscription 子目录,并没有 pve-no-subscription,因此得根据情况改一下
文件变化:
--- a/etc/apt/sources_backup/ceph.list.bak
+++ b/etc/apt/sources.list.d/ceph.list
@@ -1 +1 @@
-deb https://enterprise.proxmox.com/debian/ceph-quincy bookworm enterprise
+deb https://mirrors.ustc.edu.cn/proxmox/debian/ceph-quincy bookworm no-subscription
pve-enterprise.list
最后,把 pve-enterprise.list 的企业源扬了。毕竟这个企业源得订阅了才能用,没订阅意味着没用
echo "" > /etc/apt/sources.list.d/pve-enterprise.list
文件变化:
--- a/etc/apt/sources_backup/pve-enterprise.list.bak
+++ b/etc/apt/sources.list.d/pve-enterprise.list
@@ -1 +1 @@
-deb https://enterprise.proxmox.com/debian/pve bookworm pve-enterprise
+
(可选)如果没有订阅,却依然想要一个可以更新 PVE 的源,可以用 PVE 的 pve-no-subscription 源。可以用如下指令添加
echo "deb https://mirrors.ustc.edu.cn/proxmox/debian/pve bookworm pve-no-subscription" > /etc/apt/sources.list.d/pve-no-subscription.list
如文档所述,这个源的 PVE 软件包是作为企业源的上游源,可能相对不那么的稳定
完成
done。可以 apt update 更新下,也作为一个换源操作正确性的验证
root@localhost:~# apt update
Hit:1 https://mirrors.ustc.edu.cn/debian bookworm InRelease
Hit:2 https://mirrors.ustc.edu.cn/debian bookworm-updates InRelease
Hit:3 https://mirrors.ustc.edu.cn/debian-security bookworm-security InRelease
Hit:4 https://mirrors.ustc.edu.cn/proxmox/debian/ceph-quincy bookworm InRelease
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
38 packages can be upgraded. Run 'apt list --upgradable' to see them.
root@localhost:~#
如需回滚,可以用如下指令:
cp /etc/apt/sources_backup/sources.list.bak /etc/apt/sources.list
cp /etc/apt/sources_backup/ceph.list.bak /etc/apt/sources.list.d/ceph.list
cp /etc/apt/sources_backup/pve-enterprise.list.bak /etc/apt/sources.list.d/pve-enterprise.list
CT 模板换源
需修改文件:
- /usr/share/perl5/PVE/APLInfo.pm
先备份以防万一
cp /usr/share/perl5/PVE/APLInfo.pm /usr/share/perl5/PVE/APLInfo.pm.bak
APLInfo.pm
用如下指令修改,把 APLInfo.pm 里所有 http://download.proxmox.com 替换成中科大的镜像
sed -i 's|http://download.proxmox.com|https://mirrors.ustc.edu.cn/proxmox|g' /usr/share/perl5/PVE/APLInfo.pm
具体变更的内容如下所示
--- a/usr/share/perl5/PVE/APLInfo.pm.bak
+++ b/usr/share/perl5/PVE/APLInfo.pm
@@ -197,7 +197,7 @@ sub get_apl_sources {
my $sources = [
{
host => "download.proxmox.com",
- url => "http://download.proxmox.com/images",
+ url => "https://mirrors.ustc.edu.cn/proxmox/images",
file => 'aplinfo-pve-8.dat',
},
{
注意这里的 host 属性是不能修改的,只改 url 就好
完成
重启下 pvedaemon.service,刷新下 web 页面,完事
systemctl restart pvedaemon.service
如需回滚,可以用如下指令:
cp /usr/share/perl5/PVE/APLInfo.pm.bak /usr/share/perl5/PVE/APLInfo.pm
- 本文作者: Fallen_Breath
- 本文链接:https://blog.fallenbreath.me/zh-CN/2023/pve8-change-sourceslist/
- 版权声明: 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于