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

Re: lokking for portable way to determine the size of harddisks



On Thursday 08 March 2001 00:21, Marcus Brinkmann wrote:
> On Wed, Mar 07, 2001 at 08:38:54PM +0100, Thomas Lange wrote:
> > I want to determine the size of the local harddisks in a shell. It
> > must be portable so it runs on all hardware. First is used sfdisk,
> > but it's only available on i386. Now I'm using /proc/partitions on a
> > 2.2 kernel:
>
> Using the proc filesystem only works on Linux[1]. The only really portable
> approach is to use statfs(), and that only works for a mounted filesystems,
> which should be sufficient if you are not doing really system specific
> stuff.

statfs() isn't entirely accurate when you have the ability to resize devices 
and file systems.  If you enlarge the space for a LV in LVM and have not yet 
enlarged the FS to match (or if you have reduced the size of the FS but not 
reduced the size of the LV) then the results won't be what you want.

Also if you have spare unpartitioned space in reserve for future use then 
stating the file systems won't work.

-- 
http://www.coker.com.au/bonnie++/     Bonnie++ hard drive benchmark
http://www.coker.com.au/postal/       Postal SMTP/POP benchmark
http://www.coker.com.au/projects.html Projects I am working on
http://www.coker.com.au/~russell/     My home page



Reply to: