Skip to content

PVE 8.3.0 更换国内源总结(带注释)

更换 PVE 国内源可以有效提高软件包的下载速度和系统的更新效率。以下是基于中科大源的更换步骤,每个步骤都附带了注释,帮助你理解每条命令的作用。

一、更新 Debian 源

# 将 Debian 的默认源替换为中科大的源,同时保留原始文件的备份(.bak后缀)
sed -i.bak '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

二、更新 PVE 软件源

2.1 删除或屏蔽默认企业源

# 删除企业源的配置文件,避免使用官方企业源
rm -rf /etc/apt/sources.list.d/pve-enterprise.list
# 或者将企业源配置文件重命名,以屏蔽企业源
mv /etc/apt/sources.list.d/pve-enterprise.list /etc/apt/sources.list.d/pve-enterprise.list.bak

2.2 更换中科大源

# 添加中科大的 PVE 源到系统配置中,确保使用无订阅的版本
echo "deb https://mirrors.ustc.edu.cn/proxmox/debian/pve bookworm pve-no-subscription" > /etc/apt/sources.list.d/pve-no-subscription.list

三、更新 CEPH 分布式源

# 添加中科大的 CEPH 源配置
echo "deb https://mirrors.ustc.edu.cn/proxmox/debian/ceph-quincy bookworm no-subscription" > /etc/apt/sources.list.d/ceph.list
# 修改 CEPH 相关脚本中的源地址,替换为中科大的源
sed -i.bak "s#http://download.proxmox.com/debian#https://mirrors.ustc.edu.cn/proxmox/debian#g" /usr/share/perl5/PVE/CLI/pveceph.pm

四、修复 https 证书并更新软件源

# 更新软件包索引,并安装必要的 HTTPS 支持和证书,修复可能的缺失依赖
apt update && apt-get install -y apt-transport-https ca-certificates --fix-missing

五、更新索引并升级安装软件包

# 再次更新软件包索引,并进行系统升级,确保所有软件包都是最新版本
apt update && apt dist-upgrade

六、更新 LXC 容器模板

# 修改 LXC 容器模板的源地址为中科大的源
sed -i.bak "s#http://download.proxmox.com/images#https://mirrors.ustc.edu.cn/proxmox/images#g" /usr/share/perl5/PVE/APLInfo.pm
# 重启 PVE 核心守护进程,使更改生效
systemctl restart pvedaemon

七、删除无效订阅弹窗

# 修改 PVE 的 JavaScript 文件,屏蔽无效订阅的弹窗提示
sed -Ezi.bak "s/(Ext.Msg.show\(\{\s+title: gettext\('No valid sub)/void\(\{ \/\/\1/g" /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js
# 重启 PVE 的代理服务,使更改生效
systemctl restart pveproxy.service

八、其他常用源选择

清华源

# 将 Debian 的默认源替换为清华的源
sed -i.bak "s#ftp.debian.org/debian#mirrors.tuna.tsinghua.edu.cn/debian#g" /etc/apt/sources.list
sed -i "s#security.debian.org#mirrors.tuna.tsinghua.edu.cn/debian-security#g" /etc/apt/sources.list

阿里云源

# 将 Debian 的默认源替换为阿里云的源
sed -i.bak "s#ftp.debian.org/debian#mirrors.aliyun.com/debian#g" /etc/apt/sources.list
sed -i "s#security.debian.org#mirrors.aliyun.com/debian-security#g" /etc/apt/sources.list

163 源

# 将 Debian 的默认源替换为 163 的源
sed -i.bak "s#ftp.debian.org/debian#mirrors.163.com/debian#g" /etc/apt/sources.list
sed -i "s#security.debian.org#mirrors.163.com/debian-security#g" /etc/apt/sources.list

通过以上步骤,可以将 PVE 系统的软件源更换为国内源,从而提高软件包的下载速度和系统的更新效率。不同的国内源可以根据自己的需求和网络情况进行选择。

Ref

https://blog.csdn.net/weixin_52626278/article/details/144147244