How to mount point a drive onto a VM?

brooklyngrit

Member
May 20, 2023
9
0
6
I have a VM of docker running. I need to mount my zfs drive to it that's currently /mnd/disc1
I just need my docker apps to be able to see this drive

How do I do this in a Virtual Machine?
Usually on an LXC, I do:
Code:
mp0: /mnt/disc1,mp=/mnt/disc1
 
The same way you'd point your docker apps config to a designated place, in your case im guessing /mnt/disc1/(container_name)/config. Please elaborate
 
How do I do this in a Virtual Machine?
Usually on an LXC, I do:
VMs are very different than LXCs. VMs are physically isolated from the host using their own kernel/OS as opposed to LXCs that while they are containerized & have limited access to the host, they are in fact running on the host & its' kernel. This difference is the reason that sharing host data resources differs greatly between an LXC to a VM. So while a simple host mountpoint can be used with an LXC - this is not the case for a VM. You can visualize this like the VM would be running bare-metal on a different host - you won't be able to simply access/mount a data resource from a different host.

Your options:

1. Create an NFS/SMB/CIFS share on the required host data resource, & then access that in the VM.
2. Use Virtiofs - which has been made available since PVE 8.4. See here.

Virtiofs is a type of shared file system that lets VMs access a directory tree on the host. The upside of Virtiofs is that it does not use the NW stack for its access, so performance could be better that the NFS/SMB/CIFS share option.

You can search these forums on Virtiofs implementation - but basically what you do is add a Directory Mapping on the host & then add that to the VM's hardware using Virtiofs. This can all be done in the GUI.

Note: I don't personally use virtiofs although there are many users out there who do.

Good luck.