From cdc625767e891189dafecd42a2e390f81a62c915 Mon Sep 17 00:00:00 2001 From: Evangelos Foutras Date: Sun, 25 Jan 2009 03:59:29 +0200 Subject: [PATCH] Using fdisk instead of hdparm to get disc capacity --- setup | 19 +++++++++++++++---- 1 files changed, 15 insertions(+), 4 deletions(-) diff --git a/setup b/setup index 6d519e9..3f4bd66 100755 --- a/setup +++ b/setup @@ -337,14 +337,25 @@ _umountall() umount $(mount | grep "${DESTDIR} " | sed 's|\ .*||g') >/dev/null 2>&1 } +# _getdisccapacity() +# +# parameters: device file +# outputs: disc capacity in MB +_getdisccapacity() +{ + echo $(($(fdisk -l $1 | sed -n '2p' | cut -d' ' -f5) / 1000000)) +} + # Get a list of available disks for use in the "Available disks" dialogs. This -# will print the disks as follows, getting size info from hdparm: +# will print the disks as follows, getting size info from fdisk: # /dev/sda: 640133 MBytes (640 GB) # /dev/sdb: 640135 MBytes (640 GB) _getavaildisks() { - # NOTE: to test as non-root, stick in a 'sudo' before the hdparm call - for i in $(finddisks); do echo -n "$i: "; hdparm -I $i | grep -F '1000*1000' | sed "s/.*1000:[ \t]*\(.*\)/\1/"; echo "\n"; done + for DISC in $(finddisks); do + DISC_SIZE=$(_getdisccapacity $DISC) + echo "$DISC: $DISC_SIZE MBytes ($((DISC_SIZE / 1000)) GB)" + done } autoprepare() @@ -363,7 +374,7 @@ autoprepare() ROOT_PART_SET="" CHOSEN_FS="" # get just the disk size in 1000*1000 MB - DISC_SIZE=$(hdparm -I $DISC | grep -F '1000*1000' | sed "s/^.*:[ \t]*\([0-9]*\) MBytes.*$/\1/") + DISC_SIZE=$(_getdisccapacity $DISC) while [ "$SET_DEFAULTFS" = "" ]; do FSOPTS="ext2 ext2 ext3 ext3 ext4 ext4" [ "$(which mkreiserfs 2>/dev/null)" ] && FSOPTS="$FSOPTS reiserfs Reiser3" -- 1.6.1