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]

 



Like Roberto pointed out, you're using the "-h" flag of df which will give you a human readable output in terms of K, M or G...whichever is most appropriate...  Reading from /sys/block/device/partion/size gives you the raw size of the partition...

-Adam

-------- Original Message --------
Subject: Re: how to get the size of a disk partition from user space?
From: "Roberto A. Foglietta" <roberto.foglietta@xxxxxxxxx>
Date: Mon, May 19, 2008 6:24 am
To: "Adil Mujeeb" <mujeeb.adil@xxxxxxxxx>
Cc: "Michael Blizek" <michi1@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx.com>,
kernelnewbies@xxxxxxxxxxxx

2008/5/19 Adil Mujeeb <mujeeb.adil@gmail.com>:
> On 5/19/08, Michael Blizek <michi1@michaelblizek.twilightparadox.com> 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??

if block size would be 512 bytes then 91570437 / 2 / 1024 / 1024 = 43.3 GB

Cheers,
--
/roberto

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

-- 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