Sample Header Ad - 728x90

ls -s uses wrong block size

2 votes
2 answers
1753 views
Ubuntu linux: **ls -s** disagrees with **du** & **stat** for the **number of blocks** used by a small file. ls -s ../nc2/.git/logs/refs/heads/ total 4 du ../nc2/.git/logs/refs/heads/ 8 ../nc2/.git/logs/refs/heads/ stat ../nc2/.git/logs/refs/heads/ File: ‘../nc2/.git/logs/refs/heads/’ Size: 4096 Blocks: 8 IO Block: 4096 ...... sudo blockdev --getbsz /dev/sda 4096 ls -s shows the file using 4 blocks. du & size say it uses 8 blocks. Why is ls -s seemingly wrong? Can it not detect the correct block size? I can make it say the file uses 8 blocks by running 'ls -s --block-size 512'. This is NOT a size of file vs number of blocks question. All commands above are listing block size not file size. Edit: More info requested: ls --version ls (GNU coreutils) 8.21 type ls ls is aliased to `ls --color=auto' LS_BLOCK_SIZE=512 ls -s ../nc2/.git/logs/refs/heads/ total 8
Asked by andy boot (1243 rep)
Mar 17, 2018, 03:19 AM
Last activity: Aug 4, 2023, 12:30 PM