LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-15-2005, 07:55 PM   #1
hansi umayangan
Member
 
Registered: Aug 2004
Distribution: AS3
Posts: 81

Rep: Reputation: 15
Un partition Disk Space


In win 2000 disk management utility help us identify the unpartitioned disk space in a HDD drive .In Linux how can I identify the unpartitioned disk space in HDD drive?
 
Old 03-15-2005, 08:10 PM   #2
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
One way to see Un partitioned space would be as root user to run this script I made.
For example: ./drive /dev/hda

Code:
#!/bin/bash
##### This script calculates hard drive space.
##### example:  ./drive /dev/hda

##############################################
#  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
##############################################

usage()
{
        echo "Usage: $0 /dev/hd#"
        exit 1;
}

test "$1" || usage

if ! [ -e $1 ]; then
    echo "$1 does not exist. Exiting."
    exit 1
fi

if [ -e $1 ]; then

drive=`/sbin/sfdisk -s $1`
echo
for i in `/sbin/sfdisk -l $1 | \
grep -e "^[/dev]" | awk '{print $1}'`;
do
a=`/sbin/sfdisk -s $i 2> /dev/null`
part=$((($a + 0) / 1024))
totalused=$(($totalused + ($a + 0)))
echo "Partition $i used $part MB"
done
echo

else
    exit 1
fi

#####
size=$(($drive / 1024))
used=$(($totalused / 1024))
free=$((($drive - $totalused) / 1024 +1))
#
echo " Total drive size    $size   MB"
echo " Partitioned size    $used   MB"
echo " Unpartitioned size  $free   MB"
echo
echo
#####End
 
Old 03-15-2005, 10:41 PM   #3
J.W.
LQ Veteran
 
Registered: Mar 2003
Location: Boise, ID
Distribution: Mint
Posts: 6,642

Rep: Reputation: 87
And if you are interested in seeing how much of your partitioned space is being used, there's always the very useful
Code:
df -h
-- J.W.
 
Old 03-15-2005, 11:54 PM   #4
ccool
Member
 
Registered: Oct 2002
Location: Canada
Distribution: Slackware 10.1
Posts: 71

Rep: Reputation: 15
If df -h is not enough, there is always cfdisk its a great/powerfull utility

cfdisk
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Disk space used after initial partition is created Wraezor Linux - General 2 04-21-2005 10:01 AM
3Gb of disk space lost! Disk space problem or mother board conflicts with HDD Mistreated Linux - Hardware 4 12-06-2004 03:58 PM
Resize ReiserFS partition to use rest of disk space fivezerosixzero Linux - General 1 10-31-2004 01:43 PM
easiest way to know how much disk space is left on partition el jue Linux - Newbie 2 04-07-2004 09:19 PM
max disk space for a linux partition blas Linux - General 5 04-04-2003 08:01 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:52 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
Open Source Consulting | Domain Registration