Solved

Linux Free Space

Posted on 2011-03-09
16
1,012 Views
Last Modified: 2012-06-27
hi,

how to find out the free space in a linux system. i have a server where i know that there are free spaces available but df -kh and fdisk -l doent diaply exactly the free space info

how to find out the exact free space info
0
Comment
Question by:kurajesh
  • 7
  • 6
  • 2
  • +1
16 Comments
 
LVL 40

Expert Comment

by:omarfarid
ID: 35080604
df -kh will show the filesystems that are created and mounted.

fdisk should show you the partitions created on the disk but the free disk space (not partitioned) I think needs to be calculated
0
 
LVL 3

Expert Comment

by:Abhishek_Chib
ID: 35080620
Hi,

You can use following commands :

# df -h ( in MB and GB )
# df -ig ( For inode )

Once you find the partition, use "du -sh" to find the size of folder and files

Secondly, if you are trying to that you HDD is 100 GB and showing somewhere around 96GB, do not worry, 4GB used by Linux OS that we call it "File System Area"

 
0
 
LVL 1

Author Comment

by:kurajesh
ID: 35080651

i did try with df -h and the result is same as df -kh whereas i had kept additional space while buidling the server.

0
 
LVL 3

Expert Comment

by:Abhishek_Chib
ID: 35080657
Note: Correct command for inode # df -i  
0
 
LVL 3

Expert Comment

by:Abhishek_Chib
ID: 35080683
kurajesh, can you share you exact details, what you are trying to do ?

From you initial comments, it seem that you not able to see disk space.
0
 
LVL 1

Author Comment

by:kurajesh
ID: 35080704

i meant that total hdds' space is 1.2tb outof which 100gb i have not made a separate parition. rest 1.1tb has been paritioned and properly mounted. now when i df -kh i can see all 1.1tb perfectly but the 100gb is not showing in the table

0
 
LVL 3

Expert Comment

by:Abhishek_Chib
ID: 35080851
its little bit tricky, us command fdisk command

# fdisk /dev/XXXX ( XXXX will be you HDD name )
# Press p ( for partition table )

You will see some values like :


Disk /dev/sda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x0006cd01

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          26      204800   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              26        9729   77943361   8e  Linux LVM

Check how may cylinders left and multiple by 512 ( treat as a example )


0
 
LVL 1

Author Comment

by:kurajesh
ID: 35081440
i just checked the table and output is as follows:


[root@localhost ~]# fdisk /dev/cciss/c0d0

The number of cylinders for this disk is set to 71380.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): p

Disk /dev/cciss/c0d0: 587.1 GB, 587128266752 bytes
255 heads, 63 sectors/track, 71380 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

           Device Boot      Start         End      Blocks   Id  System
/dev/cciss/c0d0p1   *           1         255     2048256   83  Linux
/dev/cciss/c0d0p2             256       25751   204796620   83  Linux
/dev/cciss/c0d0p3           25752       41049   122881185   83  Linux
/dev/cciss/c0d0p4           41050       71380   243633757+   5  Extended
/dev/cciss/c0d0p5           41050       53797   102398278+  83  Linux
/dev/cciss/c0d0p6           53798       60171    51199123+  83  Linux
/dev/cciss/c0d0p7           60172       61701    12289693+  82  Linux swap
/dev/cciss/c0d0p8           61702       62976    10241406   83  Linux

Command (m for help): q

[root@localhost ~]# fdisk /dev/cciss/c0d1

The number of cylinders for this disk is set to 72937.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): p

Disk /dev/cciss/c0d1: 599.9 GB, 599932581888 bytes
255 heads, 63 sectors/track, 72937 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

           Device Boot      Start         End      Blocks   Id  System
/dev/cciss/c0d1p1   *           1       25496   204796588+  83  Linux
/dev/cciss/c0d1p2           25497       50992   204796620   83  Linux
/dev/cciss/c0d1p3           50993       63740   102398310   83  Linux

Command (m for help): q

[root@localhost ~]#


from the above how can i find that unassigned space
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 3

Accepted Solution

by:
Abhishek_Chib earned 333 total points
ID: 35081527
See the BOLD area

++++++++++++++++++++++++++++++++++++++++++++++++++++++
Disk /dev/cciss/c0d1: 599.9 GB, 599932581888 bytes
255 heads, 63 sectors/track, 72937 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

           Device Boot      Start         End      Blocks   Id  System
