/dev/sdX as storage has changed. How to fix?

Hi,

I’m a complete newbie to LXD/LXC, so please be nice. :wink:

I set up a whole partition on an extra SSD (/dev/sde1) as a storage with lxd init, did some stuff with containers and now did some updates so my home server and rebooted it. And what had to come, came to pass: This partition is now /dev/sdb1 while /dev/sde1 is the EFI boot partition and of course nothing works anymore.

lxd --debug says

Failed to start the daemon: Failed initializing storage pool "default": Failed to mount "/dev/sde1" on "/var/snap/lxd/common/lxd/storage-pools/default" using "btrfs": device or resource busy 

which isn’t surprising.

As I set up lxd I tried to use /dev/disk/by-id but that didn’t work so I went for /dev/sdX. I did some research and really didn’t find any advice on how to not use /dev/sdX for this.

How can I solve my issue and make the storage available again? Running lxd init returns:

Error: Failed to connect to local LXD: Get "http://unix.socket/1.0": dial unix /var/snap/lxd/common/lxd/unix.socket: connect: no such file or directory

And furthermore how can I use a block device a storage without using the /dev/sdX?

That’s a bit of a weird error as for btrfs we don’t actually use the device name but instead rely on its UUID.

Can you install sqlite3 and then run sqlite3 /var/snap/lxd/common/lxd/database/global/db.bin "SELECT * FROM storage_pools_config;"

It says:

3|1|1|size|30GB
4|1|1|source|/dev/sde1
5|1|1|volatile.initial_source|/dev/sde1

Oh, okay, that’s unusual…

Anyway, you can fix this by writing a file at /var/snap/lxd/common/lxd/database/patch.global.sql containing:

UPDATE storage_pools_config SET value='/dev/sdb1' WHERE value='/dev/sde1';

Then attempt to start LXD again and the patch should get applied fixing this issue.

1 Like

That worked, thanks! What can I do to prevent this happening again? Otherwise if /dev/sdb goes /dev/sdc after a reboot I’d have to apply this fix again.