Noob question: How to create additional storage? (loop file based, dir, etc.)

This will be maybe the easiest question for anyone to answer but I am 100% stuck.

How do you create a new storage - that is NOT block based?
So basically, how do you create new storages? What are the options?

I love LXD, and I would love to learn more about it, but it is so hard to find more information about various bits… storage is one of these bits.

  • Read the doc. I did. That was about the second thing I did. First I tried to just use the command and find out myself. The doc is great on explaining small bits about how you grow an existing file based ZFS for example and that sort of thing.
  • Use the ‘lxc storage’ command and find out. I tried, but it just tells me I either use a block device or I’m not getting any storage.
  • It would be great if I could learn proper storage management. Like how do I change which storage is default, how do I move them around, that sort of thing.

Ps.: LXD is great, it’s a wonderful tech, please, keep up the great work!

To create a loop file based storage, just don’t specify a source, this works for btrfs, zfs and lvm:

  • lxc storage create NAME zfs
  • lxc storage create NAME btrfs
  • lxc storage create NAME lvm

If you just want to use an existing directory to store containers directly, you can do that with the dir backend, though this is our most limited backend feature and performance wise.

  • lxc storage create NAME dir source=/some/empty/directory

Dear stgraber!

Thank you for replying so quickly.
My original question remains - which I do realize I should have worded differently - how do I create a new, let’s say lvm storage in an empty directory? I mean, how do I create a loop file?

During the init process, I can simply say “N” to block device, then say 100GB, and it will create a loop device, with LVM, ZFS, btrfs, whatever I ask for. And that works great. But I would like to create a loop based storage elsewhere (to a VPS Volume that is mounted under /mnt/whatever/…).

Thank you!

You can’t. LXD expects all the loop files it manages to be inside /var/snap/lxd/common/lxd/disks.

If you want them somewhere else, then it’s up to you to manually create a loop file somewhere else, create the filesystem or LVM on top of it, then tell LXD to use it.

So for ZFS you could do:

  • truncate -s 50G /srv/blah.img
  • zpool create mypool /srv/blah.img -m none
  • lxc storage create mypool zfs source=mypool

But then it’s on you to make sure that the mypool zpool is online by the time LXD starts up, so you may need some init scripts and the like to ensure everything works.

Similar instructions would go for LVM (manually create a VG). For something like btrfs, you’d then want to have it be mounted somewhere through /etc/fstab and then pass that as the source when creating the LXD pool.