du measures in 4K blocks resulting in inaccuracies
Date: Thu, 07 Nov 2024 01:01:36 UTC
I'm trying to size a disk. Unfortunately /usr/bin/du is misleading. An
example referencing two files, one 60 Bytes, other 908 Bytes:
unset BLOCKSIZE
echo ; ls -l /projectx/adm/README /projectx/adm/gen_pw.sh
echo "1 ---" ; ls -lh /projectx/adm/README
echo "2 ---" ; du /projectx/adm/README
echo "3 ---" ; du -ckh /projectx/adm/README /projectx/adm/gen_pw.sh
-rw-r----- 1 sysman wheel 60 Jul 28 2023 /projectx/adm/README #60B
-rwx------ 1 sysman wheel 968 Jul 28 2023 /projectx/adm/gen_pw.sh
1 ---
-rw-r----- 1 sysman wheel 60B Jul 28 2023 /projectx/adm/README
2 ---
8 /projectx/adm/README <<< 8 sectors
3 ---
4.0K /projectx/adm/README <<< min count is 4K, so sectorsize?
4.0K /projectx/adm/gen_pw.sh
8.0K total <<< Expect at most 2K
# diskinfo -v /dev/ada2p3
/dev/ada2p3
512 # sectorsize
Perhaps my understanding is wrong, so to authority "man du"
-k Display block counts in 1024-byte (1 kiB) blocks. (incorrect)
-h "Human-readable" output. Use unit suffixes: Byte, Kilobyte,
Megabyte, Gigabyte, Terabyte and Petabyte based on powers of
1024. (? 4K)
but even --si gives
4.1k /projectx/adm/README # <<< 4.1K??!
4.1k /projectx/adm/gen_pw.sh
What am I missing? Should the doc reflect the minimum reporting size is 4K?