LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-04-2004, 01:35 PM   #1
patpawlowski
Member
 
Registered: Mar 2003
Location: Centreville, Virginia
Distribution: Mandrak, Red Hat
Posts: 163

Rep: Reputation: 30
Here is a simple question for you guys


How do I check to see how much hard disk space I have left?
 
Old 02-04-2004, 01:37 PM   #2
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 67
type df at the command line.
 
Old 02-04-2004, 01:50 PM   #3
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 59
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
im almost there guys! ....but, yet another question??? matthewa Linux From Scratch 4 06-04-2005 02:04 AM
ok guys, im getting there..another question? matthewa Linux From Scratch 2 06-03-2005 06:32 PM
question guys for those gurus golpemortal Linux - Wireless Networking 0 04-20-2005 11:52 PM
Guys ...PHP QUESTION maseby Programming 5 05-25-2004 03:17 PM
hey, guys simple question notslim Linux - Newbie 3 08-05-2003 08:35 PM


All times are GMT -5. The time now is 10:23 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration