LXD does not start after a storage pool was accidentally deleted

I deleted a LXD storage pool named ‘juju-zfs’ (it was a storage pool for juju instances) from zfs without deleting from LXD database. After PC reboot, snap.lxd.daemon fails to start with following message in lxd.log

...
t=2019-10-07T19:46:51+0900 lvl=info msg="Initializing storage pools"
t=2019-10-07T19:46:51+0900 lvl=eror msg="Failed to start the daemon: ZFS storage pool \"juju-zfs\" could not be imported: "
t=2019-10-07T19:46:51+0900 lvl=info msg="Starting shutdown sequence"
t
...

I wonder whether we could delete this zfs storage pool from lxd configuration?
My lxd version is LXD 3.17

I could resolve this issue by myself.

According to the lxd database documentation, it seems that I could delete unnecessary settings at startup by putting a patch.global.sql under /var/snap/lxd/common/lxd/database with query to delete old setting records.

So I confirmed the unnecessary records by

$ sqlite3 /var/snap/lxd/common/lxd/database/global/db.bin
sqlite> select * from storage_pools;
...
sqlite> select * from storage_pools_config;
...

and created a query to delete those records.

Yep, that’s one way to solve that kind of issue, the other is to create the zpool using a loop file or something, have LXD start and then delete the pool as usual.

1 Like