001-PVE基础配置(8.2.4版本)


简介

安装完PVE后,我们需要针对国内环境进行一些基本的配置,比如更新镜像源、处理订阅与disabled显示温度等操作。

环境

  • 操作系统: ubuntu 22.04.2 LTS

正文

1. 更换 Debian 源

Debian源国内可更新的镜像源有好多,比如官方源清华大学等,这里用官方源为范例:

# 备份文件
$ mv /etc/apt/sources.list /etc/apt/sources.list.bak
# 写入源地址
cat <<EOF > /etc/apt/sources.list
deb https://mirrors.ustc.edu.cn/debian/ bookworm main non-free non-free-firmware contrib
deb-src https://mirrors.ustc.edu.cn/debian/ bookworm main non-free non-free-firmware contrib
deb https://mirrors.ustc.edu.cn/debian-security/ bookworm-security main
deb-src https://mirrors.ustc.edu.cn/debian-security/ bookworm-security main
deb https://mirrors.ustc.edu.cn/debian/ bookworm-updates main non-free non-free-firmware contrib
deb-src https://mirrors.ustc.edu.cn/debian/ bookworm-updates main non-free non-free-firmware contrib
deb https://mirrors.ustc.edu.cn/debian/ bookworm-backports main non-free non-free-firmware contrib
deb-src https://mirrors.ustc.edu.cn/debian/ bookworm-backports main non-free non-free-firmware contrib
EOF

2. 更换 PVE与Ceph 源

PVE源同样也有官方源清华大学

# 备份文件
$ mv /etc/apt/sources.list.d/pve-enterprise.list /etc/apt/sources.list.d/pve-enterprise.list.bak
$ mv /etc/apt/sources.list.d/ceph.list /etc/apt/sources.list.d/ceph.list.bak
# 修改pve源
$ cat <<EOF > /etc/apt/sources.list.d/pve-enterprise.list
deb https://mirrors.ustc.edu.cn/proxmox/debian bookworm pve-no-subscription
EOF

# 修改ceph源
$ cat <<EOF > /etc/apt/sources.list.d/ceph.list
deb https://mirrors.ustc.edu.cn/proxmox/debian/ceph-quincy bookworm no-subscription
EOF

3. 更新LXC源

# 备份
$ cp /usr/share/perl5/PVE/APLInfo.pm /usr/share/perl5/PVE/APLInfo.pm_back
# 更换为新源
$ sed -i 's|http://download.proxmox.com|https://mirrors.ustc.edu.cn/proxmox|g' /usr/share/perl5/PVE/APLInfo.pm
# 重启服务
$ systemctl restart pvedaemon.service

4. 温度展示

显示 CPU 实时频率、各核心温度、硬盘型号、寿命、温度等信息 对于不想动手的朋友可以用脚本

