LXD on Debian

How to install using snap!

LXD Logo

Most installations will be making the assumption that LXD is being installed on an Ubuntu host with LXD installed from packages or from source. I enjoy the art of distro hopping. But when it comes to my service hosting I prefer to run on either Debian or Ubuntu LTS version of Linux. They are stable and pretty much are reliable.

So with that being said, LXD is perfectly happy to run on any Linux distribution which has the LXC library available (version 2.0.0 or higher), a recent kernel (3.13 or higher) and some standard system utilities available (rsync, dnsmasq, netcat, various filesystem tools, etc). For my use I am going to cover the installation on Debian which is pretty straight forward.


Installing snapd and LXD

Getting the latest stable LXD onto an up to date Debian testing system is just a matter of running:

apt install snapd
snap install lxd

Once you install snapd, you’ll have to either logout and log back in to update your PATH, or just update your existing one with:

. /etc/profile.d/apps-bin-path.sh

Once you log back into your system you can now configure LXD by responding to the following questions:

root@debian:~# lxd init

Name of the storage backend to use (dir or zfs) [default=dir]:
Create a new ZFS pool (yes/no) [default=yes]?
Name of the new ZFS pool [default=lxd]:
Would you like to use an existing block device (yes/no) [default=no]?
Size in GB of the new loop device (1GB minimum) [default=100]:
Would you like LXD to be available over the network (yes/no) [default=no]?
Would you like stale cached images to be updated automatically (yes/no) [default=yes]?
Would you like to create a new network bridge (yes/no) [default=yes]?
What should the new bridge be called [default=lxdbr0]?
What IPv4 subnet should be used (CIDR notation, “auto” or “none”) [default=auto]?
What IPv6 subnet should be used (CIDR notation, “auto” or “none”) [default=auto]?
LXD has been successfully configured.

Now with LXD initialized you can start using LXD:

Below are a few examples of how to install an OS from an existing image library; when creating the container the last name at the end of the command is the name of the container. For example I want to install Hubzilla in a Ubuntu container I would run the following command:

lxc launch ubuntu:18.04 Hubzilla

Below are samples for different Operating Systems to get you started:

root@debian:~# lxc launch images:debian/stretch debian
Creating debian
Starting debian

root@debian:~# lxc launch ubuntu:18.04 ubuntu Creating ubuntu Starting ubuntu

root@debian:~# lxc launch images:centos/7 centos Creating centos Starting centos

root@debian:~# lxc launch images:archlinux archlinux Creating archlinux Starting archlinux

root@debian:~# lxc launch images:gentoo gentoo Creating gentoo Starting gentoo

Now you can list the installation of active Linux distributions:

root@debian:~# lxc list

|   NAME    |  STATE  |         IPV4          |                     IPV6                      |    TYPE    | SNAPSHOTS |
| archlinux | RUNNING | (eth0) | fd42:46d0:3c40:cca7:216:3eff:fe40:7b1b (eth0) | PERSISTENT | 0         |
| centos    | RUNNING | (eth0) | fd42:46d0:3c40:cca7:216:3eff:fe87:64ff (eth0) | PERSISTENT | 0         |
| debian    | RUNNING | (eth0) | fd42:46d0:3c40:cca7:216:3eff:feb4:e984 (eth0) | PERSISTENT | 0         |
| gentoo    | RUNNING | (eth0) | fd42:46d0:3c40:cca7:216:3eff:fe27:10ca (eth0) | PERSISTENT | 0         |
| ubuntu    | RUNNING | (eth0)  | fd42:46d0:3c40:cca7:216:3eff:fedc:f0a6 (eth0) | PERSISTENT | 0         |

And that is it you have installed LXD on Debian using SNAP. One point to note is depending on specifics of you instllation, you may or may not have issues installing ZFSUTILS-LINUX. This is beyond the scope of this posting. You will need to investigate the issues with your particular installation. In some cases as with OVH and Kimsufi, the Kernel is modified from the distribution and may impact the installation. In cases like this, you can use DIR as the storage-pool type. This will use the filesystem and deposit the files for the container build in there.

G. Love #Foss #HowTo #Linux

— G. Love