Reputation: 3533
I'd like to create a volume in a zfs dataset:
sudo zfs create mypool/maildir
sudo lxc storage volume create mypool/maldir custom1
and got
error: not found
my create is sure to be wrong, what I intended to do is:
so if I re-install the system, I can create a container and attach the same dataset to the new container,
is this possible? Thanks
Upvotes: 0
Views: 4526
Reputation: 6095
Your post does not really show what your pool or datasets look like, but here's one way you can do it.
Generally, you want to:
zpool create ...
command;zfs create ...
, using the lxd init
step to make this assignment;attach-profile
sub-command to assign volumes to container profilesI don't have enough information to use your data as an example, so I'll show you how I did mine, using LXD/LXC 3.0:
Create the ZFS Pool and Dataset
$ sudo zpool create -m /mnt/tank tank raidz3 <vdev1> <vdev2> ...
$ sudo zfs create tank/lxd
$ sudo zfs list
NAME USED AVAIL REFER MOUNTPOINT
tank 954M 1.31T 41.7K /mnt/tank
tank/lxd 953M 1.31T 41.7K /mnt/tank/lxd
Give LXD its Dataset as a Pool
$ lxd init
...
Name of the new storage pool [default=default]: lxd-pool
Name of the storage backend to use (btrfs, dir, lvm, zfs) [default=zfs]:
Create a new ZFS pool? (yes/no) [default=yes]: no
Name of the existing ZFS pool or dataset: tank/lxd
...
Use LXC to Create the Volumes
The following command creates a new volume called dev-volume
within the pool called lxd-pool
that we assigned above, and sets a size of 512GB. (You may use whatever numbers you need in your case.)
$ lxc storage volume create lxd-pool dev-volume size=512GB
If you're getting an error: not found
you'll need to make sure you're using the commands correctly, that the arguments are in the correct order so that you reference things that actually exist, and so on. Using lxc help <subcommand>
is very helpful.
Attach Volume to Container Profile
You'll want to assign the volume to a profile that will be used by a container. To do this, simply rely on the following command:
$ lxc storage volume attach-profile lxd-pool dev-volume dev-profile tank /mnt/tank
The command above attaches the volume dev-volume
within the lxd-pool
to a profile called dev-profile
as a device called tank
that gets mounted at file system path /mnt/tank
within the container.
I hope this helps.
Upvotes: 2