Understanding and how to correctly set up storage

Hi everyone,

I’m new to lcx/lxd. I do not understand storage. Please help.
Currently I am using the “dir” backend, all is fine, except I see the available space from the entire drive, despite having the limit set in the profile.

 root:
    path: /
    pool: data
    size: 5GB
    type: disk

where the “data” is “dir” backend storage (with this setup, from the container I see all the 2+ TB of space, instead of 5 GB).

On the server I have a hardware raid, I do not want additional safety with zfs or btrfs (btw, do these backends use a file or a physical partition/disk?). I would want something simple either a “dir” backend with a specific limit or something like a file on the filesystem for each container (I understand that loopback devices are not recommended). So what would be a better choice?

Any advice is appreciated. Thank you.

They can use either a loop file or a dedicated disk/partition, the latter provides significantly better performance though.

If you’re only after quotas and don’t care about:

  • snapshots
  • migration
  • backups

Then an option may be to enable project quotas on your ext4 filesystem. This will then allow for the size property on individual volumes to work and I believe may even lead to df properly reporting the quota in the guests.

If you however expect that any of the features above would be useful to you, then having a dedicated partition and using ZFS (ideally) or btrfs (alternatively, its quotas are a bit wonky) would be best.

Alternatively, you can use the LVM storage type - directly via LXD or dir on a manualy created and mounted LV (in specific cases).

Thank you everyone,

I managed with ext4 for now. I put the usrquota,grpquota into fstab, but not the prjquota (also had to enable it with tune2fs). After rebooting and recreating the instance, I now see the correct disk size from the container. Maybe this should be mentioned in the documentation (prjquota option is needed on ext4 for “size” to work - if it is, my apologies, I didn’t see it).

A question about loop files, how does that work (I do not understand from the documentation), does lxc create one storage file for each instance, or do I have to create one manually and all instances will be stored there (on the same file)? Is this also the case with lvm/zfs/btrfs?

Thanks.

Hi LvF,
Can you follow the instructions at the below link, @stgraber explains loop device in that post.
Regards.

Thank you, it isn’t clear to me, but I assume every container is stored on the same one storage.

Hi,

Yes, thats correct.

Ok, thank you everyone for your help and time, it’s clear now how it works.