LXD cleanup problem when uninstall & install again

I have found this problem on two different computers
while installing and uninstalling LXD for testing

Environment: Ubuntu 18.04, LXD installed with apt

  1. Installed LXD with apt

  2. Initialized LXD with clustering feature on, local zfs storage using block device(/dev/sda5), without any bridge

  3. Removed LXD with apt
    sudo apt remove -y lxd

But sudo zpool list still shows “local” pool…
so I removed manually

  1. Install LXD again
    sudo apt install -y lxd

Now apt installation process gets stuck at "Setting up LXD"
It’s around Progress: [ 67%]

1 Like


I think you need to purge the previous data if you want to re-install:

sudo apt purge lxd
sudo apt install lxd

In your case you’ll need to kill the apt install process, and probably then repair the dpkg database manually, something like:

sudo dpkg --purge --force-all lxd
sudo dpkg --reconfigure -a
sudo apt install lxd

but it depends on which state your system is in.

We might want to consider this a bug, @stgraber?

The package manager can’t always untangle all of the system integration, filesystems, … which you might have defined.

One way is to remove the package and purge it, then reboot you system to make sure all kernel state is gone. Another way is to use the LXD API to stop and delete all containers, images, networks and storage pools. At which point the kernel state should effectively be gone and uninstalling/reinstalling should be fine.

I personally tend to go with the former, mostly out of laziness :slight_smile:

1 Like