How To Get Drive Size Using Ubuntu Terminal

How To Get Drive Size Using Ubuntu Terminal

2 min read Mar 30, 2025
How To Get Drive Size Using Ubuntu Terminal

Discover more detailed and exciting information on our website. Click the link below to start your adventure: Visit Best Website. Don't miss out!

How to Get Drive Size Using the Ubuntu Terminal

Knowing your drive size is crucial for managing storage space on your Ubuntu system. Whether you're troubleshooting low disk space or planning a system upgrade, understanding how to quickly retrieve this information is essential. This guide provides several methods to check your drive size using the Ubuntu terminal, catering to different levels of user expertise.

Method 1: Using df (Disk Free)

The df command is a simple and effective way to view disk space usage. It provides a concise summary of file system usage, including the total size, used space, and available space for each mounted drive.

df -h

The -h flag formats the output in a human-readable format (using KB, MB, GB, etc.), making it easier to interpret the results. This will show you a table with information on all your mounted partitions. Look for the column labeled "Size" to see the total size of each drive.

Understanding the Output:

The output will look something like this:

Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1        97G   65G   28G  70% /
/dev/sda5        99G   12G   83G  13% /home

Here, /dev/sda1 is a partition with a total size of 97GB, and /dev/sda5 is another with 99GB.

Method 2: Using lsblk (List Block Devices)

The lsblk command provides a more detailed view of your block devices, including hard drives, SSDs, and partitions. It’s particularly useful for visualizing the hierarchical structure of your storage.

lsblk -f

The -f flag displays extra information such as mount points and file system types. This command gives you a tree-like representation of your drives and partitions, with the size clearly indicated for each.

Interpreting lsblk Output:

The output might appear like this:

NAME   FSTYPE   LABEL        SIZE MOUNTPOINT
sda                                   931.5G
└─sda1  ext4     root          88.0G /
└─sda2  swap                    4.0G [SWAP]
└─sda5  ext4     home          802.5G /home

This shows that sda is a 931.5 GB drive, with partitions sda1 (88GB), sda2 (4GB swap), and sda5 (802.5GB).

Method 3: Targeting Specific Partitions

If you only need the size of a specific partition, you can directly specify the device name. For example, to find the size of /dev/sda1:

lsblk -b /dev/sda1

The -b flag outputs the size in bytes. To get a human-readable output, omit the -b flag, and use the output from lsblk -f instead.

Troubleshooting and Further Exploration

  • Permissions: If you encounter permission errors, ensure you're running the commands with sufficient privileges (e.g., using sudo).
  • Multiple Drives: If you have multiple hard drives or SSDs installed, the output will list them all.
  • Advanced Usage: Explore the df and lsblk man pages (man df and man lsblk) for more advanced options and detailed information.

By using these methods, you can easily determine your drive size and manage your Ubuntu system's storage effectively. Remember to always back up important data before making any significant changes to your storage configuration.


Thank you for visiting our website wich cover about How To Get Drive Size Using Ubuntu Terminal. We hope the information provided has been useful to you. Feel free to contact us if you have any questions or need further assistance. See you next time and dont miss to bookmark.