How to move a storage to other places?


When I create storage’s they places into /var/lib/lxd/disks/:

lxc storage create ssdpool2 btrfs size=5GB
lxc storage list
|   NAME   | DESCRIPTION | DRIVER |             SOURCE              | USED BY |
| ssdpool  |             | btrfs  | /var/lib/lxd/disks/ssdpool.img  | 1       |
| ssdpool2 |             | btrfs  | /var/lib/lxd/disks/ssdpool2.img | 0       |
  1. How I can create storage pool in another place, for example create into /mnt/work/hddpool.img ?
    When I use option source I get a message:

    Error: Provided path does not reside on a btrfs filesystem

    Do I need first create loopback file and then formatted into btrfs and then use lxc storage create? Why can’t lxc storage create do it for me?

  2. How can move file /var/lib/lxd/disks/ssdpool2.img to another place, for example to /mnt/work/ssdpool2.img? Create symlink on /var/lib/lxd/disks/ssdpool2.img?

I use latest version of LXD - 3.23


Symlinks won’t work. Using a separate loop device would work, though remember that for production environments, actual partitions will be a lot more reliable and a lot faster.

If you want to move all your disks elsewhere, you can do so while LXD is off, then setup a bind-mount over /var/lib/lxd/disks. Again, stay away from symlinks, those will not work or may break at any time.

Sorry, I do not understand answer on my first question.

I open documentation and see key source for Storage pool configuration:

source - Path to block device or loop file or filesystem entry

Loop file? Ok. I do next steps:

dd if=/dev/zero of=hddpool.img bs=1MiB count=1024
lxc storage create hddpool btrfs source=/mnt/work/lxd/hddpool.img

and I get error:

Error: Provided path does not reside on a btrfs filesystem

Hmm… Ok, I do next:

  1. Attach loopback file to loop device:

    sudo losetup -f -P ./hddpool.img
  2. List of loopdevices:

    losetup -l
    /dev/loop1         0      0         0  0 /mnt/work/lxd/hddpool.img        0     512
    /dev/loop0         0      0         1  0 /var/lib/lxd/disks/ssdpool.img   0     512
  3. Making a BTRFS:

    sudo mkfs.btrfs /dev/loop1 -L hddpool
    btrfs-progs v5.4 
    See for more information.
    Label:              hddpool
    UUID:               74be420d-f90a-4215-acc1-91b41c971626
    Node size:          16384
    Sector size:        4096
    Filesystem size:    1.00GiB
    Block group profiles:
    Data:             single            8.00MiB
    Metadata:         DUP              51.19MiB
    System:           DUP               8.00MiB
    SSD detected:       no
    Incompat features:  extref, skinny-metadata
    Checksum:           crc32c
    Number of devices:  1
    ID        SIZE  PATH
        1     1.00GiB  /dev/loop1
  4. Detach file:

    sudo losetup -D /dev/loop1
  5. Try create storage and get next error:

    lxc storage create hddpool btrfs source=/mnt/work/lxd/hddpool.img
    Error: Provided path does not reside on a btrfs filesystem

What I doing wrong?

LXD does not accept loop files outside of /var/lib/lxd/disks, if you use a loop, then you must make sure it will always be using the same path and pass that as the source, not the file backing it.

Ok, I understand. Thank You!