Proxmox VE 小贴士

前言

上回书说到,与其加价购买树莓派,还不如直接在x86平台找方案。

这次我们就来说说x86架构主机做HomeLab基本都要用的Proxmox VE的一些小贴士。

无法启动安装器问题

安装镜像引导后长时间卡在Starting the installer GUI see tty2 (CTRL+ALT+F2) for any errors,在tty2可以看到无法进入framebuffer模式的描述

我的N100主机遇到了这个问题,原因是X11并不认识这个核显,GUI就不会启动。

解决起来很简单。

首先执行lspci| grep -i vga找到显卡的BusID,例如:

1
2
# lspci| grep -i vga
00:02.0 VGA compatible controller: Intel Corporation Device 46d1

接着在/usr/share/X11/xorg.conf.d/目录里新建一个配置文件,写入以下内容:

1
2
3
4
5
Section "Device"
Identifier "Card0"
Driver "fbdev"
BusID "pci0:00:0:2:"
EndSection

检查无误直接xinit就可以正常启动安装器。

CPU频率过高

Proxmox VE装好,一个vm都没有,风扇已经呼呼的吹,再看CPU完全是满载的温度。

通过cpufreq-info一看:

1
2
3
4
5
6
7
8
9
10
11
analyzing CPU 0:
driver: intel_pstate
CPUs which run at the same hardware frequency: 0
CPUs which need to have their frequency coordinated by software: 0
maximum transition latency: 4294.55 ms.
hardware limits: 700 MHz - 3.40 GHz
available cpufreq governors: performance, powersave
current policy: frequency should be within 700 MHz and 3.40 GHz.
The governor "performance" may decide which speed to use
within this range.
current CPU frequency is 2900 MHz.

完全不慌,我们把governor改成powersave不就好了?

不好,没有用。

那我们把turbo boost禁用了看看:

1
# echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo
1
2
3
4
5
6
7
8
9
10
11
analyzing CPU 0:
driver: intel_pstate
CPUs which run at the same hardware frequency: 0
CPUs which need to have their frequency coordinated by software: 0
maximum transition latency: 4294.55 ms.
hardware limits: 700 MHz - 3.40 GHz
available cpufreq governors: performance, powersave
current policy: frequency should be within 700 MHz and 3.40 GHz.
The governor "performance" may decide which speed to use
within this range.
current CPU frequency is 800 MHz.

是不是好多了?

不好,频率上不去了。/sys/devices/system/cpu/cpu*X*/cpufreq/scaling_min_freq/sys/devices/system/cpu/cpu*X*/cpufreq/scaling_man_freq两个参数居然一样

我们还是先回到启用turbo boost和powersave的情况,然后只需要做一件事:安装acpi

好了,你的p-state调度又如丝般顺滑了。

别问我为什么,按说intel_pstate驱动是不依赖acpi的。

注:有一些文档建议直接禁用intel_pstate驱动,因为acpi_cpufreq驱动有类似ondemand的governor可选,我觉得大可不必,只要能调度就行,intel_pstate的powersave本身就是干这个的。

异机迁移

如果你有vm需要从旧pve主机迁移至新主机,而你又不信任pve的集群功能,pve提供了一个非常实用的异机迁移命令qm remote-migrate

准备新主机

首先新主机的PVE应该安装妥当,存储容量要够,网络要通。

执行pvenode cert info记录主机的fingerprint。

创建一个API Token,记录好令牌信息。

准备vm

  • 删除全部快照
  • 移除各种直通

开始迁移

直接来看命令怎么说

1
2
3
qm remote-migrate <vmid> [<target-vmid>] <target-endpoint> --target-bridge <string> --target-storage <string> [OPTIONS]

Migrate virtual machine to a remote cluster. Creates a new migration task. EXPERIMENTAL feature!

这里面最复杂的就是<target-endpoint>部分:

1
<target-endpoint>: apitoken=<A full Proxmox API token including the secret value.> ,host=<Remote Proxmox hostname or IP> [,fingerprint=<Remote host's certificate fingerprint, if not trusted by system store.>] [,port=<integer>]

我们需要提供新主机的IP地址,API Token和fingerprint

搞好的命令就应该是这样子:

1
2
3
4
5
qm remote-migrate 源vmid 目的vmid \
'host=192.168.6.250,apitoken=PVEAPIToken=root@pam!你定义的令牌名称=令牌,fingerprint=主机fingerprint' \
--target-bridge vmbr0 \
--target-storage local-lvm \
--online

–online参数只在在线迁移时使用。是的,vm是可以主机不在同一个集群并在线迁移的。

收尾工作

迁移完成后,旧主机上还会显示这些vm,但是带有一个提醒你已经迁移的图标,这个时候你就可以删掉这些vm了。

在新的主机上重新配置那些直通。

Windows的vm在线迁移大概率会蓝屏,记得重启。

硬盘直通

如果你只是准备把一块硬盘直通给vm,并不打算直通整个SATA控制器跑一个TrueNAS:

1
qm set 102 -scsi2 /dev/disk/by-id/ata-SanDisk_SDSSDXPS480G_xxx

-scsi2也可以用别的总线和序号,只要Guest OS支持就行。

答应我,好吗,别通更多硬盘了,别在PVE里跑黑群晖,再在黑群晖里跑docker。