LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 01-06-2007, 06:51 PM   #1
DataSheet
Member
 
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" ?

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

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

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

Rep: Reputation: 0
in terminal ,df -h
 
Old 01-06-2007, 11:00 PM   #5
sonicbhoc
Member
 
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
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 56
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 drive.pl and make it executable with chmod +x drive.pl
Then, you would run it like this example...
./drive.pl /dev/hda
Code:
#!/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);
         write;
      }
   }
}
$~ = "ENDING";
write;

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
($totalused/1000)
Unpartitioned size @######## MB
(($D4-$totalused)/1000)

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


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
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/Novell 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


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

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration