From 8bec371c9fbc6bb8c7d1efed8a8538ea2c842a3d Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sat, 14 Feb 2009 14:14:18 +0100 Subject: slightly better way to get disk size with fdisk --- src/core/libs/lib-blockdevices-filesystems.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/core/libs/lib-blockdevices-filesystems.sh b/src/core/libs/lib-blockdevices-filesystems.sh index 29ae2ab..3b43541 100644 --- a/src/core/libs/lib-blockdevices-filesystems.sh +++ b/src/core/libs/lib-blockdevices-filesystems.sh @@ -739,6 +739,8 @@ get_filesystem_program () # $2 standard SI for 1000*n, IEC for 1024*n (optional. defaults to SI) # --> Note that if you do SI on a partition, you get the size of the entire disk, so for now you need IEC for single partitions # output will be in $BLOCKDEVICE_SIZE in MB/MiB +# WARNING: hdparm works - by design - only for ide/sata. not scsi et al +# TODO: clean up all disk size related stuff. see http://bugs.archlinux.org/task/12949 get_blockdevice_size () { [ -b "$1" ] || die_error "get_blockdevice_size needs a blockdevice as \$1 ($1 given)" @@ -749,8 +751,9 @@ get_blockdevice_size () BLOCKDEVICE_SIZE=$(hdparm -I $1 | grep -F '1000*1000' | sed "s/^.*:[ \t]*\([0-9]*\) MBytes.*$/\1/") elif [ "$standard" = IEC ] then - blocks=`fdisk -s $1` || show_warning "Fdisk problem" "Something failed when trying to do fdisk -s $1" - #NOTE: on some interwebs they say 1 block = 512B, on other internets they say 1 block = 1kiB. 1kiB seems to work for me. don't sue me if it doesn't for you - BLOCKDEVICE_SIZE=$(($blocks/1024)) + #NOTE: unreliable method: on some interwebs they say 1 block = 512B, on other internets they say 1 block = 1kiB. 1kiB seems to work for me. don't sue me if it doesn't for you + #blocks=`fdisk -s $1` || show_warning "Fdisk problem" "Something failed when trying to do fdisk -s $1" + #BLOCKDEVICE_SIZE=$(($blocks/1024)) + BLOCKDEVICE_SIZE=$((`fdisk -l $1 | sed -n '2p' | cut -d' ' -f5`/1024)) fi } -- cgit v1.2.3-54-g00ecf