I have tried LXD both installed from source and installed using snapd.
Snapd is ‘normally’ set up so that when one uses snap remove xxxxx that software is removed.
LXD is a ‘special’ snap as advised in these pages where LXD is given greater access to the underlying system for its particular needs. This also means that it is not possible to remove LXD using snap remove lxd. In trying this one is left with a number of directories what can’t even be removed by using rm -r (there is a system refusal resultant).
So how do I remove LXD (installed using snapd) from my system?
(Hopefully without having to do a M$ fix!!!)
The main issue with removing LXD is related to storage pools as those can cause a number of mounts that then misbehave when the snap is removed.
You should make sure to delete all containers, images, custom storage volumes and storage pools prior to removing the snap. I’d also recommend removing all networks for good measure.
With that done, the snap should remove cleanly.
We do have on our todo to add logic to the snap that will have it do that for you on package removal (not sure if snapd has implemented hooks for that yet though…).
To make sure I have this correct - - - what I need to do is whilst still in lxd is to first kill lxdbr0 (and and other networking), then I would delete all the containers (this presently needs to done one at a time) and images. Then any storage volumes need to be removed and lastly all storage pools need to be removed. Then, and only then, can lxd be removed.
How does one remove the storage pools?
The storage pools are setup using lxd init but that ‘tool’ really doesn’t give any indication on how to remove any storage pool.
Yeah, once the LXD snap is properly removed, removing snapd should be fine.
I suspect snapd is supposed to cleanup all snaps on removal but I’m not sure I’d necessarily trust that to happen
Should we add the lxc profile list also to the list of things to be cleaned ?
The lxc list --format yaml is useful to do selective cleanup. Can we have the yaml format supported for all commands so that automated scripts can do the cleanup. Some of the commands don’t support the yaml output.
erm, I just installed lxd on a Lubuntu 16.04 LTS VM with snap and it was only for a quick test, created a container, tested it, deleted it and the associated image, did a sudo snap remove lxd and no error, everything seems to have worked without a glitch. Under /var/snap there is only core, so it seems that no storage is left behind, lxdbr0 is gone too. Seems progress to me.
@stgaber
Hi, I cannot do the last step.
My pool is called “zfspool1” but I cannot remove it because it is referenced in the default profile and I cannot remove the default profile
mirto@mirto-P65:~$ sudo lxc profile show default
config: {}
description: Default LXD profile
devices:
eth0:
name: eth0
nictype: bridged
parent: lxdbr0
type: nic
root:
path: /
pool: zfspool1
type: disk
name: default
used_by: []
mirto@mirto-P65:~$
mirto@mirto-P65:~$ sudo lxc storage delete zfspool1
Error: Storage pool "zfspool1" has profiles using it:
default
mirto@mirto-P65:~$ sudo lxc profile delete default
Error: The 'default' profile cannot be deleted
mirto@mirto-P65:~$
Also I cannot change the pool: value using a non existent pool
xxx is a non existent pool so when I try to save the default profile
I receive the error
mirto@mirto-P65:/etc/init.d$ sudo lxc profile edit default
[sudo] password di mirto:
Config parsing error: The "xxx" storage pool doesn't exist
Press enter to open the editor again
and you can exit only issuing a ^C so the profile is not changed.
Also to note for those using the BTFRS file system. You will want to delete the sub volumes nested under the created storage volume. You most likely won’t be able to delete the storage volume prior to doing this.
To view volumes you can use:
btfrs subvolume list /var/lib/storage-pools/[STORAGE NAME]
For the sake of whoever will come here at a later time…
actually the step "network delete <whatever came from list>" is not going to work for (at least) two reasons:
(trivial) lxc network list will list all networks and you don’t want to delete them all.
(less trivial) even after all containers/images are gone lxdbr0 network is still owned by default so an lxc network detach-profile lxdbr0 default is needed before lxc network delete lxdbr0.
(nitpick) you forgot backticks around echo '{"config": {}}' | lxc profile edit default so the quoting marks got converted making the line fail if used by copy&paste.