[HowTo] Resize a btrfs filesystem

Resize a btrfs filesystem/device (Wiki)

When resizing a filesystem, you also need to resize the partition(device) it is on. With gparted you cannot resize a partition that is mounted ! So you need to unmount it beforehand, or use a live-manjaro from USB to resize the partition and the filesystem.

When resizing existing filesystems it is strongly advisable to be im possession of actual backups. This said, resizing is easily possible when using gparted.

shrink

You must be aware, that you can shrink a filesystem only securely if it is not too full. Shrinking a filesystem may take a long time because btrfs needs to move all data that is located in the area to be freed, into the remaining area. Using gparted is save to shrink a btrfs filesystem.

  • Select the partition
  • Select “Partition/Size change”
  • Apply :white_check_mark:

gparted will take all necessary steps like:

  • mount filesystem
  • shrink filesystem (so it later will fit exactly into the partition)
  • umount filesystem
  • shrink partition

expand

Using gparted is save to expand a btrfs filesystem. It will take all necessary steps like:

  • expand partition
  • mount filesystem
  • expand filesystem (to the max of the partition)
  • umount filesystem

If a btrfs volume consists of several devices (partitions). The resizing-operation is performed on each device in a separate step.
:footprints:
If you think this needs corrections … (but please stay on topic)

You should run btrfs balance on a partition first, then the partition can be shrunk.
Otherwise, it can not be shrunk if there is a large hole or many holes between two existing data in the partition. Therefore, btrfs balance would help to move all data to the left in the partition.


Edit:// :point_down:

1 Like

Are you saying gparted also shrinks the filesystem, not only the partition?
I had no idea this is the case!
With using parted in cli it clearly states that parted only shrinks the partition, not the filesystem so the filesystem has to be shrunk with btrfs filesystem resize before resizing the partition.

Thank you for this (for me) new information! (I knew about ext4 but not btrfs)

You don’t need to balance beforehand

But you definitely can.

https://btrfs.readthedocs.io/en/latest/Resize.html

Btrfs will relocate data as needed when a resize is initiated with:

btrfs filesystem resize

And that is what gparted calls :wink:


Yes

:footprints: