John Mark Causing

System Administrator | Hosting Support Engineer

Bacolod City, Philippines

+639393497018

John Mark Causing

System Administrator | Hosting Support Engineer

Bacolod City, Philippines

+639393497018

Create storage

If you want to create a separate storage you can try to follow the instructions below. This example is using Linode to add additional storage.

  • Create volume in Linode. Don’t configure it or set the partition
  • To check if it’s there in your instance, run: lsblk.

You will see:

sdc 8:32 0 10G 0 disk

  • Add that volume in LXD:

lxc storage create zfs-test zfs source=/dev/sdc

  • It will create a partition. You can see that using:

lsblk

sdc 8:32 0 10G 0 disk
├─sdc1 8:33 0 10G 0 part
└─sdc9 8:41 0 8M 0 part

  • To remove the partition (remove first the storage in LXD), you can use:

gdisk /dev/sdc
x <– expert mode
z <– delete the partition that is already exist in ‘sdc’
Y <– to blank out the master boot record MBRSet Editor in LXD profile ‘web’
lxc profile set web environment.EDITOR vim

Set boot start priority for the profile ‘web’


lxc profile set web boot.autostart.priority 50

Set boot stop priority


lxc profile set web boot.stop.priority 50

Copy image from remote to local


lxc image copy ubuntu:16.04 local: --alias ubuntu
Lxc image list

LXC Profile set examples:

auto start highest priority

lxc profile set dbs boot.autostart.priority 99

boot stop lowest priority

lxc profile set dbs boot.stop.priority 1

disk limit highest priority

This is giving an error when you launch a container

cloud_user@lxd:~$ lxc profile set dbs limits.disk.priority 10

Create snapshots every 12 midnight

lxc profile set snapshots.schedule "0 0 * * *"

Take a snapshot of the web01 container:

lxc snapshot web01 1.0

Copy a container from ‘web01’ from a snapshot “1.0” then start it

lxc copy web01/1.0 web02
lxc start web02

Get the IP address only when you list the containers

lxc list | awk '{print $6}' | grep -v IPV4 | grep -v -e '^$'
10.190.81.44
10.190.81.66
10.190.81.122
10.190.81.247
10.190.81.84
10.190.81.42

Update the web01 container so nginx starts at boot:

lxc exec web01 -- rc-update add nginx default

Take a new snapshot:

lxc snapshot web01 1.1

Remove the web02 container and relaunch it with the new snapshot:

lxc stop web02
lxc delete web02
lxc copy web01/1.1 web02
lxc start web02

Remove the 1.0 snapshot:

lxc delete web01/1.0

Remote / Images / Publish

Convert container snapshot FROM this lxd TO a remote LXD as an image

  1. Configure lxc https address
    lxc config set core.https_address ip_of_this_machine
  2. Publish an image from a container snapshot
    lxc publish alpine1/1.0 custom: --alias NewImageofAlpine
  3. Check if that image is there in the remote LXD
    lxc image list custom:
  4. Launch a container to this lxd getting an image (published) from the remote LXD
    Lxc launch custom:NewImageofAlpine Mynewalpine
  5. Launch a container to the remote LXD using the new published image
    lxc launch custom:NewImageofAlpine custom:Mynewalpine2