$ (curl -Lf -o /tmp/temp.sh https://raw.githubusercontent.com/a904055262/PVE-manager-status/main/showtempcpufreq.sh || curl -Lf -o /tmp/temp.sh https://mirror.ghproxy.com/https://raw.githubusercontent.com/a904055262/PVE-manager-status/main/showtempcpufreq.sh) && chmod +x /tmp/temp.sh && /tmp/temp.sh remod

喜欢动手的可以按这个来

# 安装 lm-sensors 查询命令
$ apt install lm-sensors patch
# 初始化 sensors,一路回车
$ sensors-detect
# 给予 smartctl 权限(用于读取 NVMe 信息)
$ chmod +s /usr/sbin/smartctl

# 修改 /usr/share/perl5/PVE/API2/Nodes.pm
# 在PVE::pvecfg::version_text();下一行添加
    $res->{sensors_json} = `sensors -j`; # 获取 CPU 、主板温度及风扇转速
    $res->{smartctl_nvme_json} = `smartctl -a -j /dev/nvme?`; # 读取 nvme 硬盘 S.M.A.R.T. 值,获取硬盘寿命、容量、温度等
    $res->{cpusensors} = `lscpu | grep MHz`; # 读取 CPU 频率
sed -i '/PVE::pvecfg::version_text();/a\
$res->{sensors_json} = `sensors -j`; # 获取 CPU 、主板温度及风扇转速\n\
$res->{smartctl_nvme_json} = `smartctl -a -j /dev/nvme?`; # 读取 nvme 硬盘 S.M.A.R.T. 值,获取硬盘寿命、容量、温度等\n\
$res->{cpusensors} = `lscpu | grep MHz`; # 读取 CPU 频率' /usr/share/perl5/PVE/API2/Nodes.pm
    {
        itemId: 'MHz',
        colspan: 2,
        printBar: false,
        title: gettext('CPU频率'),
        textField: 'cpusensors',
        renderer:function(value){
                var f1 = value.match(/CPU min MHz.*?([\d]+)/)[1];
                var f2 = value.match(/CPU max MHz.*?([\d]+)/)[1];
                var f0 = value.match(/CPU.*scaling MHz.*?([\d]+)/)[1];
                var f0 = f0*f2/100;
            return `实时: ${f0} MHz || 最小: ${f1} MHz | 最大: ${f2} MHz `
        }
    },
    {
        itemId: 'thermal',
        colspan: 2,
        printBar: false,
        title: gettext('CPU温度'),
        textField: 'sensors_json',
        renderer: function(value) {
            value = value.replace(/temp([0-9]{1,})_input/g,'input');
            if (value.indexOf("coretemp-isa") != -1 ) {
                value = value.replace(/coretemp-isa-(.{4})/g,'coretemp-isa');
                value = JSON.parse(value);
                try {var cpu_Intel = 'CPU: ' + value['coretemp-isa']['Package id 0']['input'].toFixed(1) + '°C';} catch(e) {var cpu_Intel = '';} 
                if (cpu_Intel.length > 0) {
                    try {var cpu0 = ' || 核心 0 : ' + value['coretemp-isa']['Core 0']['input'].toFixed(1) + '°C';} catch(e) {var cpu0 = '';} 
                    try {var cpu1 = ' | 核心 1 : ' + value['coretemp-isa']['Core 1']['input'].toFixed(1) + '°C';} catch(e) {var cpu1 = '';} 
                    try {var cpu2 = ' | 核心 2 : ' + value['coretemp-isa']['Core 2']['input'].toFixed(1) + '°C';} catch(e) {var cpu2 = '';} 
                    try {var cpu3 = ' | 核心 3 : ' + value['coretemp-isa']['Core 3']['input'].toFixed(1) + '°C';} catch(e) {var cpu3 = '';} 
                    return `${cpu_Intel}${cpu0}${cpu1}${cpu2}${cpu3}`;
                } 
            } else {
                return `提示: CPU 温度读取异常`;
            }
        }
    },
    {        
        itemId: 'nvme_ssd',
        colspan: 2,
        printBar: false,
        title: gettext('NVME'),
        textField: 'smartctl_nvme_json',
        renderer: function(value) {
            value = JSON.parse(value);
            if (value['model_name']) {
                try {var model_name = value['model_name'];} catch(e) {var model_name = '';} 
                try {var percentage_used = ' | 使用寿命: ' + value['nvme_smart_health_information_log']['percentage_used'].toFixed(0) + '% ';} catch(e) {var percentage_used = '';} 
                try {var data_units_read = value['nvme_smart_health_information_log']['data_units_read']*512/1024/1024;var data_units_read = '(读: ' + data_units_read.toFixed(2) + 'GB, ';} catch(e) {var data_units_read = '';} 
                try {var data_units_written = value['nvme_smart_health_information_log']['data_units_written']*512/1024/1024;var data_units_written = '写: ' + data_units_written.toFixed(2) + 'GB)';} catch(e) {var data_units_written = '';} 
                try {var power_on_time = ' | 通电: ' + value['power_on_time']['hours'].toFixed(0) + '小时';} catch(e) {var power_on_time = '';} 
                try {var temperature = ' | 温度: ' + value['temperature']['current'].toFixed(1) + '°C';} catch(e) {var temperature = '';} 
                return `${model_name}${percentage_used}${data_units_read}${data_units_written}${power_on_time}${temperature}`;
            } else { 
                return `提示: 未安装硬盘或已直通硬盘控制器`;
            }
        }
    },

结束