Signed-off-by: Evangelos Foutras <foutrelis@gmail.com> --- setup | 21 ++++++++++++++++----- 1 files changed, 16 insertions(+), 5 deletions(-) diff --git a/setup b/setup index 6e6ba4a..6f119c6 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 bytes +_getdisccapacity() +{ + fdisk -l $1 | sed -n '2p' | cut -d' ' -f5 +} + # 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 _getdisccapacity(): # /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 / 10**6)) MBytes ($((DISC_SIZE / 10**9)) GB)\n" + done } autoprepare() @@ -362,8 +373,8 @@ autoprepare() SWAP_PART_SET="" 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/") + # disk size in MB + DISC_SIZE=$(($(_getdisccapacity $DISC) / 10**6)) while [ "$SET_DEFAULTFS" = "" ]; do FSOPTS="ext2 ext2 ext3 ext3 ext4 ext4" [ "$(which mkreiserfs 2>/dev/null)" ] && FSOPTS="$FSOPTS reiserfs Reiser3" -- 1.6.1.1