On my host, I have Ubuntu 16.10:
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.10
Release: 16.10
Codename: yakkety
and I use LXD from the stable repo:
lxc --version
2.12
I currently have a few containers created with DIR as the storage backend:
root@Ubuntu-1610-yakkety-64-minimal ~ # lxc storage show default
config:
source: /var/lib/lxd/storage-pools/default
name: default
driver: dir
used_by:
- /1.0/containers/elasticsearch-internal
- /1.0/containers/yyy-dev
- /1.0/containers/yyy-pre-prod
- /1.0/containers/xxx-dev
- /1.0/containers/xxx-dev/snapshots/snap1
- /1.0/containers/mysql-dev
- /1.0/containers/mysql-dev/snapshots/snap01
- /1.0/containers/mysql-preprod
- /1.0/images/2cab90c0c342346ea154bc2e8cacdae752a70747a755ce1f2970c9a9ebb5fe8c
- /1.0/images/d51e7b34d5f470912bc45a6270278d7990b049d826e33dd8affe9b54aaf0d7ee
- /1.0/profiles/default
I also have 2 x 2TB SATA III HDDs mirrored with ZFS:
root@Ubuntu-1610-yakkety-64-minimal ~ # zpool list -v
NAME SIZE ALLOC FREE EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
lxdstorage 1.81T 361M 1.81T - 0% 0% 1.00x ONLINE -
mirror 1.81T 361M 1.81T - 0% 0%
sdc - - - - - -
sdd - - - - - -
Now, since version 2.12, LXD has the new storage API: lxd/storage-backend
I need to move the actual containers from DIR to ZFS storage. What I have done so far is create the new storage:
lxc storage create pool1 zfs source=lxdstorage/containers
root@Ubuntu-1610-yakkety-64-minimal ~ # lxc storage list
+---------+--------+------------------------------------+---------+
| NAME | DRIVER | SOURCE | USED BY |
+---------+--------+------------------------------------+---------+
| default | dir | /var/lib/lxd/storage-pools/default | 11 |
+---------+--------+------------------------------------+---------+
| pool1 | zfs | lxdstorage/containers | 0 |
+---------+--------+------------------------------------+---------+
How can I move the containers from default
to pool1
?
There is still no direct way to do this (today version 2.14).
The workarround is stop container, publish as image, delete original container and init it in new storage pool:
LXC Manual migration from dir: to zfs: backend on Debian Stretch
I could not find a way on SE which worked for me, i do not seem to have the publish option in debian lxc.
My containers live in ext4 on /var/lib/lxc (default install), and I need them on zfs in /tank/lxc/containers
0) Stop the container(s):
1) Create a file /etc/lxc/lxc.conf - lxc will pick this up and works from zfs. If you forgot to stop a container (like i did), move the file, then stop the container, and put back this file again
2) Create the datasets:
3) Create the new container with the same name (this will land on zfs now)
Turns out mycontainer is a ZFS dataset which is not mounted. You could start it first to initialize it, or you can copy the old config over too (mac address, autostart, and what else you had set).
4) The 2nd dataset you mount here is in fact the rootfs of the container(!)
5) sync the old root to the new one
6) copy the config if you need it
7) umount the datasets and start up your container from ZFS
Repeat for all - Happy containering on ZFS!