Software & AppsOperating SystemLinux

How To Find the Actual Physical Disk Size Using Command Line

Ubuntu 16

In the world of system administration, knowing how to handle and retrieve information from the command line is an essential skill. One such piece of information that you might need to retrieve is the actual physical disk size. This article will guide you through different ways to find the actual physical disk size using the command line in a Linux environment.

Quick Answer

To find the actual physical disk size using the command line in a Linux environment, you can use the lsblk command to list all available block devices and their sizes. If the lsblk command is not available, you can use the parted command to list disks and their partition information, or the hdparm command to view hardware parameters of hard disk drives, including the disk size.

Using the lsblk Command

The lsblk command lists information about all available block devices, which are read from the sysfs filesystem. The command reads the sysfs filesystem to gather information. The command shows block device attributes like size, RO (Read-Only), RM (Removable device) and more.

To use the lsblk command, open your terminal and type:

lsblk

The output will list all the disks, their sizes, partitions, and mount points. Look for the “SIZE” column to see the size of each disk.

If the lsblk command is not available, you may need to install it. Use the following command to install it:

sudo apt-get install util-linux

Using the parted Command

The parted command is a disk partitioning and partition resizing program. It allows you to create, destroy, resize, move and copy ext2, linux-swap, FAT, FAT32, and reiserfs partitions.

To use the parted command, type:

sudo parted -l

This command will list all disks and their partition information. If you want to get more specific details about a particular disk, use the command as follows:

sudo parted /dev/sda print

Replace “sda” with the specific disk’s block device that you want to check.

Using the hdparm Command

The hdparm command is a command line utility to set and view hardware parameters of hard disk drives. It can set parameters such as drive caches, sleep mode, power management, acoustic management, and DMA settings. It can also provide information about the disk, including its size.

To use the hdparm command, type:

sudo hdparm -I /dev/your_device | grep GB

Replace “your_device” with the device name (e.g., sda, sdb). Look for the line that includes “GB” to find the actual disk size.

Conclusion

These commands provide a quick and easy way to find the actual physical disk size using the command line. Remember to run these commands with sudo or as a superuser to ensure you have the necessary permissions to access the disk information. Be aware that the availability of these commands may vary depending on your operating system.

Knowing how to retrieve this information is essential for system administration tasks such as disk management, troubleshooting, and capacity planning. With this knowledge in hand, you’ll be well-equipped to handle these tasks efficiently and effectively.

What is the purpose of the `lsblk` command?

The lsblk command is used to list information about all available block devices, including their sizes, partitions, and mount points.

How do I install the `lsblk` command if it is not available?

If the lsblk command is not available, you can install it by using the command sudo apt-get install util-linux.

What does the `parted` command do?

The parted command is a disk partitioning and partition resizing program. It allows you to create, destroy, resize, move, and copy partitions on various file systems.

How do I use the `parted` command to get disk information?

To get disk information using the parted command, you can use the command sudo parted -l to list all disks and their partition information. If you want more specific details about a particular disk, use the command sudo parted /dev/sda print, replacing "sda" with the specific disk’s block device.

What is the purpose of the `hdparm` command?

The hdparm command is a utility to set and view hardware parameters of hard disk drives. It can also provide information about the disk, including its size.

How do I use the `hdparm` command to find the disk size?

To find the disk size using the hdparm command, use the command sudo hdparm -I /dev/your_device | grep GB, replacing "your_device" with the device name (e.g., sda, sdb). Look for the line that includes "GB" to find the actual disk size.

Leave a Comment

Your email address will not be published. Required fields are marked *