LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to find how much free space left on my hard disk? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-find-how-much-free-space-left-on-my-hard-disk-516994/)

DataSheet 01-06-2007 05:51 PM

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

Tuttle 01-06-2007 05:53 PM

cfdisk
parted
gparted (gui for parted)

Simon Bridge 01-06-2007 05:54 PM

In terminal
Code:

fdisk -l
(man fdisk)

nigaocuomei 01-06-2007 09:46 PM

in terminal ,df -h

sonicbhoc 01-06-2007 10:00 PM

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.

homey 01-06-2007 10:35 PM

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!



All times are GMT -5. The time now is 04:39 PM.