LXD on Bitfolk: Difference between revisions

From BitFolk
Jump to navigation Jump to search
No edit summary
 
Line 1: Line 1:
This shows how to say 'Hello Linuxcontainer' on Bitflok.
This shows how to say 'Hello Linuxcontainer' on Bitflok.
= VPS Setup =
= VPS Setup =
xen-shell> install debian_bullseye


Divide xvda into xvda1 (500MB, ext4, boot) and xvda2 (as much as one's got, btrfs, /).
See [[Installing on BTRFS]]
 
  xvda1:          Ext4 journaling file system
 
  Mount point:      /boot
  Mount options:    defaults
  Label:            BOOT
  Reserved blocks:  5%
  Typical usage:    standard
  Bootable flag:    on


  xvda2:                btrfs journaling file system
 
  Format the partition:  yes, format it
  Mount point:          /
  Mount options:        defaults
  Label:                ROOT
  Bootable flag:        on
 
  The following partitions are going to be formatted:
    partition #1 of Virtual disk 1 (xvda) as ext4
    partition #2 of Virtual disk 1 (xvda) as btrfs
    partition #1 of Virtual disk 2 (xvdb) as swap
I only installed SSH server. Choose xvda as device to put boot loader on.
= BTRFS Layout =
= BTRFS Layout =
  root@myhost:~# mkdir /mnt/xvda2
  root@myhost:~# mkdir /mnt/xvda2

Latest revision as of 03:07, 17 December 2022

This shows how to say 'Hello Linuxcontainer' on Bitflok.

VPS Setup

See Installing on BTRFS

BTRFS Layout

root@myhost:~# mkdir /mnt/xvda2
root@myhost:~# mount -o subvolid=5 /dev/xvda2 /mnt/xvda2/
root@myhost:~# btrfs subvolume create /mnt/xvda2/@lxd
Create subvolume '/mnt/xvda2/@lxd'
root@myhost:~# umount /mnt/xvda2

Like this one can take snapshots of @lxd without snapshotting the whole @rootfs. Or, in other word snapshots of @rootfs do not include @lxd. This is BTRFS specific.

Install LXD

root@myhost:~# apt install snapd

'snap install lxd' installs LXD on '/var/snap/lxd'. I want to have it on the btrfs subvolume @lxd as described in section BTRFS layout above.

root@myhost:~# mkdir /var/snap/lxd

Add the line as in listing below to '/etc/fstab'.

LABEL=ROOT /var/snap/lxd btrfs defaults,subvol=@lxd 0 0
root@myhost:~# mount /var/snap/lxd

BTRFS subvolume @lxd is now mounted on '/var/snap/lxd' - stating the obious.

root@myhost:~# snap install lxd
2022-07-19T15:03:15Z INFO Waiting for automatic snapd restart...
lxd 5.3-91e042b from Canonical✓ installed

LXD Initialisation

root@myhost:~# lxd init
Would you like to use LXD clustering? (yes/no) [default=no]: 
Do you want to configure a new storage pool? (yes/no) [default=yes]: 
Name of the new storage pool [default=default]: lxdstoragepool
Name of the storage backend to use (dir, lvm, ceph, btrfs) [default=btrfs]: 
Would you like to create a new btrfs subvolume under /var/snap/lxd/common/lxd? (yes/no) [default=yes]: 
Would you like to connect to a MAAS server? (yes/no) [default=no]: 
Would you like to create a new local network bridge? (yes/no) [default=yes]: 
What should the new bridge be called? [default=lxdbr0]: 
What IPv4 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]: 
What IPv6 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]: 
Would you like the LXD server 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 a YAML "lxd init" preseed to be printed? (yes/no) [default=no]:

In listing below one sees that lxdstoragepool is a btrfs subvolume of btrfs top level subvolume lxd as created in section BTRFS layout.

root@myhost:~# btrfs subvolume list /
ID 256 gen 3874 top level 5 path @rootfs
ID 259 gen 3874 top level 5 path @lxd
ID 261 gen 3873 top level 259 path @lxd/common/lxd/storage-pools/lxdstoragepool

My First Container

root@myhost:~# lxc launch ubuntu:22.04 my-ubuntu-lxc
Creating my-ubuntu-lxc
Starting my-ubuntu-lxc
root@myhost:~# lxc exec my-ubuntu-lxc bash
root@my-ubuntu-lxc:~# echo "Boris Becker: Ich bin drin!"
Boris Becker: Ich bin drin!