2024年3月8日星期五

在PVE使用虚拟 USB 存储设备 + ARPL 引导 DSM

 

部分内容来自: https://blog.myds.cloud/archives/synoboot-usb-image-in-pve-virtual-machine.html


虚拟机建好之后,打开配置文件

nano /etc/pve/qemu-server/100.conf

在文件最开始的地方加入以下内容

args: -drive id=arpl,if=none,file=/root/arpl.img,format=raw,cache=none -device usb-storage,drive=arpl,removable=on,bootindex=1

(其中 file= 后面是 ARPL 镜像文件的位置,需按照实际情况填写。注意不能使用 iso/ 来访问 PVE 的镜像存储区域,只能使用绝对路径)

启动虚拟机,系统会进入 ARPL 引导器。



之前一直是在用sata硬盘格式的镜像当引导盘,启动虚拟机的群晖,硬件管理里面多出一个硬盘,看着不顺眼很久了。今天闲下来想好好解决这个问题,5.2版的PVE在网页管理界面没有添加USB镜像的选项。

先是看了一堆资料,终于找到了点眉目,在vm的配置文件添加如下参数。

args: -device 'piix3-usb-uhci,addr=0x18' -drive 'id=synoboot,file=/var/lib/vz/images/{VM_ID}/synoboot.img,if=none,format=raw'
    -device 'usb-storage,id=synoboot,drive=synoboot'

然后重启虚拟机,引导界面跑完后,在串口终端监控只看到了mount failed两个字,看来还是不行。

$: qm terminal 100

继续谷歌一堆,找到了另外一个解决办法,问题出在新版的虚拟机对USB控制器的型号支持,把piix3-usb-uhci改成qemu-xhci即可。

经测试,这解决办法是有效的,成功解决了USB镜像引导DSM6.2的问题了,配置参数如下:

args: -device 'qemu-xhci,addr=0x18' -drive 'id=synoboot,file=/var/lib/vz/images/{VM_ID}/synoboot.img,if=none,format=raw' -device 'usb-storage,id=synoboot,drive=synoboot,bootindex=1'

参考资料:
https://xpenology.com/forum/topic/7387-tutorial-dsm-6x-on-proxmox/
https://xpenology.com/forum/topic/13941-installation-failed-in-kvm-with-juns-loader-104b/







2024年1月7日星期日

pve虚拟机加console

 add `serial0: socket` to the {VM_ID}.conf and then use qm terminal {VM_ID} to connect to the console

This will let you see the bootstrap, see potential issues, login via tty and also see installation/migration progress steps







2024年1月6日星期六

PROXMOX 把local-lvm空间转到local

 


 lvremove pve/data

 lvextend -l +100%FREE -f pve/root

 resize2fs /dev/mapper/pve-root



1、备份虚拟机
2、删除虚拟机
3、删除local-lvm
命令:lvremove pve/data
4、把local-lvm空间分配给Local
命令:lvextend -l +100%FREE -r pve/root
5、删除local-lvm
数据中心-存储-删除local-lvm
6、编辑local,内容里添加 磁盘映像和容器
7、恢复虚拟机

















2023年10月2日星期一

pve主机退出集群

其它主机先运行 

pvecm node

pvecm delnode pveName

自已运行

systemctl stop pve-cluster.service
systemctl stop corosync.service
pmxcfs -l
rm /etc/pve/corosync.conf
rm -rf /etc/corosync/*
killall pmxcfs
systemctl start pve-cluster.service








2023年9月24日星期日

pve直通时遇到多个PCI设置在同一组时出现:failed to open /dev/vfio/1: Device or resource busy

 

Proxmox already contains the ACS override patches, so you can just add the pcie_acs_override=downstream or if necessary pcie_acs_override=downstream,multifunction kernel parameters to GRUB or systemd-boot (please check the PVE manual to find out which is used in your case). It usually "breaks" all IOMMU group and there allows you to ignore security isolation of the IOMMU groups. PCI(e) devices can do DMA (DIrect memory access, as in reading and writing any part of the VM memory) and talk to other PCI(e) devices in the same group. This is a security issue and your should not use it if you run untrusted software or allow untrusted users to access your VMs. Also, there are no guarantees that it will work. It just allows you to ignore ACS as your own risk.


查询直通分组信息:

 for d in /sys/kernel/iommu_groups/*/devices/*; do n=${d#*/iommu_groups/*}; n=${n%%/*}; printf 'IOMMU group %s ' "$n"; lspci -nns "${d##*/}"; done







nvidia 修改风扇转速方法

转自 https://github.com/andyljones/coolgpus 




