硬盘直通
在做硬盘直通之前,在trueNas(或者其他虚拟机)内是检测不到安装的硬盘的。
在pve节点查看硬盘信息
打开pve的shell控制台
输入下面的命令查看硬盘信息:
ls -l /dev/disk/by-id/
该命令会显示出实际所有的硬盘设备信息,其中ata代表sata盘,类似的还有nvme等
root@pve:~# ls -l /dev/disk/by-id
total 0
lrwxrwxrwx 1 root root 9 Feb 17 21:19 ata-ST4000VX013-2XG104_WFN816PA -> ../../sda
lrwxrwxrwx 1 root root 9 Feb 17 21:19 ata-ST4000VX013-2XG104_WFN816TB -> ../../sdb
lrwxrwxrwx 1 root root 10 Feb 17 21:19 dm-name-pve-root -> ../../dm-1
lrwxrwxrwx 1 root root 10 Feb 17 21:19 dm-name-pve-swap -> ../../dm-0
lrwxrwxrwx 1 root root 10 Feb 17 21:19 dm-name-pve-vm--100--disk--0 -> ../../dm-6
lrwxrwxrwx 1 root root 10 Feb 17 21:19 dm-name-pve-vm--101--disk--0 -> ../../dm-7
lrwxrwxrwx 1 root root 10 Feb 17 21:19 dm-name-pve-vm--102--disk--0 -> ../../dm-8
lrwxrwxrwx 1 root root 10 Feb 17 21:19 dm-name-pve-vm--103--disk--0 -> ../../dm-9
lrwxrwxrwx 1 root root 10 Feb 17 21:19 dm-uuid-LVM-3mlYwviKP9a0AIpRl31t68XhLCx6ntFf14QZsXl4AB42wRAuJlsS98wd2gtXL2t5 -> ../../dm-7
lrwxrwxrwx 1 root root 10 Feb 17 21:19 dm-uuid-LVM-3mlYwviKP9a0AIpRl31t68XhLCx6ntFf3FP63YaM5mMZbHhSdwkdBqt4bxAHKK9z -> ../../dm-6
lrwxrwxrwx 1 root root 10 Feb 17 21:19 dm-uuid-LVM-3mlYwviKP9a0AIpRl31t68XhLCx6ntFf6WRT0hUylF3lxxBm8Nub89VXsKvBeaqK -> ../../dm-8
lrwxrwxrwx 1 root root 10 Feb 17 21:19 dm-uuid-LVM-3mlYwviKP9a0AIpRl31t68XhLCx6ntFfUI4wKjMH1zELCPMdvvXNMntZzWIU1d3x -> ../../dm-0
lrwxrwxrwx 1 root root 10 Feb 17 21:19 dm-uuid-LVM-3mlYwviKP9a0AIpRl31t68XhLCx6ntFfxjuK7aRpUpbp1tzXtoYBiqLRpYP5LvQh -> ../../dm-9
lrwxrwxrwx 1 root root 10 Feb 17 21:19 dm-uuid-LVM-3mlYwviKP9a0AIpRl31t68XhLCx6ntFfxWgMDanxMDPleCrHkmGbiVnpOzOvfEaV -> ../../dm-1
lrwxrwxrwx 1 root root 15 Feb 17 21:19 lvm-pv-uuid-lEznhG-6ksV-Les1-FoYP-ibHG-OC3R-u3MZ6f -> ../../nvme0n1p3
lrwxrwxrwx 1 root root 13 Feb 17 21:19 nvme-eui.0025388981b0b866 -> ../../nvme0n1
lrwxrwxrwx 1 root root 15 Feb 17 21:19 nvme-eui.0025388981b0b866-part1 -> ../../nvme0n1p1
lrwxrwxrwx 1 root root 15 Feb 17 21:19 nvme-eui.0025388981b0b866-part2 -> ../../nvme0n1p2
lrwxrwxrwx 1 root root 15 Feb 17 21:19 nvme-eui.0025388981b0b866-part3 -> ../../nvme0n1p3
lrwxrwxrwx 1 root root 13 Feb 17 21:19 nvme-SAMSUNG_MZVLB512HAJQ-000L2_S3RGNF0K900090 -> ../../nvme0n1
lrwxrwxrwx 1 root root 15 Feb 17 21:19 nvme-SAMSUNG_MZVLB512HAJQ-000L2_S3RGNF0K900090-part1 -> ../../nvme0n1p1
lrwxrwxrwx 1 root root 15 Feb 17 21:19 nvme-SAMSUNG_MZVLB512HAJQ-000L2_S3RGNF0K900090-part2 -> ../../nvme0n1p2
lrwxrwxrwx 1 root root 15 Feb 17 21:19 nvme-SAMSUNG_MZVLB512HAJQ-000L2_S3RGNF0K900090-part3 -> ../../nvme0n1p3
lrwxrwxrwx 1 root root 9 Feb 17 21:19 usb-VendorCo_Disk_3.0_0352091024222576332-0:0 -> ../../sdc
lrwxrwxrwx 1 root root 10 Feb 17 21:19 usb-VendorCo_Disk_3.0_0352091024222576332-0:0-part1 -> ../../sdc1
lrwxrwxrwx 1 root root 10 Feb 17 21:19 usb-VendorCo_Disk_3.0_0352091024222576332-0:0-part2 -> ../../sdc2
lrwxrwxrwx 1 root root 10 Feb 17 21:19 usb-VendorCo_Disk_3.0_0352091024222576332-0:0-part3 -> ../../sdc3
lrwxrwxrwx 1 root root 10 Feb 17 21:19 usb-VendorCo_Disk_3.0_0352091024222576332-0:0-part4 -> ../../sdc4
lrwxrwxrwx 1 root root 9 Feb 17 21:19 wwn-0x5000c500f157d407 -> ../../sdb
lrwxrwxrwx 1 root root 9 Feb 17 21:19 wwn-0x5000c500f157da0f -> ../../sda
我本次要进行硬盘直通的是如下两条记录:
lrwxrwxrwx 1 root root 9 Feb 17 21:19 ata-ST4000VX013-2XG104_WFN816PA -> ../../sda
lrwxrwxrwx 1 root root 9 Feb 17 21:19 ata-ST4000VX013-2XG104_WFN816TB -> ../../sdb
ata-ST4000VX013-2XG104_WFN816PA与 ata-ST4000VX013-2XG104_WFN816TB是对应的硬盘id。
硬盘直通
硬盘直通命令的格式为:
qm set <vm_id> –<disk_type>[n] /dev/disk/by-id/<type>-$brand-$model_$serial_number
这里涉及到了几个参数:
vm_id:填写虚拟机的id,例如我要给trueNas的虚拟机做直通,则取100
disk_type:直通模式,一般取scsi+0~10等
- b r a n d − brand- brand−model_$serial_number:直接填写硬盘id就好
我要挂载两个盘,所以此处使用两个命令:
1、qm set 100 -scsi1 /dev/disk/by-id/ata-ST4000VX013-2XG104_WFN816PA
2、qm set 100 -scsi2 /dev/disk/by-id/ata-ST4000VX013-2XG104_WFN816TB
分别在shell中执行上述两个命令:
root@pve:~# qm set 100 -scsi1 /dev/disk/by-id/ata-ST4000VX013-2XG104_WFN816PA
update VM 100: -scsi1 /dev/disk/by-id/ata-ST4000VX013-2XG104_WFN816PA
root@pve:~# qm set 100 -scsi2 /dev/disk/by-id/ata-ST4000VX013-2XG104_WFN816TB
update VM 100: -scsi2 /dev/disk/by-id/ata-ST4000VX013-2XG104_WFN816TB
此时在trueNas中已经可以显示这两块硬盘
创建trueNas存储池
因为只有两块硬盘,所以此时只能选择条带(感觉怪怪的这个名)和镜像,
这里的条带应该类似于raid0,而镜像则类似于raid1.
而且随着硬盘数的增加将会有更多的选择。
填写存储池名字,点击新建:
会删除硬盘全部内容:
成功创建存储池: