Is the Snap the recommended way to install LXD in Ubuntu 18.04?

I’m looking to upgrade my home server and VPS, both running a couple of LXD containers each, from 16.04 to 18.04 Bionic in the near future.

On 16.04 I use the backports apt repo to install LXD and keep it up to date. Is Snap now the recommended way to install LXD on Ubuntu 18.04? Are there any special steps I need to have my LXD containers from 16.04 work with the Snap LXD?

Also, I currently have my containers in /var/lib/lxd, with /var/lib/lxd/containers actually a symlink to a directory /home/srv/lxd/containers/ (which is on a BTRFS FS and has enough space for the containers). Does the Snap still support this or is the Snap restricted to only having containers in my user’s home (i.e /home/tim)?

1 Like

Yes, future versions of Ubuntu will continue security updates for debs, but otherwise will be SNAP moving forward. So, it is recommended to use SNAP. As far as migrating to SNAP version, check this nice write up for details: https://blog.simos.info/how-to-migrate-lxd-from-deb-ppa-package-to-snap-package/. Hope this helps.

1 Like

Thanks, that blog post looks very helpful. Only one question, where do the container files get moved to? it doesn’t say in that blog post

Running lxc.migrate step moves relevent file and data I believe. So, there shouldn’t be anything else involved other than rebooting. Be sure to back everything up. Also, here is a relevent discussion that might be helpful: Migrate from PPA to Snap

If your LXD deb package configuration uses a pre-allocated file that normally is found under /var/lib/lxd/, then in the LXD snap package it is moved under /var/snap/lxd/common/lxd (in disks/).

If your LXD deb package configuration uses a dedicated partition for the storage of container, then that partition is still reused in the LXD snap package.

Normally, snap packages have strict confinement. The LXD snap package is a special case though, because the snap developers created a special snap interface called lxd that gives pretty wide access rights to the system so that LXD can do its work.

1 Like

When I type apt show lxd in Ubuntu 18.04, it has the old 3.0.2 version. It says nothing about using snap as the preferred installation method (and it should, likely also with a pointer to using snap run lxd.migrate):

Package: lxd
Version: 3.0.2-0ubuntu1~18.04.1
Built-Using: golang-1.10 (= 1.10.1-1ubuntu2)
Priority: optional
Section: admin
Origin: Ubuntu
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 20.1 MB
Depends: acl, adduser, dnsmasq-base, ebtables, iproute2, iptables, liblxc1 (>= 2.1.0~), lsb-base (>= 3.0-6), lxcfs, lxd-client (= 3.0.2-0ubuntu1~18.04.1), passwd (>= 1:4.1.5.1-1ubuntu5~), rsync, squashfs-tools, uidmap (>= 1:4.1.5.1-1ubuntu5~), xdelta3, xz-utils, libacl1 (>= 2.2.51-8), libc6 (>= 2.14), libuv1 (>= 1.4.2)
Recommends: apparmor
Suggests: criu, lxd-tools
Homepage: https://linuxcontainers.org/
Task: cloud-image, server
Supported: 5y
Download-Size: 5109 kB
APT-Sources: http://ca.archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages
Description: Container hypervisor based on LXC - daemon
 LXD offers a REST API to remotely manage containers over the network,
 using an image based workflow and with support for live migration.
 This package contains the LXD daemon.

Via APT, it will install the LTS version of LXD (3.0) and will be supported for the next 5 years and include bug and security fixes, hence being the stable version, if you want to run the latest LXD with all the latest features you should be using the snap package.

so, the snap serves as a kind of beta program? I assumed the snap would be considered production ready and stable, isn’t it?

My comment was very unclear, sorry about that, let me try to clarify it.

Install LXD via APT OR use the 3.0/stable snap channel if you want a version which is not changing much and will be super stable, probably the best to run in production environments that need stability and which do not require the latest LXD features, this would be my primary personal choice for critical/corporate environments running LXD.

If you want to have the latest LXDt stable version (3.XX where version >3.0.XX) + new features that comes with LXD you can use the snap stable channel, these releases are considered stable and ready for production, these are not considered beta as these features and releases are tested on the edge, beta and candidate channels before release, but with new features and releases, you might run the risk to bump into some bugs since these are new features being added, so less stable than the 3.0/stable channel and the APT package.

1 Like

If you want to use SNAP LXD on 18.04 you will want to remove the pre-installed apt version of lxd first.
$ sudo apt purge lxd
then install the SNAP version
$ sudo snap install lxd
and make sure your UserID is a member of the LXD “group”
$ sudo adduser yourID lxd
then initialize LXD
$ sudo lxd init

Just a note to be sure about this:

  1. If you already use LXD from the deb package, then
    1.1 Install the LXD snap package.
    1.2 Run lxd.migrate to migrate the existing installation to the snap version of LXD
    1.3 When prompted, you can get lxd.migrate to remove the old LXD deb packages.
  2. If you have not used at all LXD from the deb package, then
    2.1 Uninstall the deb package of LXD.
    2.2 Install the snap package.
    2.3 You may have to logout and log in again (or run hash -r) to refresh the list of executables. You do that if it says something like command not found.
2 Likes

thanks for the clarification @Dnegreira.
That matches much more with what I thought the situation was.