I am trying to configure LXD to use an existing ZFS pool but LXD somehow cannot find the pool although it does exists.
The computer has only one physical disk with multiple partitions. The ZFS pool has been created to use one of those partitions.
$ sudo zpool create lxd_pool /dev/nvme0n1p11
$ sudo zpool list
NAME SIZE ALLOC FREE CAP DEDUP HEALTH ALTROOT
lxd_pool 97.5G 400K 97.5G 0% 1.00x ONLINE -
$ sudo zpool status -v
pool: lxd_pool
state: ONLINE
scrub: none requested
config:
NAME STATE READ WRITE CKSUM
lxd_pool ONLINE 0 0 0
nvme0n1p11 ONLINE 0 0 0
errors: No known data errors
$ sudo zfs list -t all
NAME USED AVAIL REFER MOUNTPOINT
lxd_pool 364K 96.0G 112K /lxd_pool
$ ls -lah /lxd_pool
total 13K
drwxr-xr-x 2 root root 2 Oct 12 16:48 .
drwxr-xr-x 28 root root 4.0K Oct 12 16:48 ..
$ sudo snap list | grep lxd
lxd 3.5 9010 stable canonical✓ -
When configuring LXD, the ZFS pool is not found…
$ sudo lxd init
Would you like to use LXD clustering? (yes/no) [default=no]:
Do you want to configure a new storage pool? (yes/no) [default=yes]:
Name of the new storage pool [default=default]: lxd_zfs
Name of the storage backend to use (btrfs, ceph, dir, lvm, zfs) [default=zfs]:
Create a new ZFS pool? (yes/no) [default=yes]: no
Name of the existing ZFS pool or dataset: lxd_pool
Would you like to connect to a MAAS server? (yes/no) [default=no]:
Would you like to create a new local network bridge? (yes/no) [default=yes]: no
Would you like to configure LXD to use an existing bridge or host interface? (yes/no) [default=no]: yes
Name of the existing bridge or host interface: lxdbr0
Would you like LXD to be available over the network? (yes/no) [default=no]:
Would you like stale cached images to be updated automatically? (yes/no) [default=yes]
Would you like a YAML "lxd init" preseed to be printed? (yes/no) [default=no]:
Error: Failed to create storage pool 'lxd_zfs': cannot open 'lxd_pool': dataset does not exist
I have tried with lxd_pool/lxd as suggested but without success. See below for details.
$ sudo lxd init
Would you like to use LXD clustering? (yes/no) [default=no]:
Do you want to configure a new storage pool? (yes/no) [default=yes]:
Name of the new storage pool [default=default]: lxd_zfs
Name of the storage backend to use (btrfs, ceph, dir, lvm, zfs) [default=zfs]:
Create a new ZFS pool? (yes/no) [default=yes]: no
Name of the existing ZFS pool or dataset: lxd_pool/lxd
Would you like to connect to a MAAS server? (yes/no) [default=no]:
Would you like to create a new local network bridge? (yes/no) [default=yes]: no
Would you like to configure LXD to use an existing bridge or host interface? (yes/no) [default=no]: yes
Name of the existing bridge or host interface: lxdbr0
Would you like LXD to be available over the network? (yes/no) [default=no]:
Would you like stale cached images to be updated automatically? (yes/no) [default=yes]
Would you like a YAML "lxd init" preseed to be printed? (yes/no) [default=no]:
Error: Failed to create storage pool 'lxd_zfs': Failed to create ZFS filesystem: cannot create 'lxd_pool/lxd': no such pool 'lxd_pool'
I think that you have created a ZFS filesystem in that partition and LXD somehow cannot create the pool in there.
Is that partition meant to be used only for LXD?
If that is the case, then you can use zfs destroy to clear everything up.
Finally, you can run sudo lxd init again, and specify the block device for LXD to create the ZFS pool (as in /dev/sda7 or something).
Yes, this partition is meant to be used for LXD only. I encounter this problem on my development machine, which has LXD installed with Snap. As a result the default storage location would end up to be on the root device. With this change, I simply want to move the storage to another partition in order to avoid that the storage device clogs up the root device and renders the machine unbootable.
Actually, this worked!
$ sudo lxd init
Would you like to use LXD clustering? (yes/no) [default=no]:
Do you want to configure a new storage pool? (yes/no) [default=yes]:
Name of the new storage pool [default=default]: lxd_zfs
Name of the storage backend to use (btrfs, ceph, dir, lvm, zfs) [default=zfs]:
Create a new ZFS pool? (yes/no) [default=yes]: yes
Would you like to use an existing block device? (yes/no) [default=no]: yes
Path to the existing block device: /dev/nvme0n1p11
Would you like to connect to a MAAS server? (yes/no) [default=no]: no
Would you like to create a new local network bridge? (yes/no) [default=yes]: no
Would you like to configure LXD to use an existing bridge or host interface? (yes/no) [default=no]: yes
Name of the existing bridge or host interface: lxdbr0
Would you like LXD to be available over the network? (yes/no) [default=no]:
Would you like stale cached images to be updated automatically? (yes/no) [default=yes]
Would you like a YAML "lxd init" preseed to be printed? (yes/no) [default=no]: