How do I resize a btrfs filesystem to the minimum possible size in a single step?

I only want to dd the smallest amount of data possible, and want to use dd since btrfs send is progressively slower the more snapshots there are.

btrfs filesystem resize has a max argument, but no min argument.

If I try to resize more than the free space available, I get a message like:

ERROR: unable to resize '/media/backup-alt': No space left on device

I've been progressively resizing downwards in steps of decreasing size (eg passing arguments -128G -64G, -32G, ...) but this is a time consuming convergence on a solution.

Is there a way to shrink to minimum in a single step?

  • 1
    Note: you'll need to change the UUID of the duplicate before mounting either filesystem again, or you'll get filesystem corruption!
    – Tom Hale
    Commented Feb 17, 2018 at 10:52

2 Answers 2


The best solution I've come across so far is to get the minimum free space (using -b for bytes):

sudo btrfs filesystem usage -b /mountpoint
   Free (estimated):              71890542592 (min: 71890542592)

And then resize by the negative of the min amount:

sudo btrfs filesystem resize -71890542592 /mountpoint

Alternatively, if there is a big difference between the min free and the unallocated, you may choose to use (unallocated * 0.9) since resizing by the exact unallocated bytes seems to fail.

You can then repeatedly shrink by small amounts until the resize fails:

while sudo btrfs filesystem resize -200M /mountpoint; do true; done

This is not exactly a single step, but at least mostly automated. The loop by itself could be a single step, but it will probably take longer doing small incremental resizes rather than initially shrinking by a large chunk.

  • Hi, can you please Edit your answer to add the output of your sudo btrfs filesystem usage -b /mountpoint ?
    – SebMa
    Commented Mar 31, 2019 at 12:00
  • @SebMa I can't remember which filesystem this was now... what do you find unclear?
    – Tom Hale
    Commented Apr 25, 2019 at 7:38
  • Which line in sudo btrfs f u -b /mountpoint do you pick the 71890542592 from ? Can you please give another output from any btrfs currently use ?
    – SebMa
    Commented Apr 25, 2019 at 9:28
  • 1
    @SebMa there is only one line in the output that contains Free, and one min value... Still, I updated for great karma.
    – Tom Hale
    Commented Apr 25, 2019 at 9:51
  • Exactly what I wanted so there is no ambiguity possible.
    – SebMa
    Commented Apr 25, 2019 at 9:57

An easier solution to your problem would be to use partclone.btrfs instead if dd, it's a partition cloning and imaging tool that automatically skips unused blocks for supported filesystems (including BTRFS), so no resizing needed.

https://www.partclone.org (GPL-2.0)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .