LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Here is a simple question for you guys (https://www.linuxquestions.org/questions/linux-newbie-8/here-is-a-simple-question-for-you-guys-142263/)

patpawlowski 02-04-2004 01:35 PM

Here is a simple question for you guys
 
How do I check to see how much hard disk space I have left?

jtshaw 02-04-2004 01:37 PM

type df at the command line.

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



All times are GMT -5. The time now is 08:09 AM.