Filesystem Selection and HDD passthrough

Technoob9

Member
Aug 10, 2023
49
1
8
Perhaps a stupid question... But if I plan to pass a HDD to a VM or container (e.g., Plex media storage), is it not advised to set up a filesystem (e.g., ZFS single disk) before passing it through? E.g.,

1701731627983.png

Does this cause errors? Increase wear?
 
That will partition, format, mount and add the disk as a storage on the PVE node. Mounting a filesystem on the PVE host as well as via passthrough in a VM will corrupt data. So make sure never to mount a filesystem on the PVE host you want to passthrough. For LXC with bind-mounts a directory storage could be fine but I still would prefer to manually partition, format and mount those disks.
 
That will partition, format, mount and add the disk as a storage on the PVE node. Mounting a filesystem on the PVE host as well as via passthrough in a VM will corrupt data. So make sure never to mount a filesystem on the PVE host you want to passthrough. For LXC with bind-mounts a directory storage could be fine but I still would prefer to manually partition, format and mount those disks.
Oh interesting, thanks for the clarification. But when I add a new HDD to host, wipe disk, the drive doesn't show up when I try to passthrough the hdd to my VM.

Another question - I keep seeing the term "virtual disks". From my understanding all of this is virtualized? Or is this something else?
 
Last edited:
Another question - I keep seeing the term "virtual disks". From my understanding all of this is virtualized? Or is this something else?
Depends..,
When using PCI passthrough of NVMe SSD or a HBA with disks attached to it, the VM will work directly with the real physical disks.
"Virtual disk" usually means there is an additional abstaction layer. You won't use physical disks or partitions but Zvols, LVs (thin or thick), qcow2 image files and so on and the guestOS will see an virtualized QEMU disk.
When using disk passthrough (qm set ...) this is something in between. It's actually also a virtual disk but this virtual disk isn't using some LVs, zvols or image files underneath it but it will map the virtual disk to the physical disk or partition. So still a virtual disk but thw data is read/written on block level to the physical device.
 
Depends..,
When using PCI passthrough of NVMe SSD or a HBA with disks attached to it, the VM will work directly with the real physical disks.
"Virtual disk" usually means there is an additional abstaction layer. You won't use physical disks or partitions but Zvols, LVs (thin or thick), qcow2 image files and so on and the guestOS will see an virtualized QEMU disk.
When using disk passthrough (qm set ...) this is something in between. It's actually also a virtual disk but this virtual disk isn't using some LVs, zvols or image files underneath it but it will map the virtual disk to the physical disk or partition. So still a virtual disk but thw data is read/written on block level to the physical device.

Thanks for the explanation on virtual disk.

I am still having the issue in that once I wipe the disk (and do nothing else), and I try to add the hdd to a VM in the GUI, it doesn't show up. Do I need to just do it via command line from the host? I understand that I will have to set it up inside the VM (e.g., create the partition, add a filesystem like ZFS, etc).
 
You can partition the drive and passthrough only a partition.
I don't quite follow. From what I understand:

1. In the GUI, I can "initialize the hdd with GPT" in host, add a filesystem in host, then pass the drive through from host to a VM. This from what I understand is bad as discussed above.
2. So that leaves do everything via cli. So wipe the HDD, and don't do anything else. Then in the host shell, I can pass it through to the VM via qm set 592 -scsi2 /dev/disk/by-id/ata-ST3000DM001-1CH166_Z1F41BLC

Then on the VM, I can set up the partition table and filesystem.

Am I still misunderstanding?
 
2. So that leaves do everything via cli. So wipe the HDD, and don't do anything else. Then in the host shell, I can pass it through to the VM via qm set 592 -scsi2 /dev/disk/by-id/ata-ST3000DM001-1CH166_Z1F41BLC

Then on the VM, I can set up the partition table and filesystem.

Am I still misunderstanding?
You can also create a GPT and partition that disk in CLI using fdisk/parted/sgdisk and then only passthrough that partition. But I heard some people complaining that Windows doesn't like passthroughed partitions. But I had no problems when using linux guests.

By the way...that disk is terrible...so terrible that it got its own wiki article to document all the people suing Seagate for how fast it fails. I also got 4 of them where 2 failed within the first 3 years running 24/7. I would highly recommend not to use that disk without raid for redundancy: https://en.m.wikipedia.org/wiki/ST3000DM001
 
Last edited:
You can also create a GPT and partition that disk in CLI using fdisk/parted/sgdisk and then only passthrough that partition. But I heard some people complaining that Windows doesn't like passthroughed partitions. But I had no problems when using linux guests.

By the way...that disk is terrible...so terrible that it got its own wiki article to document all the people suing Seagate for how fast it fails. I also got 4 of them where 2 failed within the first 3 years running 24/7. I would highly recommend not to use that disk without raid for redundancy: https://en.m.wikipedia.org/wiki/ST3000DM001
Yeah this is a Ubuntu server VM. So if I am understanding, if I wanted to apply what I learned to my situation (14TB HDD):
1. In host, give the HDD a GPT partition
2. In host, create the partition with a filesystem - I want to use a ZFS filesystem. So 14TB minus 8GB?
3. In host, pass through this partition to my VM via the command above.

Is this right?

As for the drive, I just copied and pasted that from the wiki haha.
 
