On 08.05.2021 20:06, Bernhard M. Wiedemann wrote:
On 08/05/2021 17.34, Sid Boyce wrote:
linux-sl6n:~ # df -h
Try instead btrfs filesystem df /
because the stat syscall used by df cannot reflect all the details of btrfs with its snapshots and copy-on-write.
Oh, really? Yet another town legend about btrfs ... bor@tw:~> df -h / Filesystem Size Used Avail Use% Mounted on /dev/vda2 39G 25G 14G 66% / bor@tw:~> So you say it lies and I must use "btrfs fi df"? bor@tw:~> sudo /usr/sbin/btrfs filesystem df / Data, single: total=30.01GiB, used=22.77GiB System, DUP: total=32.00MiB, used=16.00KiB Metadata, DUP: total=1.50GiB, used=987.25MiB GlobalReserve, single: total=78.38MiB, used=0.00B bor@tw:~> Oops. How is novice user supposed to interpret it? Where is my free space? So you claim that "df" lies and I have only 7.3GB of available space? "btrfs fi df" IS NOT ENOUGH to get information about available space because btrfs is using two-stage allocator and "btrfs fi df" only shows second half of it. It can only be sensibly used with information about the first half, which gives bor@tw:~> sudo /usr/sbin/btrfs filesystem show / Label: none uuid: cc072e56-f671-4388-a4a0-2ffee7c98fdb Total devices 1 FS bytes used 23.73GiB devid 1 size 38.91GiB used 33.07GiB path /dev/vda2 bor@tw:~> So I have 40GB disk, 33GB of which is allocated by the first stage of allocator and OF THIS ALLOCATED SPACE 22.77GB is used by data allocated by the second stage allocator. And if I had 1TB disk with 33GB allocated, "btrfs fi df" STILL showed the same 30GB without any indication how much additional disk space is available. But now in "btrfs fi df" output we apparently have "lost" 1.5GB - "total" as shown amounts to 31.5GB while "used" in "btrfs fi sh" is 33GB. And to explain it we need to know what "DUP" allocation profile is and that it allocates two copy of everything. And that "btrfs fi df" shows the LOGICAL size, not PHYSICAL. Do not you think it is a wee bit too much to demand from novice user who has met btrfs for the first time? The swiss knife today is "btrfs fi us" bor@tw:~> sudo /usr/sbin/btrfs filesystem us -T / Overall: Device size: 38.91GiB Device allocated: 33.07GiB Device unallocated: 5.84GiB Device missing: 0.00B Used: 24.70GiB Free (estimated): 13.08GiB (min: 10.16GiB) Free (statfs, df): 13.08GiB Data ratio: 1.00 Metadata ratio: 2.00 Global reserve: 78.38MiB (used: 0.00B) Multiple profiles: no Data Metadata System Id Path single DUP DUP Unallocated -- --------- -------- --------- -------- ----------- 1 /dev/vda2 30.01GiB 3.00GiB 64.00MiB 5.84GiB -- --------- -------- --------- -------- ----------- Total 30.01GiB 1.50GiB 32.00MiB 5.84GiB Used 22.77GiB 987.25MiB 16.00KiB bor@tw:~> It shows as total disk size, how much of it is allocated by the first stage, how much space from this is consumed by the second stage, and finally it shows the same estimation that plain df shows. All in all, for a btrfs on a single device "df" is pretty much accurate. And neither df nor "btrfs fi df" do care about snapshots at all. They show you how much space is used by CURRENT DATA. They do not care about logical relationship between this data (which snapshot/cloning is about). Now if you have 1TB disk and 20GB of data in root filesystem and it is shown as full you of course need to investigate where space is gone - but none of the above tools will help you. So putting "snapshots" and "df" in one sentence is simply wrong. Sorry.