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

lokking for portable way to determine the size of harddisks



Hi folks,

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:

major minor  #blocks  name

   3     0   19938240 hda
   3     1    2048256 hda1
   3     2      56227 hda2
   3     3      56227 hda3
   3     4          1 hda4
   3     5    2048256 hda5
   3     6     313236 hda6
   3     7     313236 hda7
   3     8     489951 hda8
   3     9    2562336 hda9
   3    10    2562336 hda10
   3    11    9486351 hda11

I can grep for hd? orf sd? device if I only need the whole disk. Looks
very nice, but is the blocksize constant on all platforms ? And with
kernel 2.4 and devfsd this looks like

major minor  #blocks  name

   8     0    8844633 scsi/host0/bus0/target0/lun0/disc
   8     1    8302392 scsi/host0/bus0/target0/lun0/part1
   8     2     538650 scsi/host0/bus0/target0/lun0/part2
   8     3    8841042 scsi/host0/bus0/target0/lun0/part3

There, it's difficult to get the short device name of the disk
Is there any other way ? May fdisk be the right choise ?

-- 
 Thomas
----------------------------------------------------------------------
            Thomas Lange
Institut fuer Informatik        mailto:lange@informatik.Uni-Koeln.DE
   Universitaet zu Koeln
            Pohligstr. 1        Telefon: +49 221 470 5303
             50969 Koeln        Fax    : +49 221 470 5317

1024D/AB9B66FD AEA6 A8C1 BD8E 67C4 8EF6  8BCA DC13 E54E AB9B 66FD
----------------------------------------------------------------------



Reply to: