1

Why is the size of /dev/sda always zero? You have to run commands like:

blockdev --getsize64 /dev/sda

or

cat /sys/class/block/sda/size

to get the size. You cannot use ls.

What is the reason for that?

zomega
  • 972

1 Answers1

2

ls shows the size of file system entries, like /dev/sda; but /dev/sda is just a name under which you can find the block device. It's not the content of the block device.

This confusion gets easier when you think of things like CDROM drives: /dev/sr0 is the name of the drive, and before you try to access it, your computer hasn't even got any idea of the size of the medium in it.

So, think about the ls size as the size of the information that there's a hard drive, not the hard drive itself.