2. In host, create the partition with a filesystem - I want to use a ZFS filesystem. So 14TB minus 8GB?
Why minus 8GB? And no, I wouldn't format it on the host but format it on the guest OS after passing it through.
 
Doesn't the partition table take some space?
Yes, but at best a few kilobytes and not gigabytes.
Sorry, what is the sequence of steps you would do?
1.) backup stuff on hat disk you want to keep and unmount the disk in case it is in use
2.) do a secure_erase in case if it is a alreay used SSD so you start with a fresh and good performing factory resetted SSD that isn't leaking sensitive data that might still be on there
3.) create GPT/MBR using fdisk/parted
4.) create your partitions using fdisk/parted
5.) find out a unique identifier of that partition via ls -la /dev/disk/by-id and check what a free virtual disk identifier ("scsi1" etc) as well what protocol ("sata", "scsi", "ide", ...) should be used and what the VMID of that VM is
6.) passthrough that partition using "qm set ..."
7.) check and fix VMs boot order
8.) double check the partition doesn't get mounted via systemd/fstab/autofs on the next boot by the host and that the partition or disk isn't passthroughed to another VM
9.) start the VM
10.) format the partition via the guestOS
11.) mount the filesystem to the guestOS
12.) write down the command you used to passthrough that partition as a VM note so you can easily redo it in case you ever need to restore the VM from a backup (as it then has to be done again)
 
Last edited:
Yes, but at best a few kilobytes and not gigabytes.

1.) backup stuff on hat disk you want to keep and unmount the disk in case it is in use
2.) do a secure_erase in case if it is a alreay used SSD so you start with a fresh and good performing factory resetted SSD that isn't leaking sensitive data that might still be on there
3.) create GPT/MBR using fdisk/parted
4.) create your partitions using fdisk/parted
5.) find out a unique identifier of that partition via ls -la /dev/disk/by-id and check what a free virtual disk identifier ("scsi1" etc) as well what protocol ("sata", "scsi", "ide", ...) should be used and what the VMID of that VM is
6.) passthrough that partition using "qm set ..."
7.) check and fix VMs boot order
8.) double check the partition doesn't get mounted via systemd/fstab/autofs on the next boot by the host and that the partition or disk isn't passthroughed to another VM
9.) start the VM
10.) format the partition via the guestOS
11.) mount the filesystem to the guestOS
12.) write down the command you used to passthrough that partition as a VM note so you can easily redo it in case you ever need to restore the VM from a backup (as it then has to be done again)
Thanks :)
 
Yes, but at best a few kilobytes and not gigabytes.

1.) backup stuff on hat disk you want to keep and unmount the disk in case it is in use
2.) do a secure_erase in case if it is a alreay used SSD so you start with a fresh and good performing factory resetted SSD that isn't leaking sensitive data that might still be on there
3.) create GPT/MBR using fdisk/parted
4.) create your partitions using fdisk/parted
5.) find out a unique identifier of that partition via ls -la /dev/disk/by-id and check what a free virtual disk identifier ("scsi1" etc) as well what protocol ("sata", "scsi", "ide", ...) should be used and what the VMID of that VM is
6.) passthrough that partition using "qm set ..."
7.) check and fix VMs boot order
8.) double check the partition doesn't get mounted via systemd/fstab/autofs on the next boot by the host and that the partition or disk isn't passthroughed to another VM
9.) start the VM
10.) format the partition via the guestOS
11.) mount the filesystem to the guestOS
12.) write down the command you used to passthrough that partition as a VM note so you can easily redo it in case you ever need to restore the VM from a backup (as it then has to be done again)
So everything is working. But for some reason 49GB out of the 7TB I assigned is used without anything being on there. Is this due to the filesystem? Or system reserved?
 
So everything is working. But for some reason 49GB out of the 7TB I assigned is used without anything being on there. Is this due to the filesystem? Or system reserved?
Hard to tell without knowing what filesystem was used and output of something like df -h or fdisk -l. But filesystem overhead wouldn't be uncommon.
 
Yes, but at best a few kilobytes and not gigabytes.

1.) backup stuff on hat disk you want to keep and unmount the disk in case it is in use
2.) do a secure_erase in case if it is a alreay used SSD so you start with a fresh and good performing factory resetted SSD that isn't leaking sensitive data that might still be on there
3.) create GPT/MBR using fdisk/parted
4.) create your partitions using fdisk/parted
5.) find out a unique identifier of that partition via ls -la /dev/disk/by-id and check what a free virtual disk identifier ("scsi1" etc) as well what protocol ("sata", "scsi", "ide", ...) should be used and what the VMID of that VM is
6.) passthrough that partition using "qm set ..."
7.) check and fix VMs boot order
8.) double check the partition doesn't get mounted via systemd/fstab/autofs on the next boot by the host and that the partition or disk isn't passthroughed to another VM
9.) start the VM
10.) format the partition via the guestOS
11.) mount the filesystem to the guestOS
12.) write down the command you used to passthrough that partition as a VM note so you can easily redo it in case you ever need to restore the VM from a backup (as it then has to be done again)
Apologies for bumping up this thread - hope it's not considering too old yet!

Just going through similar to pass an EXT4 partition to an OpenMediaVault VM.

Q: Is there a reason to format the partition in step 10 for second time using the guestOS, when the same partition was essentially formatted in step 4 already?
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!