我想在 zfs 数据集中创建一个卷:
sudo zfs create mypool/maildir
sudo lxc storage volume create mypool/maldir custom1
并得到
error: not found
我的创建肯定是错误的,我打算做的是:
- 创建 zfs 数据集
- 将数据集用作磁盘并挂载到容器
所以如果我重新安装系统,我可以创建一个容器并将相同的数据集附加到新容器,
这可能吗?谢谢
您的帖子并未真正显示您的池或数据集的外观,但这是您可以做到的一种方法。
通常,您希望:
zpool create ...
命令所做的那样;zfs create ...
,使用lxd init
步骤进行此分配;attach-profile
子命令将卷分配给容器配置文件我没有足够的信息来使用您的数据作为示例,所以我将向您展示我是如何使用 LXD/LXC 3.0 完成的:
创建 ZFS 池和数据集
$ 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
将 LXD 的数据集作为一个池
$ 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
...
使用 LXC 创建卷
下面的命令在我们上面分配dev-volume
的池中创建了一个新的卷lxd-pool
,并设置了 512GB 的大小。(您可以使用您需要的任何数字。)
$ lxc storage volume create lxd-pool dev-volume size=512GB
如果你得到一个error: not found
,你需要确保你正确使用了命令,参数的顺序正确,以便你引用实际存在的东西,等等。使用lxc help <subcommand>
非常有帮助。
将卷附加到容器配置文件
您需要将卷分配给容器将使用的配置文件。为此,只需依靠以下命令:
$ lxc storage volume attach-profile lxd-pool dev-volume dev-profile tank /mnt/tank
dev-volume
上面的命令将卷中的卷附加到称为设备lxd-pool
的配置文件,该设备被安装在容器内的文件系统路径中。dev-profile
tank
/mnt/tank
我希望这有帮助。