./pip install wheel
pip install coolgpus
sudo $(which coolgpus) --speed 99 99

If you hear your server take off, it works! Now interrupt it and re-run either with Sensible Defaults (TM),

sudo $(which coolgpus)

or you can pass your own fan curve with

sudo $(which coolgpus) --temp 17 84 --speed 15 99 

This will make the fan speed increase linearly from 15% at <17C to 99% at >84C. You can also increase --hyst if you want to smooth out oscillations, at the cost of the fans possibly going faster than they need to.

Piecewise Linear Control

More generally, you can list any sequence of (increasing!) temperatures and speeds, and they'll be linearly interpolated:

sudo $(which coolgpus) --temp 20 55 80 --speed 5 30 99

Now the fan speed will be 5% at <20C, then increase linearly to 30% up to 55C, then again linearly to 99% up to 80C.

systemd

If your system uses systemd and you want to run this as a service, create a systemd unit file at /etc/systemd/system/coolgpus.service as per this template:

[Unit]
Description=Headless GPU Fan Control
After=syslog.target

[Service]
ExecStart=/home/ajones/conda/bin/coolgpus --kill 
Restart=on-failure
RestartSec=5s
ExecStop=/bin/kill -2 $MAINPID
KillMode=none 

[Install]
WantedBy=multi-user.target

You just need to sub in your own install location (which you can find with which coolgpus), and any flags you want. Then enable and start it with

sudo systemctl enable coolgpus
sudo systemctl start coolgpus









2023年7月18日星期二

PVE通过arpl安装黑群


1、默认方式新建虚拟机,不要硬盘

2、qm importdisk 103 /var/lib/vz/template/iso/arpl.img local-lvm

    man qm

3、转换后把生成的unused Disk从scsi控制器转成 sata

4、查询主机的硬盘控制器,可以通过lspci命令

    一般来说,带SCSI /SATA字样的都是磁盘控制器

5、查看硬盘所属硬盘控制器

    ls -la /sys/dev/block/|grep -v loop |grep -v dm

不知道pve所在的硬盘。可以使用命令lsblk查看,有pve-root的,便是pve所在的硬盘

6、硬盘直通方法(这是控制器直通的方法)

第一步:确认自己的主板CPU是否支持Vt-d功能

不支持就搞不了直通。intel要b75以上芯片组才支持。也就是说intel4代酷睿处理器以上,都支持。amd不明。

VT-D是io虚拟化。不是VT-X,

要开启vt-d才能io虚拟化。AMD平台是iommu,某些OEM主板上叫SRIOV。请注意。


第二步:开启iommu

#编辑grub,请不要盲目改。根据自己的环境,选择设置

vi /etc/default/grub

#在里面找到:

GRUB_CMDLINE_LINUX_DEFAULT="quiet"

#然后修改为:

GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_iommu=on iommu=pt"

#如果是amd cpu请改为:

GRUB_CMDLINE_LINUX_DEFAULT="quiet amd_iommu=on iommu=pt"

#如果是需要显卡直通,建议在cmdline再加一句video=vesafb:off video=efifb:off video=simplefb:off,加了之后,pve重启进内核后停留在一个画面,这是正常情况

GRUB_CMDLINE_LINUX_DEFAULT="quiet amd_iommu=on iommu=pt video=vesafb:off video=efifb:off video=simplefb:off"


修改完成之后,直接更新grub 


update-grub

注意,如果此方法还不能开启iommu,请修改 


 /etc/kernel/cmdline文件


并且使用proxmox-boot-tool refresh 更新启动项


        Rebuild the UEFI with

Code:
update-initramfs -u -k all
pve-efiboot-tool refresh






第三步 加载相应的内核模块

echo vfio >> /etc/modules

echo vfio_iommu_type1 >> /etc/modules

echo vfio_pci >> /etc/modules

echo vfio_virqfd >> /etc/modules

使用update-initramfs -k all -u命令更新内核参数


重启主机


第四步 验证是否开启iommu

重启之后,在终端输入


dmesg | grep iommu

出现如下例子。则代表成功


[ 1.341100] pci 0000:00:00.0: Adding to iommu group 0

[ 1.341116] pci 0000:00:01.0: Adding to iommu group 1

[ 1.341126] pci 0000:00:02.0: Adding to iommu group 2

[ 1.341137] pci 0000:00:14.0: Adding to iommu group 3

[ 1.341146] pci 0000:00:17.0: Adding to iommu group 4

此时输入命令


find /sys/kernel/iommu_groups/ -type l 

#出现很多直通组,就代表成功了。如果没有任何东西,就是没有开启

