LXD on Debian

How to install using snap

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.

Requirements

  • A Debian “testing” (stretch) system
    
  • The stock Debian kernel without apparmor support
    
  • If you want to use ZFS with LXD, then the “contrib” repository must be enabled and the “zfsutils-linux” package installed on the system
    

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:

[email protected]:~# 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:


[email protected]:~# lxc launch images:debian/stretch debian
Creating debian
Starting debian

[email protected]:~# lxc launch ubuntu:18.04 ubuntu
Creating ubuntu
Starting ubuntu

[email protected]:~# lxc launch images:centos/7 centos
Creating centos
Starting centos

[email protected]:~# lxc launch images:archlinux archlinux
Creating archlinux
Starting archlinux

[email protected]:~# lxc launch images:gentoo gentoo
Creating gentoo
Starting gentoo

Now you can list the installation of active Linux distributions:

[email protected]:~# lxc list



+-----------+---------+-----------------------+-----------------------------------------------+------------+-----------+
|   NAME    |  STATE  |         IPV4          |                     IPV6                      |    TYPE    | SNAPSHOTS |
+-----------+---------+-----------------------+-----------------------------------------------+------------+-----------+
| archlinux | RUNNING | 10.250.240.103 (eth0) | fd42:46d0:3c40:cca7:216:3eff:fe40:7b1b (eth0) | PERSISTENT | 0         |
+-----------+---------+-----------------------+-----------------------------------------------+------------+-----------+
| centos    | RUNNING | 10.250.240.109 (eth0) | fd42:46d0:3c40:cca7:216:3eff:fe87:64ff (eth0) | PERSISTENT | 0         |
+-----------+---------+-----------------------+-----------------------------------------------+------------+-----------+
| debian    | RUNNING | 10.250.240.111 (eth0) | fd42:46d0:3c40:cca7:216:3eff:feb4:e984 (eth0) | PERSISTENT | 0         |
+-----------+---------+-----------------------+-----------------------------------------------+------------+-----------+
| gentoo    | RUNNING | 10.250.240.164 (eth0) | fd42:46d0:3c40:cca7:216:3eff:fe27:10ca (eth0) | PERSISTENT | 0         |
+-----------+---------+-----------------------+-----------------------------------------------+------------+-----------+
| ubuntu    | RUNNING | 10.250.240.80 (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.

#Linux #Install #Video #HowTo

-- G. Love