How to get available disk space on Unix/Linux OS, including unallocated space (which wasn't assigned to any partitions)?
On Linux the free space can hide in multitude of places:
Free file system space (the most obvious):
for dev in /dev/sd?; do parted "$dev" print; done
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
Free space in LVM system:
physical volume can use less space than the size of partition, so compare its size to partition size
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
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
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
It sounds like perhaps the desire is for a tool such as partitionmanager, or gparted.
cfdisk will also show unallocated space on a disk by disk basis:
Specify the appropriate device - sda, sdb, sdc etc.
fdisk -l *
Above link have some more description on what you are after
http://www.computerhope.com/unix/udf.htm Hope this helps