0

I'm using BTRFS with two 1TB drives formatted as a single 2TB partition. I can't figure out how much space is actually in use in my system, most tools give me different results:

  • du -cksh / says 791GiB
  • Filelight says / is 44GiB (I'm inclined to believe this as it's a fairly new install)
  • btrfs fi df -h / says 947GiB

My guess is these tools are measuring different things. What I want to know as a user is how many bytes I can still cram into the filesystem before it goes kaput.


Edit: I was recommended btrfs fi usage /, here's what it says:

Overall:
    Device size:           1.86TiB
    Device allocated:        955.02GiB
    Device unallocated:      952.42GiB
    Device missing:          0.00B
    Used:            939.36GiB
    Free (estimated):        966.78GiB  (min: 490.57GiB)
    Free (statfs, df):       966.78GiB
    Data ratio:               1.00
    Metadata ratio:           2.00
    Global reserve:      512.00MiB  (used: 0.00B)
    Multiple profiles:              no

Data,single: Size:945.01GiB, Used:930.64GiB (98.48%) /dev/nvme0n1p2 471.01GiB /dev/nvme1n1 474.00GiB

Metadata,DUP: Size:5.00GiB, Used:4.36GiB (87.13%) /dev/nvme0n1p2 6.00GiB /dev/nvme1n1 4.00GiB

System,DUP: Size:8.00MiB, Used:128.00KiB (1.56%) /dev/nvme0n1p2 16.00MiB

Unallocated: /dev/nvme0n1p2 476.54GiB /dev/nvme1n1 475.87GiB

Seems to corroborate the other btrfs command, but then the follow up is, how can I know what's taking all this space? Is this space actually taken by files, or is this just overhead?

Kroltan
  • 244
  • 2
    @ArtemS.Tashkinov not a very productive comment. BTRFS is the default file system for multiple "large" linux distros now, and it seems fairly reliable. So yes, my guess is, if Kroltan asks, they want to use btrfs. – Marcus Müller Oct 07 '22 at 14:58
  • Lots of Linux newcomers use exactly what's offered by default without understanding or recognizing the consequences. I still consider btrfs an experimental filesystem because even in 2022 I've seen reports of people losing their data to it due to algorithmic errors. Comments do not need to be productive, they need to be thoughtful. I could have written "There's no need to use btrfs if you don't require its features". I trust ext4 which is used on almost 1.5 billion of devices (Android) a lot more. – Artem S. Tashkinov Oct 07 '22 at 15:19
  • In use = filesystem size - filesystem free. So free space is most relevant metric to figure out disk usage because it includes all data and metadata with regard to compression, snapshots, sparse files, deduplication, hardlinks... – gapsf Oct 07 '22 at 16:21
  • Run du as a root so it access all files. If you want files size use du --apparent, if you want how much space files ocuppy on disc use du – gapsf Oct 07 '22 at 16:25
  • 1
    https://unix.stackexchange.com/questions/120311/why-are-there-so-many-different-ways-to-measure-disk-usage – gapsf Oct 07 '22 at 16:25
  • @ArtemS.Tashkinov well said! By the way, modern androids don't exclusively use ext4, but one of the more flash-optimized file systems. For example, my last phone used f2fs, not even sure what this one does; google's pushing (and being Google, probably succeeding) EROFS (it's mandatory for new phones launching with Android 13). – Marcus Müller Oct 07 '22 at 16:44
  • btrfs fi usage https://btrfs.wiki.kernel.org/index.php/FAQ#How_much_free_space_do_I_have.3F – gapsf Oct 07 '22 at 17:07
  • I wasn't able to read the first comment by Artem, but I appreciate that btrfs can be janky, and do regular backups of my data. I've updated the question with the output @gapsf asked, but I'm still confused about what's taking this space. – Kroltan Oct 07 '22 at 20:41
  • Check snapshots with https://github.com/speed47/btrfs-list – gapsf Oct 08 '22 at 04:02
  • Use https://dev.yorhel.nl/ncdu and check each direcrory. Run as root – gapsf Oct 08 '22 at 04:09

0 Answers0