LKBEN11493: Find the size of your hard disks on linux


Symptom

You need to find out how big your HD is on a linux bases system

Cause

You want a bigger disk so you need to know what you have

Solution

To find the size of your hard disk you can use the fdisk tool like this:

sudo fdisk -l

On my system this delivers:

Disk /dev/sda: 127 GiB, 136365211648 bytes, 266338304 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x5f897996

Device     Boot    Start      End  Sectors  Size Id Type
/dev/sda1  *        2048 19531775 19529728  9,3G 83 Linux
/dev/sda2       19531776 29296639  9764864  4,7G 82 Linux swap / Solaris

To see how much space you still have left on your HD, you can use df:

df -h

A typical output look like this:

Filesystem      Size  Used Avail Use% Mounted on
udev            975M     0  975M   0% /dev
tmpfs           200M   22M  178M  11% /run
/dev/sda1       9,1G  2,1G  6,5G  25% /
tmpfs           996M     0  996M   0% /dev/shm
tmpfs           5,0M     0  5,0M   0% /run/lock
tmpfs           996M     0  996M   0% /sys/fs/cgroup
tmpfs           200M     0  200M   0% /run/user/1000

Here you can find the Use in % and how much is still available. Most of the time you will be interested in the mountpoint /. I made it bold in the output above.

Disclaimer:

The information provided in this document is intended for your information only. Lubby makes no claims to the validity of this information. Use of this information is at own risk!

About the Author

Author: Wim Peeters - Keskon GmbH & Co. KG

Wim Peeters is electronics engineer with an additional master in IT and over 30 years of experience, including time spent in support, development, consulting, training and database administration. Wim has worked with SQL Server since version 6.5. He has developed in C/C++, Java and C# on Windows and Linux. He writes knowledge base articles to solve IT problems and publishes them on the Lubby Knowledge Platform.

Latest update: 14/01/2021 | Comment: