Switch an empty LXD installation from ZFS to BTRFS

How can I switch an empty LXD installation from ZFS to BTRFS?

And, because the Raspberry hung his self up when I tried to start my first instance for a test I already ditched the dedicated drive and got a new one.

now lxc list now shows this meaningful:

Error: Get "http://unix.socket/1.0": EOF
root@ubuntu:~# lxd init

Error: Failed to connect to local LXD: Get "http://unix.socket/1.0": EOF

Or how can I start over and use lxd init to put BTRFS as my storage driver?

Not sure if snap or deb install, but in either case, uninstalling LXD and reinstalling should get rid of the broken state.

The error you’re showing is most likely LXD failing to start due to failing to locate your now removed drive and so refusing to startup.

Should apt purge lxd be enough?

For the deb, yeah, I think so.
For the snap, it would be snap remove lxd

It didn’t really like to remove the snap:

root@ubuntu:~# snap remove lxd
error: cannot perform the following tasks:
- Stop snap "lxd" services ([--root / enable snap.lxd.daemon.unix.socket] failed with exit status 1: Failed to enable unit, unit snap.lxd.daemon.unix.socket does not exist.
)
- Remove security profile for snap "lxd" (16945) (cannot find installed snap "lxd" at revision 16945: missing file /snap/lxd/16945/meta/snap.yaml)
- Remove data for snap "lxd" (16103) (remove /var/snap/lxd/common/ns/mntns: device or resource busy)
- Disconnect lxd:lxd-support from snapd:lxd-support (snap "lxd" has no "lxd-support" plug)
- Disconnect lxd:system-observe from snapd:system-observe (snap "lxd" has no "system-observe" plug)
- Disconnect lxd:network-bind from snapd:network-bind (snap "lxd" has no "network-bind" plug)
- Disconnect lxd:network from snapd:network (snap "lxd" has no "network" plug)

It complains about mounts logically :wink:

but snap install lxd didn’t let me install it again:

snap "lxd" is already installed, see 'snap help refresh'

Try umount -l /var/snap/lxd/common/ns/mntns and then snap remove lxd again.

This is the system being a bit messed up because of the half started LXD.

I stopped snapd and purged it, followed by a new installation, now I can run lxd init again but, how do I have to prepare my partition for lxd init. It is complaining but I already did format it with mkfs.btrfs /dev/sda1 -f:

Error: Failed to create storage pool 'default': Failed to format block device: Failed to run: mkfs.btrfs /dev/sda1 -L default: /dev/sda1 appears to contain an existing filesystem (btrfs).
ERROR: use the -f option to force overwrite of /dev/sda1

With above error, how can I feed this yaml file to lxd init:

config:
  core.https_address: '[::]:8443'
  core.trust_password: NotShownHere
networks: []
storage_pools:
- config:
    source: /dev/sda1
  description: ""
  name: default
  driver: btrfs
profiles:
- config: {}
  description: ""
  devices:
    eth0:
      name: eth0
      nictype: bridged
      parent: lxcbr0
      type: nic
    root:
      path: /
      pool: default
      type: disk
  name: default
cluster: null

Do I need to make some special preparations for a already used disk other than the partition sizing?

Found a solution for the disk I guess:

root@ubuntu:~# gdisk /dev/sda1
GPT fdisk (gdisk) version 1.0.5

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.

Command (? for help): p
Disk /dev/sda1: 488395087 sectors, 232.9 GiB
Sector size (logical/physical): 512/4096 bytes
Disk identifier (GUID): 75D4FE2D-CB97-4B7E-B92C-A8E8DA5B1995
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 488395053
Partitions will be aligned on 2048-sector boundaries
Total free space is 488395020 sectors (232.9 GiB)

Number  Start (sector)    End (sector)  Size       Code  Name

Command (? for help): d
No partitions

Command (? for help): ?
b	back up GPT data to a file
c	change a partition's name
d	delete a partition
i	show detailed information on a partition
l	list known partition types
n	add a new partition
o	create a new empty GUID partition table (GPT)
p	print the partition table
q	quit without saving changes
r	recovery and transformation options (experts only)
s	sort partitions
t	change a partition's type code
v	verify disk
w	write table to disk and exit
x	extra functionality (experts only)
?	print this menu

Command (? for help): x

Expert command (? for help): p
Disk /dev/sda1: 488395087 sectors, 232.9 GiB
Sector size (logical/physical): 512/4096 bytes
Disk identifier (GUID): 75D4FE2D-CB97-4B7E-B92C-A8E8DA5B1995
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 488395053
Partitions will be aligned on 2048-sector boundaries
Total free space is 488395020 sectors (232.9 GiB)

Number  Start (sector)    End (sector)  Size       Code  Name

Expert command (? for help): ?
a	set attributes
c	change partition GUID
d	display the sector alignment value
e	relocate backup data structures to the end of the disk
f	randomize disk and partition unique GUIDs
g	change disk GUID
h	recompute CHS values in protective/hybrid MBR
i	show detailed information on a partition
j	move the main partition table
l	set the sector alignment value
m	return to main menu
n	create a new protective MBR
o	print protective MBR data
p	print the partition table
q	quit without saving changes
r	recovery and transformation options (experts only)
s	resize partition table
t	transpose two partition table entries
u	replicate partition table on new device
v	verify disk
w	write table to disk and exit
z	zap (destroy) GPT data structures and exit
?	print this menu

Expert command (? for help): z
About to wipe out GPT on /dev/sda1. Proceed? (Y/N): y
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot or after you
run partprobe(8) or kpartx(8)
GPT data structures destroyed! You may now partition the disk using fdisk or
other utilities.
Blank out MBR? (Y/N): y
root@ubuntu:~# reboot

Using preseed helped not writing to much:
https://linuxcontainers.org/lxd/docs/master/preseed

When launching my first Instance terminal froze, opening another one failed like there where no network. where can I gather useful information when rebooted?

I’d recommend looking at the kernel log to see if there’s anything suspicious in there which would explain the system no longer responding or disconnecting from the network.

I just did a new installation.