Last change
on this file since 3125 was 196, checked in by bcornec, 19 years ago |
Usage of parted2fdisk instead of fdisk everywhere.
on ia64 this is mandatory, and simplifies the infrastructure
on other archs, it doesn't change anything as parted2fdisk here is a link to fdisk
|
-
Property svn:keywords
set to
Id
|
File size:
1.3 KB
|
Rev | Line | |
---|
[1] | 1 | #!/bin/sh
|
---|
| 2 |
|
---|
| 3 | # patched by Doug Nordwall, June 28th 2000, to fix a SCSI disk size
|
---|
| 4 | # calculation bug; nice one, Doug! :-) - HR
|
---|
| 5 |
|
---|
| 6 | CalcDiskSize() {
|
---|
| 7 | local res cylinders sectorsize disksize i curr stub out
|
---|
[196] | 8 | res=`parted2fdisk -l $1 2> /dev/null | grep -i "cylinders of"`
|
---|
[1] | 9 | cylinders=`echo "$res" | cut -d' ' -f5`
|
---|
| 10 | sectorsize=`echo "$res" | cut -d' ' -f7`
|
---|
[196] | 11 | cylindermod=`parted2fdisk -l $1 2> /dev/null | grep -i $1:`; # note colon at end to make sure it's not the /dev/sda# partition info
|
---|
[1] | 12 | cylnum=`echo "$cylindermod" | cut -d' ' -f7`
|
---|
| 13 | predisksize=$(($cylinders*$sectorsize/1024))
|
---|
| 14 | disksize=$(($predisksize*$cylnum/1024)); # this works on larger drives; I imagine it'll work on smaller drives with fewer cylinders...
|
---|
| 15 |
|
---|
| 16 | #echo "cylinders = $cylinders; sectorsize = $sectorsize"
|
---|
| 17 | #echo "cylnum = $cylnum"
|
---|
| 18 | #echo "predisksize = $predisksize; disksize = $disksize"
|
---|
| 19 |
|
---|
| 20 | if [ "$disksize" = "" ] ; then
|
---|
| 21 | return 1
|
---|
| 22 | else
|
---|
| 23 | echo "$disksize"
|
---|
| 24 | return 0
|
---|
| 25 | fi
|
---|
| 26 | }
|
---|
| 27 |
|
---|
| 28 | # ---------------- main ---------------
|
---|
| 29 |
|
---|
| 30 | if [ "$#" -ne "1" ] || [ "`echo "$1" |grep -x "/dev/[a-z]*"`" = "" ]; then
|
---|
| 31 | LogIt "calc-disk-size <device>" 1
|
---|
| 32 | exit 1
|
---|
| 33 | fi
|
---|
| 34 |
|
---|
| 35 | LogIt "calc-disk-size --- starting"
|
---|
| 36 | out=`CalcDiskSize $1`
|
---|
| 37 | if [ "$out" = "" ] ; then
|
---|
| 38 | echo "-1"
|
---|
| 39 | else
|
---|
| 40 | echo "$out"
|
---|
| 41 | fi
|
---|
| 42 |
|
---|
| 43 | LogIt "calc-disk-size --- leaving"
|
---|
| 44 |
|
---|
| 45 | exit
|
---|
| 46 |
|
---|
| 47 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.