summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Hemminger <shemminger@vyatta.com>2012-01-03 11:04:26 -0800
committerStephen Hemminger <shemminger@vyatta.com>2012-01-03 11:04:26 -0800
commit42c61e632a88446a425bf2e2f0ce3e0430e2f4bf (patch)
tree6003307028adfe7d574c89806824cd3de62e71b0
parent11b7290a75eefa9da5c08a25e3c17723be6a4e90 (diff)
downloadvyatta-cfg-system-42c61e632a88446a425bf2e2f0ce3e0430e2f4bf.tar.gz
vyatta-cfg-system-42c61e632a88446a425bf2e2f0ce3e0430e2f4bf.zip
install-system: use sfdisk to find drive size
Better than using parted which requires more parsing.
-rwxr-xr-xscripts/install-system39
1 files changed, 6 insertions, 33 deletions
diff --git a/scripts/install-system b/scripts/install-system
index 63a5d3d5..536233d7 100755
--- a/scripts/install-system
+++ b/scripts/install-system
@@ -143,45 +143,18 @@ get_response () {
# Return the size of the drive in MB
get_drive_size () {
- ldrive=$1
-
- # Make sure you can print disk info using parted
- parted --script /dev/$ldrive print >/dev/null 2>&1
+ local ldrive=$1
- # If unable to read disk, it's likely it needs a disklabel
- if [ "$?" != "0" ]; then
- echo "Creating a new disklabel on $ldrive" >> $INSTALL_LOG
- echo "parted /dev/$ldrive mklabel msdos" >> $INSTALL_LOG
- output=$(parted -s /dev/$ldrive mklabel msdos)
+ # Get size of disk in 1k blocks
+ local blocks=$(sfdisk -s /dev/$ldrive)
- # Get the drive size from parted
- lsize=$(parted -s /dev/$ldrive p | grep "^Disk" | awk '{ print $3 }')
-
- if [ $(echo $lsize | grep error) ]; then
- echo "Unable to read disk label. Exiting."
- exit 1
- fi
- fi
-
- # Get the drive size from parted
- lsize=$(parted -s /dev/$ldrive p | grep "^Disk" | awk '{ print $3 }')
- # Get the reported units (mB, GB, kB)
- lmodifier=$(echo $lsize | sed 's/[0-9\.]//g')
- # remove the modifier
- lsize=$(echo $lsize | sed 's/[a-z,A-Z]//g')
- # Remove any fractions
- lsize=$(echo $lsize | cut -f1 -d'.')
- # Translate our size into mB if not there already
- if [ $lmodifier = "GB" ]; then
- lsize=$(($lsize * 1000))
- elif [ $lmodifier = "kB" ]; then
- lsize=$(($lsize / 1000))
- fi
+ # Translate to Megabytes (SI units)
+ local bytes=$(($blocks * 1024))
+ local lsize=$(($bytes / 1000000))
echo $lsize
}
-
# Probe hardrives not shown in /proc/partitions by default
probe_drives () {
# Find drives that may not be in /proc/partitions since not mounted