Lxd btfrs defrag needed?

Hi all,

Ininstalled the default btrfs filesystem for my containers. Do we need to defrag them? Some containers are becoming slow to respond

You could do a btrfs scrub and btrfs balance run, but that’s usually more for validating consistency than to improve speed.

Hi

Do i do this on the lxd.img file?

from: https://lxd.readthedocs.io/en/latest/

For production environments, you should be using block backed storage instead both for performance and reliability reasons.

Hi

What do you mean with this?

@stgraber has answered to your first question that the operations you want to do have nothing to bring performance-wise; you replied by answering you wanted to do them anyway, and gave the additional information that you were using a loop file backed storage. So I pointed to you that using a loop file backed storage is not recommended for performance reasons, hence you would be better off switching storage mode to block based if performance is your primary concern. That’s it.

Is there an easy way to switch? And how could i do this?

If you have enough available disk space and your system uses LVM, that’s reasonably easy. You can use lvreduce to make space available, then lvcreate to create another volume in the freed space. Then you use something like

sudo lxc storage create new_default btrfs source=/dev/ubuntu-vg/lxd

Very important with btrfs: the partition should NOT be initialized before calling lxc storage create. If it is, the best way is to delete it with lvdelete and recreate it again.

Once you have your new shining storage pool, you move your containers to the new storage pool with lxc move -s . Once it’s done, make the new storage default, remove the old storage and finally you delete the image file. lxc storage --help is your friend.

If your disk is not formatted with LVM, you will have to sweat with fdisk. Ugh. Better to add another disk maybe :slight_smile:

Hi gpatel-fr,

Thank you for your reply but i need some help here. My setup is now:

  • 4 x ssd in raid 10
  • formatted as xfs filesystem
  • on top of this i installed lxd with the btrfs pool

What should be the setup. should i create 2 raid storage devices and use one for btrfs pool?

Probably but I can’t give you best advice, I have always avoided XFS file systems since I discovered that there is no way to reduce them.
So the only way I can think of is to do a backup, reformat everything and restore.
Maybe there are XFS tricks to work around this, but I don’t know them.

Wat filesystem are you using?

Wat should be better.

Btrfs
Zfs

Or lvm backend. Wat options am i losing here?

ZFS block backed storage works well for me, e.g. dedicate a whole unformatted, unpartitioned drive /dev/sdb or /dev/vdb entirely to zfs

It’s not the most flexible but it seems the most robust in practise. Only my brief experience with them though!

avoid using .img files / loop backed.

Sorry I don’t think it will be of any use for you, my primary goals are simplicity and reliability, your stated goal is performance, a consideration that is secondary for me.
For the record I always partition my disks with LVM (for flexibility), the primary partition (system and home) is ext4 and the LXD partition is btrfs. I don’t use RAID, I trust backups.

After a lot of thinking i am going to reinstall my system.

Raid 10 mdadm 4 ssd

  • will partition it then i will give lxd a partition with btrfs so no loopback is being used.

Am i correct with this?

Hi @bodleytunes

In terms of filesystem btfrs speaking

Are subvolumes the same as loopbacked?