[PC-BSD Commits] r6511 - pcbsd/trunk/pc-sysinstall/backend-query

svn at pcbsd.org svn at pcbsd.org
Tue Apr 6 07:46:50 PDT 2010


Author: kris
Date: 2010-04-06 07:46:50 -0700 (Tue, 06 Apr 2010)
New Revision: 6511

Modified:
   pcbsd/trunk/pc-sysinstall/backend-query/disk-part.sh
Log:

Updated backend script for getting free space, use gpart check first, fdisk may
return bogus info when no real slices exist



Modified: pcbsd/trunk/pc-sysinstall/backend-query/disk-part.sh
===================================================================
--- pcbsd/trunk/pc-sysinstall/backend-query/disk-part.sh	2010-04-06 14:45:40 UTC (rev 6510)
+++ pcbsd/trunk/pc-sysinstall/backend-query/disk-part.sh	2010-04-06 14:46:50 UTC (rev 6511)
@@ -16,8 +16,22 @@
   exit 1
 fi
 
+# Now get the disks size in MB
+KB="`diskinfo -v ${1} | grep 'bytes' | cut -d '#' -f 1 | tr -s '\t' ' ' | tr -d ' '`"
+convert_byte_to_megabyte ${KB}
+TOTALSIZE="$MB"
+TOTALB="`diskinfo -v ${1} | grep 'in sectors' | tr -s '\t' ' ' | cut -d ' ' -f 2`"
+
+
+gpart show ${1} >/dev/null 2>/dev/null
+if [ "$?" != "0" ] ; then
+  # No partitions on this disk, display entire disk size and exit
+  echo "${1}-freemb: ${TOTALSIZE}"
+  echo "${1}-freeblocks: ${TOTALB}"
+  exit
+fi
+
 fdisk ${1} >${TMPDIR}/disk-${1} 2>/dev/null
-
 # Don't display partitions on EFI GPT disks, need to re-format entire disk on them
 cat ${TMPDIR}/disk-${1} | grep "GPT" >/dev/null 2>/dev/null
 if [ "$?" = "0" ] ; then
@@ -76,7 +90,6 @@
 
 # Now calculate any free space
 LASTB="`expr $SIZEB + $START`"
-TOTALB="`diskinfo -v ${1} | grep 'in sectors' | tr -s '\t' ' ' | cut -d ' ' -f 2`"
 FREEB="`expr $TOTALB - $LASTB`"
 FREEMB="`expr ${FREEB} / 2048`"
 echo "${1}-freemb: $FREEMB"



More information about the Commits mailing list