#921038 "btrfs filesystem resize", add "min" to minimize a Btrfs filesystem

Package:
btrfs-progs
Source:
btrfs-progs
Description:
Checksumming Copy on Write Filesystem utilities
Submitter:
Date:
2025-12-02 01:15:02 UTC
Severity:
wishlist
Tags:
#921038#5
Date:
2019-01-31 22:59:21 UTC
From:
To:
"min" could be used to minimize a Btrfs filesystem as "max" is used to
maximize a Btrfs filesystem, which would avoid to use "btrfs
inspect-internal min-dev-size" and at least one other software to
extract the number (for example "cut").

#921038#10
Date:
2025-10-11 22:09:32 UTC
From:
To:
Hi,

Sorry no one replied to your bug sooner.  I became the maintainer of
btrfs-progs for Debian at 6.12-1.

21naown@gmail.com writes:

Can't [g]parted already do this in an easy and safe way?  What is the
use case for what you're proposing and why would it be preferable to
[g]parted?

Regards,
Nicholas

#921038#17
Date:
2025-12-02 01:13:17 UTC
From:
To:
Hi,

I took a look a this again, to see how much of a potential gain it would
provide, and here is what I found:

    # df -h /
    Filesystem            Size  Used Avail Use% Mounted on
    /dev/mapper/cryptvol   98G   76G   22G  79% /

    # btrfs inspect-internal min-dev-size /
    104517861376 bytes (97.34GiB)

In other words, it doesn't look like one of the existing (safe)
approaches would be useful.

I'm guessing that this is the difference between

    # btrfs filesystem usage -b /
    Device size:                      104517861376
    Device allocated:                 104516812800

BTRFS-FILESYSTEM(8) indicates that "There are two ways to minimize the
filesystem on a given device. The btrfs inspect-internal min-dev-size
command, or iteratively shrink in steps."  So I wonder if you're asking
for syntactic candy that shrinks the filesystem by something like 512MB
every step, in a loop, until it gracefully fails.  Assuming it
safely and gracefully fails...

Regards,
Nicholas