Mount zfs pool on node from linux vm for data storage

Dec 24, 2016
19
3
8
I want to set up a nextcloud server on an Ubunutu VM and use a zpool on the node for the nextcloud data storage. I have created the zpool on the node and added it as storage for the VM but how do I mount it from the VM?
 
Sounds like you're trying to pass through the zpool filesystem to the vm and attach it from within the vm? Akin to something like a iscsi target/nfs share? Not quite sure it works like that in this implementation, though i could be mistaken.

When you create a zpool, add it to proxmox as storage, and you add vm + disk, proxmox will create a zfs volume within that zpool and directly attach that volume to the VM. So essentially, you are already "mounting" that zpools storage volume to your VM...just as a virtual disk/block device.

So if you create "zpool001/foo" and define it as storage, then create a vm., call it vmid 100.
You'll get a volume called "zpool001/foo/vm-100-disk-1" which attaches directly to the VM.
Goes the same for if you add another pool...
"zpool002/foo", define it as storage, go to your vm, create a new disk, and point it at "zpool002/foo", then you'll get "zpool002/foo/vm-100-disk-2".

So you don't mount it from within the VM like you would an iscsi target/nfs mount, you just mount it as a new disk from the hypervisor side and it simply shows up as /dev/{v,d}d{a-z}....ect ect ect...

Sorry if I completely missed the mark here, i might have mis-understood what you're trying to accomplish.
 
Dmora, thanks for that. I am a newbie with linux. I see the dataset as a block device (sdb in my case pointing to proxmoxpoolr1/vm-102) but how do I create automatic mount point within the vm's file system. If I edit the fstab, I have to provide a type but (a) the version of ubuntu doesn't support zfs and (b) I can't imagine you would want to muck around with zfs from within the vm when the dataset was created on the node. I suspect the answer is obvious, just not to me.
 
The VM doesn't know that its a ZFS vol, it just knows its a block device, so just go about your normal business with mounting it....
I think you're over thinking it

So fstab is formatted like this:
# <file system> <mount point> <type> <options> <dump> <pass>

If you say you want to mount /dev/sdb, you'll want to use its UUID instead of /dev/sdb as that naming convention isn't static anymore.

Play by play:
Code:
# partition the disk
fdisk /dev/sdb

# format it
mkfs.ext4 /dev/sdb1

# record the UUID, you'll get something like this...
blkid | grep sdb1
/dev/sdb1: UUID="6f86ee0b-0fa1-4467-93ca-c94a9fdc65c7" TYPE="ext4"

# create the directory you want to mount it
mkdir /foo_bar

# edit fstab, and place your settings, again the format is the following separated by spacing
#  <file system> <mount point> <type> <options> <dump> <pass>
UUID="6f86ee0b-0fa1-4467-93ca-c94a9fdc65c7" /foo_bar ext4 default 0 0 

# force it to mount
mount -a

# see if it mounted
mount