I’m looking to set up a filesystem that on some occasions might need extra space, but in other moments might need to shrink.
And this needs to be live at all times. The services using the data on the filesystem cannot go down and needs to provide its data at all times.
I’ve been told Btrfs is the ticket, but also that live resizing is potentially risky.
I have no experience with it, so my first reflex is to set up a test scenario. Can people tell me if what I describe down here is good, what would be better, and what I should be aware about, working with Btrfs?
My test:
Add 6 1GB disks to my VM. Add them all as Physical Disks. Create a single volume group with them, then create a single logical volume with that entire size.
Use mkfs.btrfs on it. Mount it, write it full of data and reboot.
Having rebooted, I now delete all the written data from the directory the volume is mounted as.
Now I want to take out disks, so I need to remove them from the volume group and then as physical disk
I’m reading that I should do something like this first:
sudo btrfs balance start -dusage=75 /mnt/data/
I’m reading this balances data blocks across all devices.
And check progress with this:
sudo btrfs balance status /mnt/data/
And then shrink the filesystem:
sudo btrfs filesystem resize 4G /mnt/data/
This seems to work. However, when shrinking it to 2GB, it refuses, even though there’s free room:
:~$ sudo btrfs filesystem resize 2G /mnt/data/
Resize device id 1 (/dev/mapper/vgdata-lvbtrfs) from 4.00GiB to 2.00GiB
ERROR: unable to resize '/mnt/data/': No space left on device
Apparently this is due to metadata taking up space.
At this point I’m wondering if putting Btrfs on LVM is even a good idea.
This is starting to get chaotic, so I’m going to stop and ask if people have advice for using Btrfs?