[SOLVED] Command to list the amount of unused space on a physical disk.
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Command to list the amount of unused space on a physical disk.
Hi,
Im new to Ubuntu or Linux and i'm looking for away to check the hard disk free space. I know about df -h, but that only shows me free space inside mounted partitions. I want to see unused disks space on the physical hard drive like /dev/sda not /dev/sda1
Getting this information in fdisk is hard because its only shows the blocks that are used.
Example
If i a 500GB Disk and i create 1 partition that's 100GB in size, which command would i run so i can see the 400GB that are unused on the disk?
I'm a Windows SysAdmin that's trying to convert so please dont hate me.
You can use fdisk and use the p command to view all partitions, that also shows the size of the drive. Just be careful you don't write to your partition table and screw up your drive.
Code:
sudo fdisk /dev/sda
Command (m for help): p
Disk /dev/sda: 640.1 GB, 640135028736 bytes
255 heads, 63 sectors/track, 77825 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x1549f232
<more info - deleted>
Command (m for help): q
Using df, you are correct in that (1) you will only see partitions which are mounted, and further (2) you will only see partitions which exist. For instance, if you have un-partitioned space on that drive, you will not know about it. Therefore using df and doing the math is not going to always get you the answer. However using fdisk is not recommended to be an everyday thing.
For remaining unallocated you do have to do a bit of arithmetic: 1953514584 blocks for sdb, 976757260 sdb1, 976757292 sdb2. So sdb1 + sdb2 = 1953514552, difference: 32 blocks unallocated. In this particular case it is to force alignment.
In the case of sda4, it is the "extended" partition header... and that is all it is.
But like OP, i'm also looking for a commandline tool, which display HDDs total/used/free disk size regardless of type of filesystem/regular/lvm/alloted/not alloted partitions. Believe me, from past 2-3 months, whenever i am free, i'm hunting for it in internet. still cant find it. All i find is floods of tutorials on 'df' and 'du' in some or other type of script/sed/awk. nothing else. which are by the way are not accurate.
For example, i have three disks, 40GB, 250GB and 1TB.
40GB - Windows 8 (NTFS)
250GB - Backup (NTFS)
1TB -
/boot
/dc (backup ext4)
LVM ( /, /home, /var, /docus, /kumar and swap)
It makes even more difficult that, in those LVM, some space(LVs) are alloted to volume group, some(LVs) are encrypted, some space is still not alloted to volume group. those space that is not still alloted and are encrypted are not shown in df.
@mddesai
not sure you have the same issue here,
orenzp was after unallocated space ( syg00's option being the best in my opinion )
you seem concerned with the space you have on filesystems
this might work better for you
Code:
df -h --total /home /var /dc /mnt/*/
as for the unallocated to vg, use what ever you are using to manage them to, well manage them.
and the encrypted stuff.. what encryption are you using?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.