While checking for used and free space in a btrfs subvolume, I’m not getting a consistent value. It’s confusing and doesn’t help.

  1. What is the correct way to find used/free space?
  2. Why are these values inconsistent (except normal du)?

According to btrfs fi usage /home, 83.21 GiB is used.

Overall:
    Device size:		 149.98GiB
    Device allocated:		 100.07GiB
    Device unallocated:		  49.91GiB
    Device missing:		     0.00B
    Device slack:		     0.00B
    Used:			  83.21GiB
    Free (estimated):		  63.06GiB	(min: 38.10GiB)
    Free (statfs, df):		  63.06GiB
    Data ratio:			      1.00
    Metadata ratio:		      2.00
...

As per btrfs fi df /home, used space is 82.86 GiB, not 83.21 GiB.

Data, single: total=96.01GiB, used=82.86GiB
System, DUP: total=32.00MiB, used=16.00KiB
Metadata, DUP: total=2.00GiB, used=178.61MiB
GlobalReserve, single: total=99.50MiB, used=0.00B

As per btrfs fi du -s /home , used space is 63.11 GiB.

     Total   Exclusive  Set shared  Filename
  63.11GiB    13.64GiB    49.01GiB  /home

While according to du -hs /home, 64GiB is used.


Also, maximum space used should be close to 72 GiB as per btrfs fi du -s / and 73 GiB as per du -hs /, if btrfs fi usage includes all subvolumes . ‘/home’ and ‘/’ are on separate subvolumes.

  • unhingeOP
    link
    fedilink
    arrow-up
    1
    ·
    edit-2
    9 months ago

    Thanks that helped. I have one snapshot of home. Size of diff between btrfs subvolume and Additional space used by snapshot is 11GiB (probably) and btrfs fi du -s / is 72GiB, making 83GiB (closer to btrfs fi df /).

    • Atemu@lemmy.ml
      link
      fedilink
      arrow-up
      2
      ·
      9 months ago

      Size of diff between btrfs subvolume and snapshot is 11GiB

      WDYM by “diff”?

      Also forgot to mention but if you want to know what’s taking how much space on your btrfs, try btdu. It uses a sampling-based approach and will therefore never be 100% accurate but it should be quite accurate enough after a little bit.

      • unhingeOP
        link
        fedilink
        arrow-up
        1
        ·
        9 months ago

        just comparing the subvolume with its snapshot with btrfs send -p /example/subvol /snapshot/of/example/subvol >examplediff.btrfs.

        From man btrfs-send

        generate a stream of instructions that describe changes between two subvolume snapshots

        Thanks for btdu, it seems useful as ‘btrfs fi du’ probably doesn’t account for compression, will check it out sometime.

        • Atemu@lemmy.ml
          link
          fedilink
          arrow-up
          2
          ·
          9 months ago

          Note that the diff does not necessarily correlate with the amount of data that changed, not how much additional space the snapshot takes.

          • unhingeOP
            link
            fedilink
            arrow-up
            1
            ·
            9 months ago

            You are right. I shouldn’t have used diff. I’ll fix that

            Also, incremental changes from subvolume to its snapshot might be incorrect as that will be new data added to subvolume, rather that old data deleted from subvolume while still present in snapshot. I’ll have to check carefully.