LXD on Bitfolk: Difference between revisions

From BitFolk
Jump to navigation Jump to search
No edit summary
Line 3: Line 3:
  xen-shell> install debian_bullseye
  xen-shell> install debian_bullseye


Divide xvda into xvda1 (500MB, ext4, boot) and xvda2 (rest, btrfs, /). xvda1:
Divide xvda into xvda1 (500MB, ext4, boot) and xvda2 (as much as one's got, btrfs, /).
    
    
   xvda1:          Ext4 journaling file system
   xvda1:          Ext4 journaling file system
Line 27: Line 27:
     partition #1 of Virtual disk 2 (xvdb) as swap
     partition #1 of Virtual disk 2 (xvdb) as swap


I only installed SSH server.
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
Line 33: Line 33:
  root@myhost:~# btrfs subvolume create /mnt/xvda2/@lxd
  root@myhost:~# btrfs subvolume create /mnt/xvda2/@lxd
  Create subvolume '/mnt/xvda2/@lxd'
  Create subvolume '/mnt/xvda2/@lxd'
  root@myhost:~# umount /mnt/xvda2= LXD Initialisation =
  root@myhost:~# umount /mnt/xvda2
 
= Install LXD =
= Install LXD =
root@myhost:~# apt install snapd
'snap install lxd' installs LXD on 'mkdir /var/snap/lxd'. I want to have it on the btrfs subvolume as created in section BTRFS layout above.
  root@myhost:~# mkdir /var/snap/lxd
  root@myhost:~# mkdir /var/snap/lxd
root@myhost:~# apt install snapd
 
Add the line as in listing below to '/etc/fstab'.


  LABEL=ROOT /var/snap/lxd btrfs defaults,subvol=@lxd 0 0
  LABEL=ROOT /var/snap/lxd btrfs defaults,subvol=@lxd 0 0


= My First Container =
Install LXD by snap:
 
root@myhost:~# mount /var/snap/lxd
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
  root@myhost:~# lxd init
Line 56: Line 69:
  Would you like stale cached images to be updated automatically? (yes/no) [default=yes]:  
  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]:
  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 /
  root@myhost:~# btrfs subvolume list /
Line 61: Line 76:
  ID 259 gen 3874 top level 5 path @lxd
  ID 259 gen 3874 top level 5 path @lxd
  ID 261 gen 3873 top level 259 path @lxd/common/lxd/storage-pools/lxdstoragepool
  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
  root@myhost:~# lxc launch ubuntu:22.04 my-ubuntu-lxc

Revision as of 22:39, 20 July 2022

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

VPS Setup

xen-shell> install debian_bullseye

Divide xvda into xvda1 (500MB, ext4, boot) and xvda2 (as much as one's got, 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

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

Install LXD

root@myhost:~# apt install snapd

'snap install lxd' installs LXD on 'mkdir /var/snap/lxd'. I want to have it on the btrfs subvolume as created 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

Install LXD by snap:

root@myhost:~# mount /var/snap/lxd
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!