homey |
02-04-2004 01:50 PM |
Just in case you meant to find out how much unpartitioned space you have on a drive, I happen to have a script which you could use.
Copy the code into a text file in your home directory with no extension. For example drive
Then get to the directory where the script is located and become root with the su - command.
Now run the script with the command: sh drive
Code:
#!/bin/bash
#
# This script calculates hard drive space.
###
# Ensure that root is running the script.
#
WHOAMI=`/usr/bin/whoami`
if [ $WHOAMI != "root" ]; then
echo
echo "You must be root to run this!"
echo
exit 1
fi
#
####
echo
echo ""
echo "Enter drive letter: "
read letter
echo
echo
drive=`/sbin/sfdisk -s /dev/hd$letter`
####
if [ $letter = "a" ]; then
a=`/sbin/sfdisk -s /dev/hda1`
b=`/sbin/sfdisk -s /dev/hda2`
c=`/sbin/sfdisk -s /dev/hda3`
d=`/sbin/sfdisk -s /dev/hda4`
elif [ $letter = "b" ]; then
a=`/sbin/sfdisk -s /dev/hdb1`
b=`/sbin/sfdisk -s /dev/hdb2`
c=`/sbin/sfdisk -s /dev/hdb3`
d=`/sbin/sfdisk -s /dev/hdb4`
else
clear
echo "$letter is not a valid drive letter: "
echo
exit 1
fi
####
size=$(($drive / 1024 ))
used=$((($a + $b + $c + $d ) / 1024 ))
free=$(($size - $used ))
#
echo " Total drive size $size MB"
echo " Partitioned size $used MB"
echo " Unpartitioned size $free MB"
echo
echo
#####
#End
|