in reply to Re: get the size of a special device (drive)
in thread get the size of a special device (drive)

/sys/block/*drivename*/size is useful, it looks liek it uses 512k block size?
  • Comment on Re^2: get the size of a special device (drive)

Replies are listed 'Best First'.
Re^3: get the size of a special device (drive)
by Joost (Canon) on May 30, 2007 at 22:28 UTC
      Personally, I'd go with `du -h` or `du -B 1` (for bytes)

      But AFAICT du is for mounted filesystems. He was asking about raw devices. I suppose the answer is somewhere in the docs for sysfs. (The kernel's?)

        True enough, but I still can't seem to find any docs on /sys/block/*/size.

        A simple grep -ri sys .|grep -i size (in the /usr/src/linux/Documentation dir) doesn't seem to turn up anything useful.

        update: Also, the /sys/bock/*/size entries seem to refer to full drive sizes. There's nothing in there referring to partitions. That might or might not be interesting to the OP.

      unfortunately du requires the filesystem to be mounted, not an option in this case :-(