7、返回PVE的虚拟机,添加PCI设备, 在raw device上找刚才看到sata的id

查看硬盘控制器iommu分组

 find /sys/kernel/iommu_groups/ -type l


Create a file like /etc/modprobe.d/vfio.conf setting the allow_unsafe_interrupts option for the vfio module.

options vfio_iommu_type1 allow_unsafe_interrupts=1

Otherwise you’ll get an error when trying to start a VM with a PCI device passed through: “failed to set iommu for container: Operation not permitted”

Apparently the IOMMU interrupt remapping is kinda broken on this platform.





一:RDM磁盘直通

RDM磁盘直通,不需要开启iommu。只能在PVE命令行中添加。

我们可以通过下面命令,列出当前的硬盘列表

ls -la /dev/disk/by-id/|grep -v dm|grep -v lvm|grep -v part

如下面的例子

  • root@pve:~# ls -la /dev/disk/by-id/|grep -v dm|grep -v lvm|grep -v part
  • total 0
  • drwxr-xr-x 2 root root 540 Apr 28 16:39 .
  • drwxr-xr-x 6 root root 120 Mar 3 15:52 ..
  • lrwxrwxrwx 1 root root 13 Apr 28 16:39 nvme-eui.01000000010000005cd2e431fee65251 -> ../../nvme2n1
  • lrwxrwxrwx 1 root root 13 Mar 3 15:52 nvme-eui.334843304aa010020025385800000004 -> ../../nvme1n1
  • lrwxrwxrwx 1 root root 13 Apr 28 17:36 nvme-eui.334843304ab005400025385800000004 -> ../../nvme0n1
  • lrwxrwxrwx 1 root root 13 Apr 28 16:39 nvme-INTEL_SSDPE2KX020T8_BTLJ039307142P0BGN -> ../../nvme2n1
  • lrwxrwxrwx 1 root root 13 Mar 3 15:52 nvme-SAMSUNG_MZWLL800HEHP-00003_S3HCNX0JA01002 -> ../../nvme1n1
  • lrwxrwxrwx 1 root root 13 Apr 28 17:36 nvme-SAMSUNG_MZWLL800HEHP-00003_S3HCNX0JB00540 -> ../../nvme0n1
  • lrwxrwxrwx 1 root root 9 Mar 3 15:52 scsi-35000c500474cd7eb -> ../../sda
  • lrwxrwxrwx 1 root root 9 Mar 3 15:52 wwn-0x5000c500474cd7eb -> ../../sda

nvme开头的是nvme硬盘,ata开头是走sata或者ata通道的设备。,scsi是scsi设备-阵列卡raid或者是直通卡上的硬盘。

我们可以通过qm set <vmid> --scsiX /dev/disk/by-id/xxxxxxx 进行RDM直通

例如你有一个虚拟机,虚拟机的vmid是101,--scsiX,这里的X是整数,最多为如果你不清楚vmid这个是什么含义,你可以参考下面文章

认识虚拟机VMID的作用

你打算直通intel的一个nvme硬盘,那么你可以使用下面命令

  • qm set 101 --scsi1 /dev/disk/by-id/nvme-INTEL_SSDPE2KX020T8_BTLJ039307142P0BGN

执行之后,你可以在面板中看到下面这个硬盘。



当然,你也可以使用ide或者sata形式直通硬盘,如下

qm set 101 --sata1 /dev/disk/by-id/nvme-INTEL_SSDPE2KX020T8_BTLJ039307142P0BGN

qm set 101 --ide1 /dev/disk/by-id/nvme-INTEL_SSDPE2KX020T8_BTLJ039307142P0BGN

建议为scsi设备,这样性能理论上是最优秀的。

需要注意的是,scsi会有序号,如scsi1,scsi0。在操作之前,应该要知道哪些scsi号是空的。对于pve来说,sata最多有6个设备。如果要使用sata类型直通,请勿超过sata5.

如果想要了解什么最多6个sata,请参考

https://www.intel.com/content/dam/www/public/us/en/documents/product-briefs/q35-chipset-brief.pdf



如果需要取消直通,可以使用命令qm set <vmid> --delete scsiX

如上面的例子,你应该输入

qm set 101 --delete scsi1

出现update 即代表成功。可返回网页上查看。

  • root@pve:~# qm set 101 --delete scsi1
  • update VM 101: -delete scsi1

 





在PVE使用虚拟 USB 存储设备 + ARPL 引导 DSM

  部分内容来自: https://blog.myds.cloud/archives/synoboot-usb-image-in-pve-virtual-machine.html 虚拟机建好之后,打开配置文件 nano /etc/pve/qemu-server/100.conf ...