/dev/cciss/c0d1p1   *           1       25496   204796588+  83  Linux
/dev/cciss/c0d1p2           25497       50992   204796620   83  Linux
/dev/cciss/c0d1p3           50993       63740   102398310   83  Linux

++++++++++++++++++++++++++

Diff cylinders = 72937 - 63740 = 9197 ( That is your free space )


0
 
LVL 1

Author Comment

by:kurajesh
ID: 35081590
thanks abhishek,
now it is clear, how we can allocate this 9197 + 8100 (170gb) into a new single partition as they are from c0d0 and c0d1

0
 
LVL 12

Expert Comment

by:upanwar
ID: 35086404
For using space from two different disks to one partition you have to use LVM for the same.

If you have need any help to create that you can ask us and also add the output of df -Th command in you require help to configure LVM.
0
 
LVL 1

Author Comment

by:kurajesh
ID: 35098219
I would prefer to configure lvm and can you let me know how can I got qbout this. Also how can I configure a script to have complete file system backup.
0
 
LVL 3

Assisted Solution

by:Abhishek_Chib
Abhishek_Chib earned 333 total points
ID: 35103683
Hi,

Follow link for LVM :

http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:_Ch27_:_Expanding_Disk_Capacity

And for filesystem backup use some professional backup service or tool in your case.

Note : Data is huge

0
 
LVL 12

Assisted Solution

by:upanwar
upanwar earned 167 total points
ID: 35104695

For using space from two different disks to one partition you have to use LVM for the same.

# fdisk /dev/cciss/c0d0

At the Linux fdisk command prompt,

1. press n to create a new disk partition,
2. press e to create an extended disk partition,
3. press ENTER twice to accept the default of 1st and last cylinder – to convert the rest disk space to a single disk partition,
4. press t  to change the default Linux partition type (0×83) to LVM partition type (0x8e),
5. press L to list all the currently supported partition type,
6. press 8e (as per the L listing) to change partition to 8e, i.e. Linux LVM partition type,
7. press p to display the hard disk partition setup. Please take note that the new partition is denoted as /dev/cciss/c0d0p9 in Linux,
8. press w to write the partition table and exit fdisk upon completion.


Then repeat the same task for another disk.

# fdisk /dev/cciss/c0d1

At the Linux fdisk command prompt,

1. press n to create a new disk partition,
2. press e to create an extended disk partition,
3. press ENTER twice to accept the default of 1st and last cylinder – to convert the rest disk space to a single disk partition,
4. press t  to change the default Linux partition type (0×83) to LVM partition type (0x8e),
5. press L to list all the currently supported partition type,
6. press 8e (as per the L listing) to change partition to 8e, i.e. Linux LVM partition type,
7. press p to display the hard disk partition setup. Please take note that the new partition is denoted as /dev/cciss/c0d1p4 in Linux,
8. press w to write the partition table and exit fdisk upon completion.


Then create a LVM physical volume (PV).

# pvcreate /dev/cciss/c0d0p9 /dev/cciss/c0d1p4

Now create a LVM volume group (VG) called vg01 with a physical extent size (PE size) of 16MB (Default PE size is 4 MB)

# vgcreate -s 16M vg01 /dev/cciss/c0d0p9 /dev/cciss/c0d1p4

Now execute the below given command to check size of vg01

# vgdisplay vg01

Here note down the value of Free  PE / Size and the Create a logical volume (LV) called lvol01 on volume group vg01:

# lvcreate -L <the free size which you have noted in GB>G -n lvol01 vg01

The Linux LVM setup is almost done. Now is the time to format logical volume lvol01 to create a Red Hat Linux supported file system. I am using example for ext3. You can format with the filesystem which you want to use.

mkfs -t ext3 /dev/vg01/lvol01

Create a mount point where you want to mount your newly created Filesystem:

mkdir /Path/to/mount

mount the new EXT3 file system created on logical volume lvol01 of LVM to mount point:

mount -t ext3 /dev/vg01/lvol01 /Path/to/mount


To confirm the LVM setup has been completed successfully, the df -h command should display the below given filesystem with size and mount point:

/dev/mapper/vg01-lvol01


I think its enough to configure your LVM.
0
 
LVL 1

Author Comment

by:kurajesh
ID: 35122112
i will certainly try this lvm and update quickly, thanks a lot
0
 
LVL 1

Author Closing Comment

by:kurajesh
ID: 35414988
the lvm details were useful, completed the setup, thanks a lot abhishek & upanwar
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

Suggested Solutions

Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now