Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 01-06-2007, 06:51 PM   #1
Registered: Apr 2006
Posts: 36

Rep: Reputation: 15
Question How to find how much free space left on my hard disk?

When I installed Red Hat Linux on my 19GB hard disk, I left 7868MB free (1432-2434) free.

Now how can I find out this information that I have left 7868MB? this is what I know and I wrote it down on piece of paper but is there any command to find out how much space I have left on my hard disk which is "raw" or "un-allocated" or "unpartitioned" ?

Data Sheet
Old 01-06-2007, 06:53 PM   #2
Senior Member
Registered: Jul 2003
Location: Wellington, NZ
Distribution: mainly slackware
Posts: 1,291

Rep: Reputation: 52
gparted (gui for parted)
Old 01-06-2007, 06:54 PM   #3
Simon Bridge
LQ Guru
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 198Reputation: 198
In terminal
fdisk -l
(man fdisk)
Old 01-06-2007, 10:46 PM   #4
LQ Newbie
Registered: Nov 2006
Posts: 16

Rep: Reputation: 0
in terminal ,df -h
Old 01-06-2007, 11:00 PM   #5
Registered: Aug 2006
Distribution: Gentoo
Posts: 61

Rep: Reputation: 15
df -h... dang, beat to it!

If you use KDE, there's also kdiskfree and kdf but I don't know how well those work. I also don't know if I just said the same program twice - I don't use the GUI for these kinds of things.

cfdisk is better than all of those though.
Old 01-06-2007, 11:35 PM   #6
Senior Member
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 60
The tools df -h , kdiskfree and kdf all see to assume you only want info for one drive. Also, cfdisk isn't installed by default for Redhat / Fedora.
So, I made a little diddy to calculate unpartitioned space for a drive which you choose.

Just put this in a file like and make it executable with chmod +x
Then, you would run it like this example...
./ /dev/hda
#!/usr/bin/perl -w
##### This script calculates hard drive space.
##### example:  ./drive /dev/hda

if($#ARGV != 0){
     die "Example: $0 /dev/sda \n";
if(!-e $ARGV[0]){
   die "$ARGV[0] is not a valid device. Exiting.\n";

my $DRIVE = $ARGV[0];
print "\n";

open(INFILE, "/proc/partitions") || die "Can't open file for read: $!";
while (<INFILE>){

$DRIVE =~ s/\/\w+\///g;

if ($_ =~ /($DRIVE$)/){
   ($D1, $D2, $D3, $D4, $D5) = split /\s+/;

} elsif ($_ =~ /($DRIVE[0-9])/){
   ($var1, $var2, $var3, $var4, $var5) = split /\s+/;
      if ($var4 == 1){
         print "Partition /dev/$var5   --- Extended ---\n";
      else {
         $totalused = ($totalused += $var4);
$~ = "ENDING";

format STDOUT =
Partition /dev/@<<<< used @######## MB
$var5, ($var4/1000),  $var1,$var2,$var3

format ENDING =

Total drive size   @######## MB
($D4/1000),  $D1,$D2,$D3,$D5
Partitioned size   @######## MB
Unpartitioned size @######## MB

####Just so you don't bork that last dot!


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
No space left on disk rtaft Linux - Software 5 12-27-2006 01:28 PM
Finding Used / Free Space for the Entire Hard Disk Jayaraghavendran Programming 1 03-03-2006 06:33 AM
Is there a way to find out where did all the hard disk space go? yinglcs Linux - General 4 02-28-2006 08:13 AM
Not enough free space on hard drive with 50g of free space??? auoq SUSE / openSUSE 5 10-13-2004 09:21 PM
How much free space left on a tape? bfloeagle Linux - General 0 08-07-2001 08:55 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:48 AM.

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