LXD/LXD Installation

From Funtoo
< LXD
Jump to: navigation, search

PART II - LXD Installation

{{#layout:doc}}


Installing LXD in Funtoo

Kernel pre-requisities

These options should be disabled in your kernel to use all of the functions of LXD:

 GRKERNSEC_CHROOT_CAPS
 GRKERNSEC_CHROOT_CHMOD
 GRKERNSEC_CHROOT_DOUBLE
 GRKERNSEC_CHROOT_MOUNT
 GRKERNSEC_CHROOT_PIVOT
 GRKERNSEC_PROC
 GRKERNSEC_SYSFS_RESTRICT
 NETPRIO_CGROUP

These options should be enabled in your kernel to use all of the functions of LXD:

 BRIDGE
 CGROUP_CPUACCT
 CGROUP_DEVICE
 CGROUP_FREEZER
 CGROUP_SCHED
 CGROUPS
 CHECKPOINT_RESTORE
 CPUSETS
 DUMMY
 EPOLL 
 EVENTFD 
 FHANDLE 
 IA32_EMULATION 
 INET_DIAG 
 INET_TCP_DIAG
 INET_UDP_DIAG
 INOTIFY_USER
 IP_NF_NAT
 IP_NF_TARGET_MASQUERADE
 IP6_NF_NAT
 IP6_NF_TARGET_MASQUERADE
 IPC_NS
 IPV6
 MACVLAN
 NAMESPACES 
 NET_IPGRE
 NET_IPGRE_DEMUX
 NET_IPIP
 NET_NS
 NETFILTER_XT_MATCH_COMMENT
 NETLINK_DIAG
 NF_NAT_MASQUERADE_IPV4
 NF_NAT_MASQUERADE_IPV6
 PACKET_DIAG 
 PID_NS 
 POSIX_MQUEUE
 UNIX_DIAG
 USER_NS
 UTS_NS
 VETH
 VXLAN

   Note

The Funtoo's default kernel (sys-kernel/debian-sources – v. 4.11.11 at the time of writing) has all these options enabled.

   Tip

On older kernels DEVPTS_MULTIPLE_INSTANCES is needed too (as of kernel version 4.11.11 - the option doesn't exist any more)

LXC package comes with an utility to check all needed config options.

root # CONFIG=/path/to/config /usr/bin/lxc-checkconfig

You can also use this code to compare your config settings with the ones needed. Put the required config options in a kernel-req.txt file and run the script.

   kerncheck.py (python source code) - check kernel options
import gzip

REQF = "kernel-req.txt"    # copy kernel options requirements into this file
REQS = set()
CFGS = set()

with open(REQF) as f:
    for line in f:
        REQS.add("CONFIG_%s" % line.strip())

with gzip.open("/proc/config.gz") as f:
    for line in f:
        line = line.decode().strip()
        if not line or line.startswith("#"):
            continue

        try:
            [opt, val] = line.split("=")
            if val =="n":
                continue
            CFGS.add(opt)
        except:
            pass

print("Enabled config options:")
print(CFGS & REQS)

print("Missing config options:")
print(REQS - CFGS)

Installing LXD

Installing LXD is pretty straight forward as the ebuild exists in our portage tree. I would recommend putting /var on btrfs or zfs (or at least /var/lib/lxd) as LXD can take advantage of these COW filesytems. LXD doesn’t need any configuration to use btrfs, you just need to make sure that /var/lib/lxd is stored on a btrfs filesystem and LXD will automatically make use of it for you. You can use any other filesystem, but be advised LXD can take great advantage of btrfs or ZFS, be it for snapshots, clones, quotas and more. If you want to test it on your current filesystem consider creating a loop device that you format with btrfs and use that as your /var/lib/lxd device.

There are couple of major versions of LXD/LXC.

  • LXC
    • LXC 1.0 (LXC upstream strongly recommends 1.0 users to upgrade to the 2.0 LTS release. Not supported by Funtoo.)
    • LXC 2.0.x LTS (supported until June 2021) - latest version 2.0.9
    • LXC 2.x (supported for a year from release announcement on 5th of September 2017 - so until September 2018) - latest version 2.1.1
  • LXD
    • LXD 2.0.x LTS (supported until June 2021) - latest 2.0.11
    • LXD 2.x - latest 2.21
  • LXCFS
    • LXCFS 2.0.x LTS (supported until June 2021) - latest 2.0.8
   Warning

LXD downgrade from "current" to "LTS" is not supported, but can still be done with lots of manual work.

Install LXD by:

root # emerge -av lxd
   Note

You probably want to install also lxcfs, apparmor, ebtables as these are used by lxd and are not dependencies in the ebuild, yet.