Proxmox PVE 9 软件仓库源更换为国内源并关闭弹窗订阅的方法
经营范围:电脑组装,电脑维修,智能家居设备,苹果电脑系统安装,苹果手机刷机,监控安装,媒体编辑,数据恢复,复印打印,网站制作等 |
一、PVE屏蔽企业软件源
查看/etc/apt/sources.list.d/的sources文件
#cd到当前目录 cd /etc/apt/sources.list.d/ #查看目录下文件 ls #输出结果 ceph.sources debian.sources pve-enterprise.sources
将pve-enterprise.sources文件重命名保存为bak格式,保存原文件的完整性,在/etc/apt/sources.list.d/目录执行命令如下,
mv pve-enterprise.sources pve-enterprise.sources.bak
以上操作完成后即可屏蔽企业软件源。
建议操作:接下来将debian.sources和ceph.sources文件重命名保存为bak格式,保存原文件的完整性,后续使用新建文件即可,在/etc/apt/sources.list.d/目录执行命令如下,
mv debian.sources debian.sources.bak mv ceph.sources ceph.sources.bak
二、PVE新建免费软件源
#新建文件,在/etc/apt/sources.list.d/新建pve-no-subscription.list文件,nano命令:ctrl+o保存,enter回车确认,ctrl+X退出
nano /etc/apt/sources.list.d/pve-no-subscription.list
#写入内容,pve-no-subscription.list文件写入:
deb https://mirror.nju.edu.cn/proxmox/debian/pve trixie pve-no-subscription
或者执行命令如下,完成在/etc/apt/sources.list.d/新建pve-no-subscription.list文件并写入配置内容
echo 'deb https://mirror.nju.edu.cn/proxmox/debian/pve trixie pve-no-subscription' \ > /etc/apt/sources.list.d/pve-no-subscription.list
备注:因为PVE用的是root账户不需要sudo,但是非要用sudo的话,首先要把debian软件源设置apt update升级后,才能安装apt install sudo,在使用sudo功能,不需要卸载的话apt remove sudo
用sudo的示例:只做说明
echo 'deb https://mirror.nju.edu.cn/proxmox/debian/pve trixie pve-no-subscription ' | sudo tee /etc/apt/sources.list.d/pve-no-subscription.list
然后执行
apt clean apt update apt list --upgradable #查看需要升级的文件清单 apt upgrade
三、Debian 13软件源更改
#新建文件,在/etc/apt/sources.list.d/新建debian.sources文件,nano命令:ctrl+o保存,enter回车确认,ctrl+X退出
nano /etc/apt/sources.list.d/debian.sources
#写入内容,Debian版本【Debian 13(trixie)】,启用源码镜像【否】,使用官方安全更新软件源选择【否】,debian.sources文件写入:
Types: deb URIs: https://mirrors.ustc.edu.cn/debian Suites: trixie trixie-updates trixie-backports Components: main contrib non-free non-free-firmware Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg # 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释 # Types: deb-src # URIs: https://mirrors.ustc.edu.cn/debian # Suites: trixie trixie-updates trixie-backports # Components: main contrib non-free non-free-firmware # Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg # 以下安全更新软件源包含了官方源与镜像站配置,如有需要可自行修改注释切换 Types: deb URIs: https://mirrors.ustc.edu.cn/debian-security Suites: trixie-security Components: main contrib non-free non-free-firmware Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg # Types: deb-src # URIs: https://mirrors.ustc.edu.cn/debian-security # Suites: trixie-security # Components: main contrib non-free non-free-firmware # Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg # Types: deb # URIs: http://security.debian.org/debian-security # Suites: trixie-security # Components: main contrib non-free non-free-firmware # Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg # # Types: deb-src # # URIs: http://security.debian.org/debian-security # # Suites: trixie-security # # Components: main contrib non-free non-free-firmware # # Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
或者执行命令如下,完成在/etc/apt/sources.list.d/新建debian.sources文件并写入配置内容
echo 'Types: deb URIs: https://mirrors.ustc.edu.cn/debian Suites: trixie trixie-updates trixie-backports Components: main contrib non-free non-free-firmware Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg # 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释 # Types: deb-src # URIs: https://mirrors.ustc.edu.cn/debian # Suites: trixie trixie-updates trixie-backports # Components: main contrib non-free non-free-firmware # Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg # 以下安全更新软件源包含了官方源与镜像站配置,如有需要可自行修改注释切换 Types: deb URIs: https://mirrors.ustc.edu.cn/debian-security Suites: trixie-security Components: main contrib non-free non-free-firmware Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg # Types: deb-src # URIs: https://mirrors.ustc.edu.cn/debian-security # Suites: trixie-security # Components: main contrib non-free non-free-firmware # Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg # Types: deb # URIs: http://security.debian.org/debian-security # Suites: trixie-security # Components: main contrib non-free non-free-firmware # Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg # # Types: deb-src # # URIs: http://security.debian.org/debian-security # # Suites: trixie-security # # Components: main contrib non-free non-free-firmware # # Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg' \ > /etc/apt/sources.list.d/debian.sources
执行升级
apt clean apt update apt list --upgradable #查看需要升级的文件清单 apt-get upgrade
国内镜像源参考:https://help.mirrors.cernet.edu.cn/debian/,建议中国科技技术大学开源软件镜像,比较快。
四、CEPH分布式源更改
#新建文件,在/etc/apt/sources.list.d/新建ceph.sources文件,nano命令:ctrl+o保存,enter回车确认,ctrl+X退出
nano /etc/apt/sources.list.d/ceph.sources
#写入内容,ceph.sources文件写入:
Types: deb URIs: https://mirrors.ustc.edu.cn/proxmox/debian/ceph-squid Suites: trixie Components: no-subscription Signed-By: /usr/share/keyrings/proxmox-archive-keyring.gpg
或者执行命令如下,前提必须在/etc/apt/sources.list.d/新建ceph.sources空文件
#cd到当前目录 cd /etc/apt/sources.list.d #新建空文件 > ceph.sources
然后执行命令写入配置内容:
if [ -f /etc/apt/sources.list.d/ceph.sources ]; then CEPH_CODENAME=$(ceph -v | awk '{print $(NF-1)}') cat > /etc/apt/sources.list.d/ceph.sources <<EOF Types: deb URIs: https://mirrors.ustc.edu.cn/proxmox/debian/ceph-$CEPH_CODENAME Suites: trixie Components: no-subscription Signed-By: /usr/share/keyrings/proxmox-archive-keyring.gpg EOF fi
然后执行
apt clean apt update apt list --upgradable #查看需要升级的文件清单 apt upgrade
五、CT Templates容器源更改
将/usr/share/perl5/PVE/APLInfo.pm 文件中默认的源地址 http://download.proxmox.com 替换,一键直接执行命令如下:
sed -i.bak 's|http://download.proxmox.com|https://mirrors.ustc.edu.cn/proxmox|g' /usr/share/perl5/PVE/APLInfo.pm
更改后执行以下命令后重启生效,/usr/share/perl5/PVE/APLInfo.pm 文件属于 pve-manager 软件包,该软件包升级后,需要重新替换 URL。
systemctl restart pvedaemon
国内参考:https://mirrors.ustc.edu.cn/help/proxmox.html
在local(pve)→CT模板→【模板】随便找一个→【下载】,如果输出我们更改的https://mirrors.ustc.edu.cn/proxmox地址,并能进行下载说明更改成功。
六、关闭每次登陆弹窗:无有效订阅
sed -Ezi.bak "s/(Ext.Msg.show\(\{\s+title: gettext\('No valid sub)/void\(\{ \/\/\1/g" /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js && systemctl restart pveproxy.service
命令执行完,浏览器Ctrl+F5强制刷新缓存,在登录不显示弹窗订阅。
Ctrl+F5