Xcp-ng and zfs, needs modprobe and remount pool every boot

I’ve been trying to install a XCP-NG instance on my lab, with a ZFS pool as backend storage

After the installation of XCP-NG, following the guides on xcp website, i do

yum install zfs
modprobe zfs
reboot

after reboot

modprobe zfs
zpool create -f -o ashift=12 -m /mnt/zfs tank raidz  /dev/sda /dev/sdb /sdv/sdc
zfs set compression=lz4 tank
xe sr-create type=zfs content-type=user name-label=localZFS device-config:location/mnt/zfs

at this point the pool is created and it is showing as a storage in ZFS which I can create new VMs normally.

Upon rebooting though, I lost all my configuration:

  • ZFS modules is not loaded. Need to modprobe zfs again
  • The SR shows no PBD attached
  • zpool import tank returns no pool available
  • nothing is mounted on /mnt/zfs

to fix it, I need:

modprobe zfs
zpool import -a -d /dev/sda
xe sr-forget uuid=[localZFS uuid]
xe sr-create type=zfs content-type=user name-label=localZFS device-config:location/mnt/zfs

And reconfigure all the VMs to look at the new SR

Is it something wrong I’m doing while building the zpool? Which information I need to help troubleshoot this?

1 Like

im not familiar with xcp-ng but if it uses dracut… maybe rebuild the initramfs might help?

1 Like

Same thing happened to me. Installing the package and rebooting did not make the module auto load. The doccumentation says it will auto load.
After creating the zpool and doing ‘xe sr-create …’ it did load on reboot.
I’m on xcp-ng 8.2.1 (latest as of writing).

1 Like

You need to create a dataset, after you have a dataset created, ZFS module will be loaded at boot.

github. com/xcp-ng/xcp/issues/192#issuecomment-501192530

As of now created a storage and you gave it the whole pool.

So do zfs create tank/ZFSstorage

then change

device-config:location/mnt/zfs/ZFSstorage

It now points to the dataset.

2 Likes

thanks. i think i got it.

I initially thought that the pool could work as a dataset ;).
Thank you for the help

pool is everything. You can create filesystems at will by creating a dataset with your preferred properties. It usually makes sense to create multiple dataset for different types of data and purposes, also to save space and get more performance. I have 17 datasets on my server (+30 or so zvols) and 26 on my laptop. Limit is 2^48 datasets and thus mountpoints, so make use of it.

With only one dataset, you’re also limited in snapshots/backup, as you have to rollback the entire pool where a special dataset/zvol for a VM is all you need to rollback the VM.

Limit on the amount of datasets is 2^48, so there is no need to not use them.

1 Like