I'm using all default lxc settings with ZFS as the backstore.

Which means, I have an lxc zpool and created containers with lxc-create -B zfs -n ubuntu-base -t ubuntu

Now, the root fs ran out of space because I was testing lxc with ZFS and a zpool created from a file.

I attached a virtual drive to the VM /dev/sdb, exported the exiting lxc zpool, and created a new lxc zpool with /dev/sdb

Then, imported the old lxc zpool as lxc-old Then, used zfs send all datasets from lxc-old to lxc, destroyed lxc-old

Now lxc-ls -f no longer shows any existing containers, but zfs shows the datasets

root@lxc:~# lxc-ls -f root@lxc:~#

root@lxc:~# zfs list NAME USED AVAIL REFER MOUNTPOINT lxc 5.40G 45.1G 19K /lxc lxc/clamav 679M 45.1G 870M /var/lib/lxc/clamav/rootfs lxc/hadoop 541M 45.1G 710M /var/lib/lxc/hadoop/rootfs lxc/hulk 1.11G 45.1G 1.26G /var/lib/lxc/hulk/rootfs lxc/mongodb 1.03G 45.1G 1.16G /var/lib/lxc/mongodb/rootfs lxc/mongodb2 1.03G 45.1G 1.16G /var/lib/lxc/mongodb/rootfs lxc/python 48.2M 45.1G 185M /var/lib/lxc/python/rootfs lxc/slamdata 427M 45.1G 576M /var/lib/lxc/slamdata/rootfs lxc/splunk 172M 45.1G 324M /var/lib/lxc/splunk/rootfs lxc/ubuntu-base 229M 45.1G 210M /var/lib/lxc/ubuntu-base/rootfs lxc/ubuntu-base@python 1K - 151M - lxc/ubuntu-base@mongodb 1K - 151M - lxc/ubuntu-base@slamdata 1K - 151M - lxc/ubuntu-base@hulk 1K - 151M - lxc/ubuntu-base@splunk 1K - 151M - lxc/ubuntu-base@hadoop 17.0M - 187M - lxc/ubuntu-base@new 1K - 210M - lxc/ubuntu-base@clamav 1K - 210M -

I'm not exactly sure how to get lxc to see the existing containers in the new lxc zpool

  • I think I know why now. They are missing config file in their respective containers. Will have to test it out – naisanza Mar 30 '16 at 23:41

The reason I "lost" all of my containers was what I had previously suspected, the config file being missing.

When ZFS is used as the backstore, and a new container is created, such as /var/lib/lxc/clamav/rootfs, only the rootfs directory is contained in the backstore (ZFS)

The config file is stored in the path /var/lib/lxc/<container>/config, which isn't stored in the backstore.

The solution is to create a dataset with a mountpoint of /var/lib/lxc/

root@lxc:~# zfs list NAME USED AVAIL REFER MOUNTPOINT lxc 11.4G 37.5G 526M /lxc lxc/_configs 44K 37.5G 44K /var/lib/lxc/ lxc/_share 252K 37.5G 252K /usr/share/lxc/

Problem solved.

  • Interesting. I've manually migrated my LXC containers to ZFS, and set my mountpoint for lxc to /var/lib/lxc, which includes all the configs. The rootfs for each LXC is in its own dataset like LXC expects with the ZFS backend. Glad to hear you solved the issue! – fideli Apr 21 '16 at 14:46
  • @fideli I had created the containers without first setting the mountpoints (because I just didn't know), so when I migrated it I lost all the configs :/ – naisanza Apr 23 '16 at 3:26

I'm taking a bit of a shot in the dark, but try the following. I noticed that in your zfs list you have the following:

NAME                       USED  AVAIL  REFER  MOUNTPOINT
lxc                       5.40G  45.1G    19K  /lxc

Perhaps your new lxc dataset needs to be mounted to /var/lib/lxc.

zfs set mountpoint=/var/lib/lxc lxc
  • By default /var/lib/lxc is the location for new privileged containers. BY specifying the backstore as ZFS it will create a new container as a dataset in a zpool named 'lxc' and set its mountpoint to the base directory of /var/lib/lxc – naisanza Apr 21 '16 at 7:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.