[lxd 4.2] Error: Fail to create storage

Hello.

During the lxd init I tried to set the stogage backend as brtfs on an external disk same as purposed by this command. The path filled is /dev/disk/by-label/mylabel

The command as me for other questions after and fail during the creation of the mkfs.btrfs and return this error:

Error: Failed to create storage pool ‘default’: failed to format block device: Failed to run: mkfs.btrfs /dev/disk/by-label/mylabel -L default: /dev/disk/by-label/mylabel appears to contain an existing filesystem (brtfs).
Error: use the -f option to force overwrite of /dev/disk/by-label/mylabel

The help of lxd init not provide info about this parameter (note that the help have an error too because it purpose a --version option that doesn’t work). If anyone have an idea about how to force the creation of the FS.

Look closely at the error, the message comes from mkfs.btrfs, not from LXD itself.

It’s telling you the partition you passed has already been formatted and so refuses to format it again as that may cause data loss. If you know the partition doesn’t contain anything and is safe to use, then you’ll need to clear its header with something like dd if=/dev/zero of=/dev/disk/by-label/mylabel bs=4M count=10 (writes zeroes on the first 40MB of the partition).

Oh. Ok. Preserve it the label already set in this case ?

You should use a partition table label rather than a filesystem label in this case.

Though with btrfs, it doesn’t really matter as LXD will track it by UUID as soon as it’s formatted.

Ok. Thanks for you help here. I test that later and give you a feedbak to close this topic properly :wink:

My main goal here is to reconfigure my default lxd settings same as I tried to do when I attempt to create a new one with lxd init. I just try to set lxd to not work on my internal ssd but in an extrernal disk.

Here is the log of my lxd init command: https://hastebin.com/oyaciwejox.log

Using the partlabel seems to work nice but I have another error. How to reconfigure my default lxd settings to work on an external disk ?

Extra informations about my lxd here: https://hastebin.com/winafoviju.log

lxd init never deletes anything, so running it on an already configured system can be a bit awkward.

If all you want to do is reconfigure storage. You should do something like:

  • lxc profile device remove default root
  • lxc storage delete dir-storagepool
  • lxc storage create default btrfs source=/dev/disk/…
  • lxc profile device add default root disk pool=default path=/

Do you think it’s more intresting in my case to uninstall the lxd snap and reinstall it from scratch or try to reconfigure the storage as explained to also get the stability? I have nothing to keep for the moment.

If you go the reinstall route, I’d recommend a reboot since you have configured networks that a remove is unlikely to fully cleanup.

The instructions above should work just fine and get you to something virtually identical to what lxd init would do.

(There’s nothing special in lxd init, it just effectively does all of those commands for you in one shot to be more user friendly)

Ok. Thank you for help Mr stgraber :slight_smile: