12

I am setting up LXD to play around with conjure-up. I would like to the storage to be mounted only on my RAID device, so it would be good to remove the default storage or replace/redirect it. I cannot remove the default storage because the default profile uses it.

How can I use the RAID storage with conjure-up and be sure it isn't using my default storage?

P H Kaznowski
  • 189
  • 1
  • 1
  • 12

4 Answers4

18

The default storage cannot be deleted because it is part of the default profile. The default profile cannot be removed. So the way around this is to push a blank profile to the default profile with;

printf 'config: {}\ndevices: {}' | lxc profile edit default

Then the default storage will be removed from the default profile, so you will now be able to remove the default storage with;

lxc storage delete default
7

The default storage can be deleted with sudo lxc storage delete default.

Kalle Richter
  • 8,008
  • 26
  • 77
  • 177
  • 5
    When I try this I get `Error: Storage pool "default" has profiles using it: default` – pgoetz Jan 30 '19 at 20:56
  • 4
    And `lxc profile delete default` results in `Error: The 'default' profile cannot be deleted` – pgoetz Jan 30 '19 at 20:57
  • 3
    Removing the default storage from the default profile lets me delete the storage afterwards. `printf 'config: {}\ndevices: {}' | lxc profile edit default` Ref: https://discuss.linuxcontainers.org/t/error-the-default-profile-cannot-be-deleted/3972/3 – dr ganjoo Mar 17 '19 at 07:41
  • @drganjoo method worked for me: change profile to have empty config and devices, then delete storage. – pianoJames Apr 16 '19 at 18:34
1

Ok, I seem to have found a workaround that would seem to work.

I delete the default profile

lxc profile delete default

Then I deleted the lxc-storage

sudo rm /var/lib/lxd/storage-pools

Finally i linked a directory on my RAID as the deleted directory and create a new storage

sudo ln -s /mnt/RAID/lxc-storage-pools /var/lib/lxd/storage-pools
lxc storage create default dir

There must be a better way to do this though.

I then reinstalled lxd because I lost my default profile set up...

P H Kaznowski
  • 189
  • 1
  • 1
  • 12
  • That still causes `lxd init` to fail due to `The requested storage pool "default" already exists. Please choose another name.` – Kalle Richter Aug 21 '18 at 18:20
  • Thanks for pointing that out, the above "solution" is in fact absolutely terrible. I have approved your answer, thanks. – P H Kaznowski Aug 23 '18 at 21:33
1

If you are rearranging your storage as I was, you should backup your LXD profiles / LXD network configuration / containers / images before doing the following.

    lxc list
    lxc delete <whatever came from list>
    lxc image list
    lxc image delete <whatever came from list>
    # I did not actually need to delete lxdbr0
    lxc network list
    lxc network delete <whatever came from list>
    echo ‘{“config”: {}}’ | lxc profile edit default
    lxc storage volume list default
    lxc storage volume delete default <whatever came from list>
    lxc storage delete default

enter image description here

Stuart Cardall
  • 2,099
  • 24
  • 18