Share containers between Gentoo and Ubuntu


I have a dual boot system using Gentoo and Ubuntu (Bionic). They share the ZFS filesystem. The lxd version in gentoo usually lags behind upstream. What is the best way to share containers between the two?

At the moment, i am using ‘btrfs’ backend in Gentoo (lxd is not setup in Ubuntu). How can i migrate the existing containers to ZFS dataset rpool/lxd?

Under gentoo,

$ lxc storage show default
  source: /var/lib/lxd/storage-pools/default
  volatile.initial_source: /var/lib/lxd/storage-pools/default
description: ""
name: default
driver: btrfs
- /1.0/containers/jessie
- /1.0/containers/mythvm

$ lxc network show br0
config: {}
description: ""
name: br0
type: bridge
- /1.0/containers/jessie
- /1.0/containers/mythvm

$lxc info|grep version
api_version: "1.0"
  driver_version: 2.0.9
  kernel_version: 4.9.76-gentoo-r1
  server_version: "2.21"
  storage_version: 4.10.2


I was able to migrate the containers into the ZFS filesystem. The containers start fine on Ubuntu, however lxd crashes right away on Gentoo.

Log file says,

Mar 30 06:53:07 box /etc/init.d/lxd[17493]: You have to create an init script for each container:
Mar 30 06:53:07 box /etc/init.d/lxd[17495]:  ln -s lxc /etc/init.d/lxc.container
Mar 30 06:53:07 box /etc/init.d/lxd[17725]: start-stop-daemon: no matching processes found

Here are my ZFS datasets,

# zfs list|grep lxd
rpool/liblxd                                                                                552K   205G   552K  /var/lib/lxd
rpool/lxd                                                                                  1.80G   205G    96K  none
rpool/lxd/containers                                                                       18.5M   205G    96K  none
rpool/lxd/containers/openhab                                                               7.14M   205G  1.11G  /var/lib/lxd/storage-pools/default/containers/openhab
rpool/lxd/containers/zmvm                                                                  11.3M   205G   684M  /var/lib/lxd/storage-pools/default/containers/zmvm
rpool/lxd/custom                                                                             96K   205G    96K  none
rpool/lxd/deleted                                                                          1.78G   205G    96K  none
rpool/lxd/deleted/images                                                                   1.78G   205G    96K  none
rpool/lxd/deleted/images/12e2a2c7e61fe78081ae664970f49eb425d03c992dbab9e60515b967830c701e  1.11G   205G  1.11G  none
rpool/lxd/deleted/images/3e878a033d8528311145908294e1ba637774ba2c8111ce70b5cb2b356c8d65bd   684M   205G   684M  none
rpool/lxd/images                                                                             96K   205G    96K  none
rpool/lxd/snapshots                                                                          96K   205G    96K  none

Any idea why LXD works fine in Ubuntu but crashes in Gentoo?

Is there anything in lxd.db which needs to be changed?

It turns out that LXD Bionic has version 3 while Gentoo has 2.21. There is a schema mismatch between the two.

Indeed, there are different major versions (LXD 2, LXD 3) and there are differences in the way the configuration is stored and handled.

An option would be to uninstall LXD 3.0 from Ubuntu 18.04 (deb package), and install the snap version of LXD, the one from the 2.0/stable channel. That LXD is at version 2.0.11, supported until 2016+5 = 2021. You need to compare with the Gentoo version you already have so that the versions do not diverge too much.

I have installed the 2.0/stable from snap package. However, it creates its files in /var/snap/lxd/common/lxd instead of /var/lib/lxd.

What i need is files sitting in a ZFS dataset (say rpool/liblxd) mounted to /var/lib/lxd. This dataset can then be shared in both Gentoo and Ubuntu. The snap package kills this inter-operability.

Is there a way to bind mount /var/lib/lxd to /var/snap/lxd/common/lxd ?