Follow

Is "df" broken?

I have an external USB drive I use for backups, and I'm preparing to swap it out for a fresh one. It was full, and I'm been cleaning it a bit before the swap. In doing so I've found that

# df -B 1 <mount_point>

was producing:

1B-blocks 1968842792960
Used 1870698692608
Available 0
Use% 100%

That surprises me a little ...

Ubuntu 20.04 LTS

# df --version
df (GNU coreutils) 8.28

Comments?

· · Web · 1 · 1 · 1

@ColinTheMathmo What file system on that drive? If it's an ext* fs, could it be a combo of reserved blocks and fs overhead? The total blocks is definitely raw blocks, not what's available to the fs, just checking on a drive that I have and adding the used/avail up.

@cefiar It's EXT4 ... I'm finding that the Usage number goes up and down exactly as expected. Archive files to a tarball, the "Used" figure goes up. Remove the originals, the "Used" figure goes down.

The "Available" and "Use%" figures remain static at 0 and 100% respectively, even when subtracting or dividing "Used" and "Total" appropriately show that they should not be.

It's as if a "needle" got to the limit of its travel and got stuck there.

@ColinTheMathmo @cefiar are you writing to the disk as root? That lets you override the 'reserved block'

@penguin42 @cefiar Ah, good point ... (pause) ... OK, trying to write as user gives me "no space on device" but writing as sudo let's me succeed.

OK, so how do I return to getting useful results from df?

(and thank you)

@ColinTheMathmo @cefiar The answer depends what you want; I think if you run the df as root it'll give you the real answer; as a normal user it's telling you what is available to use. If you just want it to let you use all the disk as a normal user then use tune2fs -m 0 to remove the reserved blocks.

@ColinTheMathmo @cefiar The reserved blocks are there for 2 reasons; 1) So when a user fills up the root directory they dont stop system processes from working 2) The block allocation algorithms get much less efficient when the disk is nearly full. (1) is irrelevant in your case, (2) is probably mostly irrelevant.

@penguin42 @cefiar Running "df" as root also gives me 0 and 100% for Available and Use%, so that seems not to be the entire story.

I'll think about "tune2fs -m 0" ... thanks.

Sign in to participate in the conversation
Mathstodon

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!