Howto find out or Learn harddisk size in Linux or UNIX

Q. How do I find out or learn hard disk size in Linux?

A. Under Linux and UNIX you can use df command. df command displays the amount of disk space available on the file system containing each file name argument. If no file name is given, the space available on all currently mounted file systems is shown.

Task: Display hard disk partition size

$ df

Output:

Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/hdb1             19228276  14699744   3551784  81% /
tmpfs                   384300         4    384296   1% /dev/shm
/dev/hdb5             27917308  23883184   2615988  91% /data/network

Task: Display hard disk partition size in Mega bytes

$ df -H

Output:

Filesystem             Size   Used  Avail Use% Mounted on
/dev/hdb1               20G    16G   3.7G  81% /
tmpfs                  394M   4.1k   394M   1% /dev/shm
/dev/hdb5               29G    25G   2.7G  91% /data/network

Task: Display TOTAL hard disk size

fdisk command is partition table manipulator for Linux. But it can be use to display total hard disk site. You must type the following command as the root user:

# fdisk -l | grep Disk

Output:

Disk /dev/hda: 20.0 GB, 20060651520 bytes
Disk /dev/hdb: 80.0 GB, 80060424192 bytes
Want to read Linux tips and tricks, but don't have time to check our blog everyday? Subscribe to our daily email newsletter to make sure you don't miss a single tip/tricks. Subscribe to our weekly newsletter here!

{ 3 comments… read them below or add one }

1 Ashish 12.17.08 at 7:33 am

Hello Sir,
Pls verify the other userfull command for me on linux.

2 Andrew 03.24.09 at 4:12 pm

Thanks for the fdisk -l tip! I’ve been wondering how to see total disk size, not just partitions. Now I know!

3 senshikaze 07.01.09 at 2:35 pm

Nice and quick, thanks!

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Tagged as: , , , , , , , , , , , ,

Previous post: How do I use shell aliases under Linux?

Next post: Formatting usb pen in Linux