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. I recall something about a block being a minimum of 512 bytes. and 8 * 512 = 4096 so I can make the other tools agree with each other.
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
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. I recall something about a block being a minimum of 512 bytes. and 8 * 512 = 4096 so I can make the other tools agree with each other.
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.
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
ls -s uses wrong block size
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. I recall something about a block being a minimum of 512 bytes. and 8 * 512 = 4096 so I can make the other tools agree with each other.
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.