11

How to get available disk space on Unix/Linux OS, including unallocated space (which wasn't assigned to any partitions)?

  • 1
    The other answers being posted here are excellent, so I won't add to them (though I will upvote them!), but I will note that almost any command to look at a raw device (which is what you need to do, to see space not yet made available to the system users) requires privilege. If you don't have root, forget it. – MadHatter Nov 2 '12 at 10:08
  • 1
    And if you're having a problem that you are trying to solve, then you should write about that problem. – Michael Hampton Nov 2 '12 at 11:13
  • My problem is that i don't know how to get available disk space, that's all. – krapstuke Nov 5 '12 at 13:01
20

On Linux the free space can hide in multitude of places:

  1. Free file system space (the most obvious):

    df -h
    
  2. Unpartitioned space:

    for dev in /dev/sd?; do parted "$dev" print; done
    

    or

    for dev in /dev/sd?; do fdisk -l "$dev"; done
    

    and carefully study how much space is between the partitions, and between partitions and end of the device

  3. Free space in LVM system:

    vgs
    

    or

    pvs
    

    physical volume can use less space than the size of partition, so compare its size to partition size

  4. Space unassigned to partition in MD system:

    for dev in /dev/md*; do mdadm --detail "$dev"; done
    

    You'll need to compare the "Used Dev size" with partition size

  5. File systems can be smaller than the volume they're on (thanks @PaulGear!). You should compare the size of LVM Logical Volume, MD RAID device, partition or some other device the file system resides on with the size of file system (as returned by df).

If you have more than one disk or LVM volume group and relatively new distribution, you may use lsblk to show a tree of block devices together with mountpoints.

NOTE: There's also the difference between marketing GB (which is 10^9B) and OS or engineering GB (which is 2^30B and should be written GiB to differentiate between the two). 40GB is around 37.25GiB. All of the above tools except parted use binary gigabytes as default units. Add unit MiB to parted command, before print to get answers in Mebibytes (also useful for aligning partitions on SSDs and 4KiB sector disks).

  • 1
    Note also that there can be space hiding between the cracks, e.g. if you have an LV that's 40 GiB and a file system on it that's only 30 GiB. Make sure you cross-check the answers of df and lvs. – Paul Gear Nov 6 '12 at 21:14
3

It sounds like perhaps the desire is for a tool such as partitionmanager, or gparted.

http://kde-apps.org/content/show.php?content=89595

http://gparted.sourceforge.net/download.php

cfdisk will also show unallocated space on a disk by disk basis:

cfdisk /dev/sda

Specify the appropriate device - sda, sdb, sdc etc.

2

Try:

df -h 

or

fdisk -l *

http://www.unix.com/red-hat/178290-get-unallocated-disk-space.html

Above link have some more description on what you are after

http://www.computerhope.com/unix/udf.htm Hope this helps

  • Yes, but it didn't help. df shows just partitions allocated space. Machine have 5 disks, whose total space is 48 GB. From console i get about ~30Gb total of space. – krapstuke Nov 2 '12 at 10:19
1

You can see the partitions with "df -h". For the rest you can use "parted discname" and then "print".

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.