How to add zfs data disk to vm

juju01

Member
May 16, 2020
87
3
13
I am sure this has been asked quite a bit, but I dont quite understand it. I have a zfs pool setup on a disk I intended to use as a data storage disk for my containers and vms. ( not for images or backups ). On a container, I am able to use a bind mount. How is this done on a VM?

I just created a vm to use as a dvr server. I'd like to setup storage for the dvr server on my zfs pool ( called "databank" ) and alllocate about 200G for dvr recording storage. Not sure how to do that.
 
It doesn't. You have to set up an NFS, CIFS ot iSCSI share or use a cluster file system that the VM can connect to or you assign another disk that lives on the zfs, but then the data will only be visible from inside the VM.
 
Last edited:
It doesn't. You have to set up an NFS, CIFS ot iSCSI share or use a cluster file system that the VM can connect to or you assign another disk that lives on the zfs, but then the data will only be visible from inside the VM.

Clear as mud - so to allocate space for data storage to a VM using a zfs pool,
  1. setup the zfspool ( I have the pool called "databank", then a zfs partion called "local-zfs-databank")
  2. create an nfs share on top of "local-zfs-databank "?
or do i setup an nfs server? I will appreciate a bit more detail. I am still lost. Can you point me to a guide for dummies on this one?
 
Last edited:
You will need to setup a NFS server first. Then you can create a NFS share using /etc/fstab or "zfs set sharenfs=on pool-name".

You also could create a NAS-LXC and bind-mount that ZFS dataset into that LXC so the NAS-LXC can act as a SMB/NFS server where your VMs can connect to.
 
You will need to setup a NFS server first. Then you can create a NFS share using /etc/fstab or "zfs set sharenfs=on pool-name".

You also could create a NAS-LXC and bind-mount that ZFS dataset into that LXC so the NAS-LXC can act as a SMB/NFS server where your VMs can connect to.

I am sorry but this is still above my head. My basic question is - how do I attach storage to my VM for storing content like movies , files etc? I have a synology NAS where I can setup an ISCSI target or an NFS share ( means I dont need an nfs server, right?). But not sure what to do after that.

I tried setting up an nfs share with my synology. If i attached the NFS share to the vm, I dont see the nfs folders on synology on my vm .

Is there a guide I can follow? the answers above are generalized and vague to get me anywhere.
 
If you create an NFS share on another storage (your NAS for example) then you can't attach it to the VM but you rather have to connect to the share from inside the VM.
Install nfs-common and mount it with mount -t nfs 192.168.x.z:/share /path/to/mountpoint -o vers=4.2,noatime,soft

The same goes for an iSCSI target.
 
Last edited:
If you create an NFS share on another storage (your NAS for example) then you can't attach it to the VM but you rather have to connect to the share from inside the VM.
Install nfs-common and mount it with mount -t nfs 192.168.x.z:/share /path/to/mountpoint -o vers=4.2,noatime,soft

The same goes for an iSCSI target.

@ph0x - Must thank you for helping with this. Got it to work! I setup an nfs share on the synology ( which was using v4.1), then used your code above with slight modification.

How will this work if I used the iSCSI target ? I am able to set the LUN/target on the synology but how is it mounted to a mountpoint on the VM?

Though this is working, leaves me confused about when I am to use the storage setup function on the proxmox gui ( datacenter -> storage - nfs/iscsi etc..) . Isnt that for hooking up external storage devices too?
 
iSCSI is a bit more complicated ...

https://www.cyberciti.biz/faq/howto-setup-debian-ubuntu-linux-iscsi-initiator/

The storage function in Proxmox is used to define a storage that is already existing. Especially with remote storages like NFS, how should Proxmox be able to set them up?

Not sure what you mean by "storage that is already existing". What if I wanted to make the storage on my synology NAS available to the proxmox host globally ( i.e available to all containers and VMs). Do I need to mount each one directly individually? Isnt that what the storage function is for?
 
I meant the physical storage has to exist, like the NFS share or the iSCSI target, Proxmox can't to that.
But as soon as the storage definition exists it can be used for whatever it was marked for (vm images, iso templates, and so on).
If you check the "shared" box, the storage will even be accessible for the whole cluster (if you have one).
Sorry for the confusion.
 
I meant the physical storage has to exist, like the NFS share or the iSCSI target, Proxmox can't to that.
But as soon as the storage definition exists it can be used for whatever it was marked for (vm images, iso templates, and so on).
If you check the "shared" box, the storage will even be accessible for the whole cluster (if you have one).
Sorry for the confusion.

so if I wanted to make the shared folder on the Synology globally available to containers and VMs on the proxmox host , how will I do that , instead of mounting it directly into the individual vm like you showed me above ?

I know how to set it up via datacenter -> storage. Where I get lost is how to make it available to a particular vm from there. Is it as simple as adding it as an extra hard drive on the VM ?
 
If you want the VM to use the NFS share, you have to connect from inside the VM and can't use the storage tab of Proxmox. And yes, you have to do that with every VM that should use the share.
If you want the NFS share to be used by Proxmox to put VM images there, you define the storage and put a disk for the VM on it (i.e. add a disk to the VM with the NFS share as the storage backend). The VM then doesn't know about NFS, it just sees a disk.
 
Last edited:
IMHO the best way is to use bind mount once host-mounted NFS directory into CTs' disks, so you don't need to NFS mount in every individual CTs'.

But I need a good solution like bind mount, but for VMs (not CTs) especially for Windows ones.
Key point of bind mount is to not loose volume data when destroying CT/VM (like with ordinary virtual disk volumes attached).

Another bad thing with NFS/CIFS/SMB is network layer overhead and some hardcoded limitations (Windows SMB connections per user), so I'm looking for alternative solutions. NFS may be the case (another protocol) but lacks NFSv4 and UTF support even in Windows 10/ Server 2019 client side.

May be iSCSI is better way given its connection from whole VM OS instead of every individual Windows user account... and iSCSI is block device, but I need to have the per-file access to it (NTFS) from PVE host /another CT (Linux) to nightly backup only some files, not whole iSCSI volume.
 

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!