Need help Setting up LXD 3.0.1 on Ubuntu 18.04


#1

Ok, so I have an existing Btrfs filesystem on /dev/sdb, mounted at /media/adrian/btr-store.

I start by installing lxd:

sudo apt install lxd

Then I run (answers written explicitly):

$ lxd init

#1

Would you like to use LXD clustering? (yes/no) [default=no]: no

#2

Do you want to configure a new storage pool? (yes/no) [default=yes]: yes

I presume this asks about LXD storage pools (the concept), not about setting up filesystems on my host, correct?

#3

Name of the new storage pool [default=default]: default

So is this the name as written to my filesystem, i.e. a Btrfs subvolume name? Or is it still internal to LXD?

#4

Name of the storage backend to use (btrfs, dir) [default=btrfs]: btrfs

#5

Create a new BTRFS pool? (yes/no) [default=yes]: yes

So this probably creates a Btrfs subvolume under the root (top-level) I give it. So yes.

#6

Would you like to use an existing block device? (yes/no) [default=no]: yes

My Btrfs root would be a block device, so yes. If I answered no, it would use a loopback solution.

#7

Path to the existing block device: /media/adrian/btr-store
Invalid input: '/media/adrian/btr-store' is not a block device

Ok, so it doesn’t want the filesystem itself. Does it want /dev/sdb where fs is located?

Path to the existing block device: /dev/sdb
Error: Failed to create storage pool 'default': Failed to create the BTRFS pool: /dev/sdb appears to contain an existing filesystem (btrfs)

So what do I now?


(Stéphane Graber) #2

So you say you have an existing btrfs filesystem on /dev/sdb, yet you tell LXD you want to create a new btrfs pool? That doesn’t really make sense.

What you want to do is tell LXD to configure a new storage pool, choose a name, say it’s btrfs, then say no to creating a new pool, at which point it’ll ask you about the name of the existing pool or dataset, which in your case would be /media/adrian/btr-store/lxd or something along those lines.


#3

That’s what I did before, which ended with the problems described in the earlier thread.

Since pool is used as a relative path in LXD’s storage context, I concluded that it must refer to a Btrfs subvolume, rather than the top-level. So I had hoped that lxd init would create a proper subvolume along with the configuration necessary.


(Stéphane Graber) #4

Just did a clean Ubuntu 18.04 install:

root@edfu:~# mkfs.btrfs /dev/sdc
btrfs-progs v4.15.1
See http://btrfs.wiki.kernel.org for more information.

Detected a SSD, turning off metadata duplication.  Mkfs with -m dup if you want to force metadata duplication.
Performing full device TRIM /dev/sdc (279.46GiB) ...
Label:              (null)
UUID:               7359ba4c-bd90-4696-940a-1805c389c54e
Node size:          16384
Sector size:        4096
Filesystem size:    279.46GiB
Block group profiles:
  Data:             single            8.00MiB
  Metadata:         single            8.00MiB
  System:           single            4.00MiB
SSD detected:       yes
Incompat features:  extref, skinny-metadata
Number of devices:  1
Devices:
   ID        SIZE  PATH
    1   279.46GiB  /dev/sdc

root@edfu:~# mkdir /media/btrfs
root@edfu:~# mount /dev/sdc /media/btrfs
root@edfu:~# 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]:    
Name of the storage backend to use (btrfs, dir, lvm) [default=btrfs]:      
Create a new BTRFS pool? (yes/no) [default=yes]: no
Name of the existing BTRFS pool or dataset: /media/btrfs/lxd
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 LXD 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]: 
root@edfu:~# lxc storage list
If this is your first time running LXD on this machine, you should also run: lxd init
To start your first container, try: lxc launch ubuntu:16.04

+---------+-------------+--------+------------------+---------+
|  NAME   | DESCRIPTION | DRIVER |      SOURCE      | USED BY |
+---------+-------------+--------+------------------+---------+
| default |             | btrfs  | /media/btrfs/lxd | 1       |
+---------+-------------+--------+------------------+---------+
root@edfu:~# lxc launch ubuntu:16.04 c1
Creating c1
Starting c1                                   
root@edfu:~# btrfs subvolume list /media/btrfs 
ID 257 gen 12 top level 5 path lxd
ID 258 gen 15 top level 257 path lxd/containers
ID 259 gen 10 top level 257 path lxd/snapshots
ID 260 gen 15 top level 257 path lxd/images
ID 261 gen 12 top level 257 path lxd/custom
ID 264 gen 15 top level 260 path lxd/images/62d45468572e4d9be02ef2513a2056548c41869312190079b2a691f7fe08fcea
ID 265 gen 15 top level 258 path lxd/containers/c1
root@edfu:~# 

#5
$ sudo btrfs subvolume create /media/adrian/btr-store/lxd

$ edit /etc/fstab   (give subvolume its own mountpoint)

$ sudo mount -v /media/adrian/lxd
mount: /dev/sdb mounted on /media/adrian/lxd.

$ lxd init
(...)
Do you want to configure a new storage pool? (yes/no) [default=yes]: yes
Name of the new storage pool [default=default]: btr
Name of the storage backend to use (btrfs, dir) [default=btrfs]: btrfs
Create a new BTRFS pool? (yes/no) [default=yes]: no
Name of the existing BTRFS pool or dataset: /media/adrian/lxd
(...)

$ lxc storage list
+------+-------------+--------+-----------------------------+---------+
| NAME | DESCRIPTION | DRIVER |           SOURCE            | USED BY |
+------+-------------+--------+-----------------------------+---------+
| btr  |             | btrfs  | /media/adrian/lxd           | 1       |
+------+-------------+--------+-----------------------------+---------+

$ lxc launch images:alpine/3.8 a1
Creating a1
(...)
Starting a1

All working fine now, as in your example. I don’t know where I went wrong before, but I’ll be sure to write these steps down. Thanks for all the help Stéphane! :+1: