本文档主要作用是方便自己重装 pve 时进行使用
固定网卡名称 当增减pcie设备时可能会导致网卡名称变化,使用下面的方式将网卡名称固定。 不建议使用 udev 规则 修改固定网卡名,因为可能会导致 vnstat 流量统计失败。 创建 /etc/systemd/network/70-persistent-net.link 并写入下面的内容,网卡名称和 mac 请使用 ip a 查看,并替换下面的 name 和 MACAddress。
1 2 3 4 5 6 [Match] MACAddress =00 :01 :02 :03 :04 :05 Type =ether[Link] Name =enp4s0
添加天成功后需要更新内核引导
1 sudo update-initramfs -u -k all
如果你固定的名称不是你现在的网卡名 还需要 /etc/network/interfaces 将里面的网卡名替换成你固定的名称。
修改后重启生效
开启ipv6 在 /etc/network/interfaces 添加如下内容重启后启用 ipv6
1 2 3 iface vmbr0 inet6 dhcp accept_ra 2 request_prefix 1
如果你像我一样插入了多张 m2 硬盘后无法获取到ipv6,可以删除上面添加的内容,然后在/etc/sysctl.conf 添加下列内容
1 2 net.ipv6.conf.vmbr0.accept_ra=2 net.ipv6.conf.vmbr0.autoconf=1
修改后重启生效
修改软件源为国内 修改 debian源 /etc/apt/sources.list.d/debian.sources 为如下内容
1 2 3 4 5 6 7 8 9 10 11 Types: deb URIs: https://mirrors.tuna.tsinghua.edu.cn/debian Suites: trixie trixie-updates Components: main contrib non-free-firmware Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg Types: deb URIs: https://mirrors.tuna.tsinghua.edu.cn/debian-security Suites: trixie-security Components: main contrib non-free-firmware Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
修改pve软件源 /etc/apt/sources.list.d/ceph.list 为如下内容
1 2 3 4 5 Types: deb URIs: https://mirrors.tuna.tsinghua.edu.cn/proxmox/debian/ceph-squid Suites: trixie Components: no-subscription Signed-By: /usr/share/keyrings/proxmox-archive-keyring.gpg
修改pve ceph 软件源 /etc/apt/sources.list.d/pve-enterprise.list 为如下内容
1 2 3 4 5 Types: deb URIs: https://enterprise.proxmox.com/debian/pve Suites: trixie Components: pve-enterprise Signed-By: /usr/share/keyrings/proxmox-archive-keyring.gpg
LXC 容器源替换为国内源
1 sed -i 's|http://download.proxmox.com|https://mirrors.ustc.edu.cn/proxmox|g' /usr/share/perl5/PVE/APLInfo.pm
重启后生效 systemctl restart pvedaemon.service
创建 nat 网络 创建 nat 网络参考 https://pve.proxmox.com/wiki/Setup_Simple_Zone_With_SNAT_and_DHCP
cpu 调度调整到省电 查看当前电源策略
1 cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
查看可用的电源策略
1 cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
debian13 不再使用 cpufrequtils 所以安装 linux-cpupower 后用 linux-cpupower 控制电源策略
1 sudo apt install linux-cpupower
在 /etc/systemd/system/cpupower.service 写入以下内容
1 2 3 4 5 6 7 8 9 10 11 [Unit] Description=Set CPU Frequency Governor [Service] Type=oneshot ExecStart=/usr/bin/cpupower -c all frequency-set -g powersave ExecStop=/usr/bin/cpupower -c all frequency-set -g performance RemainAfterExit=yes [Install] WantedBy=multi-user.target
重启后切换到动态频率调节
调整保存的历史命令 修改 ~/.bashrc 内的 HISTSIZE HISTFILESIZE 为以下子 以增加历史命令保存数量
1 2 HISTSIZE=10000 HISTFILESIZE=20000
显示 cpu频率和温度 这里使用的是 i5-12600K
需要安装 lm-sensors
1 sudo apt install lm-sensors
安装好后运行 sensors-detect 一路运行回车就好,全部使用默认选项
在 /usr/share/perl5/PVE/API2/Nodes.pm ksm 后添加内容
1 2 3 4 5 6 7 8 $res->{ksm} = { shared => $meminfo->{memshared}, }; $res->{cpure} = `cat /proc/cpuinfo | grep -i "cpu mhz"` ; $res->{sensinfo} = `sensors -j` ; $res->{upsinfo} = `upsc tgbox` ;
在 /usr/share/pve-manager/js/pvemanagerlib.js itemId cpus 后添加内容
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 { itemId : 'cpus' , colspan : 2 , printBar : false , title : gettext('CPU(s)' ), textField : 'cpuinfo' , renderer : Proxmox.Utils.render_cpu_model, value : '' , }, { itemId : 'cpumhz' , colspan : 2 , printBar : false , title : gettext('CPU(MHz)' ), textField : 'cpure' , renderer : function (value ) { const m = value.match(/(?<=:\s+)(\d+)/g ); return `${m[0 ]} | ${m[1 ]} | ${m[2 ]} | ${m[3 ]} | ${m[4 ]} | ${m[5 ]} | ${m[6 ]} | ${m[7 ]} | ${m[8 ]} | ${m[9 ]} | ${m[10 ]} | ${m[11 ]} | ${m[12 ]} | ${m[13 ]} | ${m[14 ]} | ${m[15 ]} ` ; } }, { itemId : 'sensinfo' , colspan : 2 , printBar : false , title :gettext('Temperature Sensor' ), textField :'sensinfo' , renderer : function (value ) { value = JSON .parse(value.replaceAll('Â' , '' )); const cp = value['coretemp-isa-0000' ]['Package id 0' ]['temp1_input' ].toFixed(1 ); const c0 = value['coretemp-isa-0000' ]['Core 0' ]['temp2_input' ].toFixed(); const c1 = value['coretemp-isa-0000' ]['Core 4' ]['temp6_input' ].toFixed(); const c2 = value['coretemp-isa-0000' ]['Core 8' ]['temp10_input' ].toFixed(); const c3 = value['coretemp-isa-0000' ]['Core 12' ]['temp14_input' ].toFixed(); const c4 = value['coretemp-isa-0000' ]['Core 16' ]['temp18_input' ].toFixed(); const c5 = value['coretemp-isa-0000' ]['Core 20' ]['temp22_input' ].toFixed(); const c6 = value['coretemp-isa-0000' ]['Core 28' ]['temp30_input' ].toFixed(); const c7 = value['coretemp-isa-0000' ]['Core 29' ]['temp31_input' ].toFixed(); const c8 = value['coretemp-isa-0000' ]['Core 30' ]['temp32_input' ].toFixed(); const c9 = value['coretemp-isa-0000' ]['Core 31' ]['temp33_input' ].toFixed(); return `CPU: ${cp} ℃ (${c0} | ${c1} | ${c2} | ${c3} | ${c4} | ${c5} | ${c6} | ${c7} | ${c8} | ${c9} )` ; } }, { itemId : 'ups' , colspan : 2 , printBar : false , title : gettext('UPS' ), textField : 'upsinfo' , renderer : function (value ) { const statusLine = "ups.status:" ; const reStatus = new RegExp (`${statusLine} .*?\n` ); let upsStatus = value.match(reStatus)[0 ]; upsStatus = upsStatus.slice(statusLine.length+1 , -1 ); const changeLine = "battery.charge:" ; const reChange = new RegExp (`${changeLine} .*?\n` ); let upsChange = value.match(reChange)[0 ]; upsChange = upsChange.slice(changeLine.length+1 , -1 ); const realpowerLine = "ups.realpower:" ; const reRealpower = new RegExp (`${realpowerLine} .*?\n` ); let upsRealpower = value.match(reRealpower)[0 ]; upsRealpower = upsRealpower.slice(realpowerLine.length+1 , -1 ); let upsRealpowerNum = parseInt (upsRealpower, 10 ) upsRealpowerNum -= 17 return `status: ${upsStatus} | change: ${upsChange} | power: ${upsRealpowerNum} W` ; } },
使用 sudo systemctl restart pveproxy 重启 pve代理后,web面板将显示 cpu 频率和温度