Howto Find Out or Learn Harddisk Size in Linux or UNIX

How do I find out my installed hard disk size in Linux or UNIX like operating systems?

Under Linux and UNIX operating systems you can use the df command. The 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

Open a command-line terminal (select Applications > Accessories > Terminal), and then type:
$ df
Sample outputs:

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 or GB or TB

Type the following command:
$ df -H
Sample outputs:

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

The fdisk command is partition table manipulator for Linux. But it can be used to display total hard disk size. You must type the following command as the root user:
# fdisk -l | grep Disk
Sample outputs:

Disk /dev/hda: 20.0 GB, 20060651520 bytes
Disk /dev/hdb: 80.0 GB, 80060424192 bytes

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 24 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf duf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Modern utilitiesbat exa
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg glances gtop jobs killall kill pidof pstree pwdx time vtop
Searchingag grep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
24 comments… add one
  • Ashish Dec 17, 2008 @ 7:33

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

  • Andrew Mar 24, 2009 @ 16:12

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

  • senshikaze Jul 1, 2009 @ 14:35

    Nice and quick, thanks!

  • Louwrentius Aug 18, 2009 @ 21:25

    The following command is an improvement of the Fdisk -l command, which is actually exactly what most people are looking for:

    Bunny:~# fdisk -l 2> /dev/null | grep Disk | grep -v identifier
    Disk /dev/sda: 60.0 GB, 60011642880 bytes
    Disk /dev/sdb: 60.0 GB, 60011642880 bytes
    Disk /dev/sdc: 1000.2 GB, 1000204886016 bytes
    Disk /dev/sdd: 1000.2 GB, 1000204886016 bytes
    Disk /dev/sdv: 1000.1 GB, 1000123400192 bytes
    Disk /dev/md5: 18002.2 GB, 18002220023808 bytes

  • Elie Oct 8, 2009 @ 13:20

    hi plz how put a hard disck in a server and mirror i want the comment

  • barth Oct 4, 2010 @ 21:38

    > fdisk -l | egrep ‘Disk.*bytes’ | awk ‘{ sub(/,/,””); sum +=$3; print $2″ “$3” “$4 } END { print “—————–“; print “total: ” sum ” GB”}’

    and you will get something simillar to it:
    /dev/sda: 80.0 GB
    /dev/sdb: 120.0 GB
    /dev/sdc: 2000.4 GB
    /dev/sdd: 250.1 GB
    /dev/sde: 250.1 GB
    total: 2700.6 GB

    • Gaurav Gaur Feb 17, 2017 @ 16:52

      Though above logic is good, but not foolproof.
      If $4 units are different then sum+=$3 will yield wrong result.

  • kamran Mar 9, 2011 @ 17:05

    sir df is only work for mounted filesystem. and fdisk does’nt show any free space of the whole disk

  • bazooka May 18, 2011 @ 2:51

    why people need to show off with the linux command?

    fdisk -l | egrep 'Disk.*bytes' | awk '{ sub(/,/,""); sum +=$3; print $2" "$3" "$4 } END { print "—————–"; print "total: " sum " GB"}'

    wut the heck..why dont you type a little bit more until it becomes some great bash romance..i think this website has explain pretty well..or maybe u can check this link

  • sandeep Jan 3, 2012 @ 6:21

    nice and helpful…

  • kamal Mar 28, 2012 @ 14:01

    Thanks a lot
    It’s very usefull for me.

    I have one question…
    below mentioned command will work on AIX, FreeBSD, HPUX, IRIX,Mac OS X, NetBSD, OpenBSD,OpenVMS, POWER HMC, IBM Hardware Management Consoles ,Solaris, Tru64,UnixWare, SCO OpenServer and SCO UNIX VMware ESX VMware ESXi …………???

    fdisk -l | egrep ‘Disk.*bytes’ | awk ‘{ sub(/,/,””); sum +=$3; print $2″ “$3” “$4 } END { print “—————–”; print “total: ” sum ” GB”}’

    fdisk -l |grep Disk

  • Patrick Jul 4, 2012 @ 7:09

    Thanks ….it worked like a charm

  • indra Sep 10, 2012 @ 9:43

    thank u very much, great tips !!

  • shital Sep 19, 2012 @ 7:37

    is there a command that shows only used hard disk size??

  • gokul krishna Feb 14, 2013 @ 6:19

    thanks it really helped me

  • sdfasdfsdf Feb 25, 2013 @ 13:30

    dmesg | grep GiB

  • fser May 27, 2013 @ 16:06

    If using lvm, you can use pvdisplay

     # pvdisplay 
      --- Physical volume ---
      PV Name               /dev/md2
      VG Name               alternc
      PV Size               1,79 TiB / not usable 768,00 KiB
      Allocatable           yes 
      PE Size               4,00 MiB
      Total PE              468340
      Free PE               33652
      Allocated PE          434688
      PV UUID               DBE80K-p3VS-kdtX-e1eJ-Fqbt-diSD-FeNvPL
  • Asep Saepuloh Feb 10, 2014 @ 5:13


  • MAK Apr 18, 2014 @ 5:19

    Our vendor has finished installing redhat OS on our servers & has submitted an installation report. When I verify the file system using df -h , the sum of the size of the file systems as shown in the output is greater than the actual HDD size allocated to that virtual machine. But when I use fdisk -l|grep Disk, the size shown in output matches with the hdd size. Can you please help me out as to how do I verify the file system ??

    My aim is to match the HDD size allocated to particular Virtual machine with the total size all file systems on that VM.

  • sean loony Jul 26, 2015 @ 14:53

    lsblk is the most flexible tool for getting infos on a blockdevice:
    Size, and only the size in bytes of drive sda (2TB hdd)
    lsblk --nodeps --bytes --noheadings --output SIZE /dev/sda:

    • Dan Dec 24, 2016 @ 19:09

      Nice. I like that one. :)

  • Moe Aug 31, 2015 @ 10:11

    I would like to ask if there is a way to find out about how a linux system was partitioned at the time of installation, as you see I installed linux but when ran this command “df” it did not give me the exact parition sizes I specified at the time of installation. I would like to know this for already existing systems as to determine the sizes in case of a problem happens and I need to build and format a new hard drive.

  • Sumit Gaur Mar 8, 2017 @ 10:20

    My disk size is 90%. can i know at what time it becomes 90%.

    is there any command for that.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum