Subject: Random sort-order in du

From: Holger Klene <[email-masked]>
Date: Sat, 30 Sep 2017 22:45:24 +0200

Hello!

I'm using Back-In-Time for backups. Out of curiosity, I wanted to know, how big the snapshots 
are and came across the FAQ:

https://github.com/bit-team/backintime/wiki/FAQ#how-can-i-check-if-my-snapshots-are-incremental-using-hard-links

They recommend:

du -hd1 /media/<USER>/backintime/<HOST>/<USER>/1/

Say I have a subdirectory structure in that folder like this:

+ 2015
I	+ FileA 1GB Inode 123
+ 2016
I	+ FileA 1GB Inode 123
+ 2017
	+ FileA 1GB Inode 123

Now du returns something like:
1G	2016
0G	2015
0G 2017
1G .

So the hardlinked FileA is reported only once (this is actually the desired feature, to not report it 
thrice).

But now the order determines, which folder the size is reported against. But I had to learn, that 
the order of items in the filesystem is unpredictable:

https://serverfault.com/questions/406229/ensuring-a-repeatable-directory-ordering-in-linux#answer-675748

I'd like to suggest to add some sort-controlling options known from ls --sort

The desired behavior in this case would be either alphabetical or reverse-alphabetical to 
attribute the FileA to the first or last appearance in the tree respectively.

Thanxs

Holger

PS: coreutils 8.25 with ext4 file-system

-- 
|_|/    MfG
| |\    Holger Klene

PGP Key ID: 0x22FFE57E