“LXD and ZFS in Ubuntu 16.04Lts Server Edition″

ubuntu-16-04-lts

UBUNTU SERVER

What is a LXD?

To obtain an answer to this Q. we’ve to read these links

https://www.ubuntu.com/containers/lxd

and that

https://stgraber.org/2016/03/11/lxd-2-0-blog-post-series-012/

What is a ZFS?

To obtain an answer to this Q. we’ve to read these links:

https://wiki.ubuntu.com/ZFS

One time we have view all informations about LXD and ZFS we can proceed with our howto

In order to setup our environment we need to make some steps and having some requirements:

  • Create a bridge network (see this howto);
  • Install LXD and ZFS;
  • Create a Container profile for our lab;

our VM is so configured

Screen Shot 2016-11-04 at 17.16.14.png

screen-shot-2016-11-04-at-22-34-38

01 STEP – PREPARE HDD FOR ZFS AND NET INTERFACE

The first thing to do is assigned a new partition on /dev/sdb, run

 

$: ssh rs@10.20.40.22
$: sudo fdisk /dev/sdb

then create its partition, the result will be that

Screen Shot 2016-11-04 at 17.20.13.png

02 STEP – INSTALL LXD

Then we can proceed installing LXD and ZFS utility with the following commands:

$: sudo apt-add-repository ppa:ubuntu-lxc/stable
$: sudo apt update 
$: sudo apt dist-upgrade

then make sure we don’t have a packaged version of LXD installed on our system.

$: sudo apt remove --purge lxd lxd-client

create the “lxd” group and add yourself to it.

$: sudo groupadd --system lxd
$: sudo usermod -G lxd -a <username>

install LXD itself

$: sudo snap install lxd

its own virtual network adapter will have to be so configured

$: sudo more /etc/network/interfaces
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto ens33
iface ens33 inet manual
auto br0
iface br0 inet dhcp
        bridge_ports ens33

03 STEP – INSTALL ZFS

After Lxd it’s time of that:

$: sudo add-apt-repository ppa:zfs-native/stable
$: sudo apt-get install zfsutils-linux bridge-utils 
$: sudo modprobe zfs

reboot the VM

$: sudo reboot

04 STEP – INITIALISE LXD

In order the networking establishes the connection between LXC containers host, we need to set up a bridge device.

$: groups
$: sudo lxd init

Name of the storage backend to use (dir or zfs): zfs
Create a new ZFS pool (yes/no)? yes
Name of the new ZFS pool: lxd
Would you like to use an existing block device (yes/no)? yes
Path to the existing block device: /dev/sdb1
Would you like LXD to be available over the network (yes/no)? no
Do you want to configure the LXD bridge (yes/no)? yes
Warning: Stopping lxd.service, but it can still be activated by:
  lxd.socket
LXD has been successfully configured.

then

05 STEP – CREATE A LXC PROFILE FOR OUR VM

Lets create a container profile by copying the default:

$: lxc profile copy default svrlab

06 STEP – LAUNCH LXD CONTAINER

Once the profile has been created, we can now launch the LXC container:

$: lxc launch ubuntu:xenial xenial-svr
Creating xenial-svr
Retrieving image: 100%
Starting xenial-svr

wait few second and then check list with that command

$: lxc list
+-------------+---------+----------------------+------+------------+-----------+
| NAME        |  STATE  |        IPV4          | IPV6 |    TYPE    | SNAPSHOTS |
+-------------+---------+----------------------+------+------------+-----------+
| xenial-svr  | RUNNING | 10.20.40.39 (eth0)   |      | PERSISTENT | 0         |
+-------------+---------+----------------------+------+------------+-----------+

then to connect on its bash run that command.

$: lxc exec xenial-svr bash

this how-to at moment is ended..


“cya to the next 1…. Njoy !”
bye dakj

Disclaimer: All the tutorials included on this site are performed in a lab environment to simulate a real world production scenario. As everything is done to provide the most accurate steps to date, we take no responsibility if you implement any of these steps in a production environment.

“We learn from our mistakes”

Advertisements