Regarding the first part about the additional storage in the instance (container/VM), I understand from your question that you want your newly provisioned instance to have additional storage space (with specific size) mounted on some mount point, let’s say /some-mount-point
.
To do this in LXD, the storage volume (device, space, disk or call it whatever you want) that you want to attach (add) to the instance must be created before it can be used by the instance (there is an exception for the storage device used for the instance’s root filesystem, which is created/allocated once the instance is created automatically).
As far as I know, currently there is no way to make the creation of new storage volumes automated through the profiles or any other way. The storage volume should be created first and then attached to the instance.
How to create new storage volume? You need to create a new storage volume in an existing storage pool.
$ lxc storage list
+----------+--------+------------------------------------------------+-------------+---------+---------+
| NAME | DRIVER | SOURCE | DESCRIPTION | USED BY | STATE |
+----------+--------+------------------------------------------------+-------------+---------+---------+
| zfs-pool | zfs | zfs-pool | | 17 | CREATED |
+----------+--------+------------------------------------------------+-------------+---------+---------+
$ lxc storage volume create zfs-pool c1-vol1
$ lxc storage volume set zfs-pool c1-vol1 size 10GiB # in case you want to set its size to 10GB
Now the new storage volume must be created successfully. Let’s attach/add it to the instance. There are two methods, one with lxc storage volume attach
and one with lxc config device add
.
Method1 (assuming the instance name is c1 and you want to mount the new storage volume in /mnt inside the instance)
lxc storage volume attach zfs-pool c1-vol1 c1 /mnt
or Method2
lxc config device add c1 c1-vol1 pool=zfs-pool source=c1-vol1 path=/mnt
Please see the other question: Custom block volumes defined in profiles? and Add additional storage pool to profile
References:
- Linux Containers - LXD - Has been moved to Canonical
- Linux Containers - LXD - Has been moved to Canonical
Unfortunately, I do not have an answer to the second (above quoted) part of your question.