PVE运维记录
换源(PVE 8.x)
首先更新证书:
sudo apt install apt-transport-https ca-certificates
接着就可以修改 Debian 源和 PVE 软件源了:
curl -fsSL https://mirrors.ustc.edu.cn/repogen/conf/debian-https-4-bookworm -o /etc/apt/sources.list
echo "deb https://mirrors.ustc.edu.cn/proxmox/debian bookworm pve-no-subscription" > /etc/apt/sources.list.d/pve-enterprise.list
echo "deb https://mirrors.ustc.edu.cn/proxmox/debian/ceph-quincy bookworm no-subscription" > /etc/apt/sources.list.d/ceph.list
wget https://mirrors.ustc.edu.cn/proxmox/debian/proxmox-release-bookworm.gpg -O /etc/apt/trusted.gpg.d/proxmox-release-bookworm.gpg
apt update
最后修改 CT Templates 源(需要重启服务):
sed -i 's|http://download.proxmox.com|https://mirrors.ustc.edu.cn/proxmox|g' /usr/share/perl5/PVE/APLInfo.pm
systemctl restart pvedaemon.service
时间同步(NTP)
cat >> /etc/chrony/chrony.conf <<'EOF_INNER'
# Aliyun NTP
server ntp1.aliyun.com minpoll 4 maxpoll 10 iburst
server ntp2.aliyun.com minpoll 4 maxpoll 10 iburst
server ntp3.aliyun.com minpoll 4 maxpoll 10 iburst
server ntp4.aliyun.com minpoll 4 maxpoll 10 iburst
server ntp5.aliyun.com minpoll 4 maxpoll 10 iburst
server ntp6.aliyun.com minpoll 4 maxpoll 10 iburst
server ntp7.aliyun.com minpoll 4 maxpoll 10 iburst
EOF_INNER
systemctl restart chrony
chronyc sources -v
解决 unsupported Ubuntu version ‘24.04’ / ‘24.10’ / ‘25.04’
首先修改 /usr/share/perl5/PVE/LXC/Setup/Ubuntu.pm:
my $known_versions = {
+ '25.04' => 1, # plucky
+ '24.10' => 1, # oracular
+ '24.04' => 1, # noble
'23.10' => 1, # mantic
'23.04' => 1, # lunar
然后在母鸡的 Shell 中执行:
pveam available
pveam update
接着在母鸡的磁盘 -> CT 模板 -> 模板中选择下载 Ubuntu_24.04,接着再次执行 pveam available 即可。
合并命令:
grep -q "25.04" /usr/share/perl5/PVE/LXC/Setup/Ubuntu.pm || sed -i "/'23.10'/i\ '25.04' => 1, # plucky\n '24.10' => 1, # oracular\n '24.04' => 1, # noble" /usr/share/perl5/PVE/LXC/Setup/Ubuntu.pm
pveam available
pveam update
解决 CT 容器内无法使用 tun 网卡
编辑 /etc/pve/lxc/<CT_ID>.conf,在最后加入:
lxc.cgroup.devices.allow: a
lxc.cap.drop:
lxc.cgroup2.devices.allow: c 10:200 rwm
lxc.mount.entry: /dev/net/tun dev/net/tun none bind,create=file
批量添加:
for f in /etc/pve/lxc/*.conf; do
grep -q "lxc.mount.entry: /dev/net/tun" "$f" || cat <<'EOF' >> "$f"
lxc.cgroup.devices.allow: a
lxc.cap.drop:
lxc.cgroup2.devices.allow: c 10:200 rwm
lxc.mount.entry: /dev/net/tun dev/net/tun none bind,create=file
EOF
done
删除克隆任务提示 TASK ERROR: VM is locked (clone)
在 PVE 中,Full Clone 克隆 VM 模板或者克隆普通 VM 一般要比 Linked Clone 模板要慢,也更容易在克隆硬盘时卡住,因此优先使用 Linked Clone
假如克隆已经卡住,停止后尝试删除 VM 则会提示“TASK ERROR: VM is locked (clone)”,此时需要进入母鸡 Shell 使用 qm unlock <CT_ID> 来解锁容器,再在 UI 控制台中操作删除
参考链接: