Re: how to get the size of a disk partition from user space?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, May 19, 2008 at 6:18 AM, Adil Mujeeb <mujeeb.adil@xxxxxxxxx> wrote:
> On 5/19/08, Michael Blizek <michi1@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
>> On 07:55 Sun 18 May     , Robert P. J. Day wrote:
>> >
>> >   possibly slightly off-topic, but i've been handed (not at hand at
>> > the moment, though) an embedded system running 2.4.26, which has a
>> > bunch of flash-based partitions corresponding to the device files
>> > /dev/scsi/host-?/bus0/target0/lun0/part-?.
>> >
>> >   what i want is a quick way to determine the size in bytes of those
>> > partitions.  will there be entries for them in /proc/partitions?  is
>> > there a better way?  they won't necessarily be mounted; in fact, they
>> > probably won't be.  thoughts?  thanks.
>>
>> cat /sys/block/hda/hda1/size
>>        -Michi
>> --
>
> it display the data in which unit?
> On my system, the output is as follows:-
>
> adil@localhost:~> df -h
> Filesystem            Size  Used Avail Use% Mounted on
> /dev/sda1              10G  4.7G  5.3G  47% /
> udev                  466M  208K  466M   1% /dev
> /dev/sda5              43G   14G   27G  35% /home
> /dev/sda7              20G  7.1G   12G  39% /home1
>
> adil@localhost:~> cat /sys/block/sda/sda1/size
> 20900502
> adil@localhost:~> cat /sys/block/sda/sda5/size
> 91570437
>
> These outputs are not matching with the first one.
> Am I missing anything??
>

The native data transfer size for a disk drive is sectors.  When you
ask for -h you get sizes that you like, but it is foreign to the disk
itself.

>From a physical disk perspective, talking about bytes is like talking
about bits when discussing ram.  It can be done, but it does not match
the inherent layout of the media.

ie. I don't believe disks even support sub-sector transfers.  If you
want to modify half a sector, you have to do a read/modify/write
sequence.  Very much like working with bits in ram.

Greg
-- 
Greg Freemyer
Litigation Triage Solutions Specialist
http://www.linkedin.com/in/gregfreemyer
First 99 Days Litigation White Paper -
http://www.norcrossgroup.com/forms/whitepapers/99%20Days%20whitepaper.pdf

The Norcross Group
The Intersection of Evidence & Technology
http://www.norcrossgroup.com

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux