Create a zfs pool using a block device with lxc

With ‘lxd init’ I can create a zfs pool on a virgin block device (ex: /dev/sda5) with options ‘use existing pool’,
When I use lxc client (lxd-client) to create a pool with:

lxc storage create new_pool zfs
a loop device is used for this new pool

I found a way to create a zfs pool with existing block device is to create a new one with zpool command:

zpool create new_pool /dev/sda5

and use it with lxc client

lxc storage create prod zfs source=new_pool

Is there a way to do it in directly with lxc client ?

I believe you can specify the block device directly as the source, e.g.

lxc storage create prod zfs source=/dev/sda5
1 Like

Sorry, I tried this before and here is the output of your command

Error: Custom loop file locations are not supported

It seems that the client try to write a loop device in block device without FS…
I tried to specify the creation with the “same” format of zfs pool created by ‘lxd init’ without success:

lxc storage create prod zfs volatile.initial_source: /dev/sda5

Can you show stat /dev/sda5 when getting that error?
This message should only be printed if the path isn’t a valid block device.


After the manual creation of zfs pool on /dev/sda6 (not sda5 in real), I can delete & create a new pool with

lxc profile device remove prod root
lxc storage create prod zfs source=/dev/sda6

without error… :thinking:

Here is result of ‘blkid’

/dev/sda6: LABEL=“prod” UUID=“1333527625986315709” UUID_SUB=“11132811449451080359” TYPE=“zfs_member” PARTUUID=“97b4f963-06”

and ‘stat /dev/sda5’

  Size: 0               Blocks: 0          IO Block: 4096   block special file
Device: 6h/6d   Inode: 343         Links: 1     Device type: 8,6
Access: (0660/brw-rw----)  Uid: (    0/    root)   Gid: (    6/    disk)
Access: 2020-02-03 22:26:56.384814550 +0100
Modify: 2020-02-03 22:24:55.608021817 +0100
Change: 2020-02-03 22:24:55.608021817 +0100
 Birth: -

I will start again from fdisk, May be problem come from there. It seems that the deletion of pool by lxc let the block device with a good tag ?
See you soon

I’m very sorry for the noise… After a fdisk, it looks good again !

Despite my attention, I had to make a handling error …
Thank you for your answers