Linux useful disk commands

If you are a Linux user or Linux system administrator, be sure to get the information you need about the hard disk. Information such as description, product name, bus type, size and cache. In this article we will teach you how to do this and by what commands it will be possible.

How Using lsblk command to find out hard disk information? #

Run the lsblk command as follows to lists information about all available or the specified block devices:

# lsblk
# lsblk /dev/DISK
# lsblk /dev/sda

On My server , result like this :

lsblk - Linux useful disk commands

lsblk result command

Another option is to run the following command to list all disks and their names:

# ls -lF /dev/disk/by-id/

disk1 1024x237 - Linux useful disk commands

#

How show block device such as hard disk drive attributes in Linux ? #

Open the terminal app and then type the blkid command:

# blkid

/dev/loop0: UUID=”73e682e5-7b8b-40b3-948b-a8272d4bbd3a” TYPE=”ext3″
/dev/loop1: UUID=”e168a285-071d-4666-aaf9-55cb24f7f910″ TYPE=”ext4″
/dev/sda1: UUID=”062aaa2d-7396-4c0d-952d-5410017bdd15″ TYPE=”ext4″
/dev/sda2: UUID=”k4Zjum-JBui-qSHB-QZcq-6MLJ-LJsw-ukXklO” TYPE=”LVM2_member”
/dev/sda3: UUID=”sDo8bK-Vto4-derZ-UNLC-xl2t-8NMY-5qYutx” TYPE=”LVM2_member”
/dev/sdb1: UUID=”a61d1672-71bd-4bdc-bcef-ee7f011c5e29″ TYPE=”ext4″
/dev/mapper/vg_server3-lv_root: UUID=”1a87b4ba-0f3f-45cc-99aa-1dae6ee2cfcf” TYPE=”ext4″
/dev/mapper/vg_server3-lv_swap: UUID=”a17f8712-8ea2-4e4a-bbda-c5a4c711525c” TYPE=”swap”
/dev/mapper/docker-253:0-955527-pool: UUID=”e168a285-071d-4666-aaf9-55cb24f7f910″ TYPE=”ext4″

How Using hdparm Command in linux to get disk information ? #

Open the terminal and type the following command to find information about /dev/sda:

# hdparm -I /dev/sda

OR

$ sudo hdparm -I /dev/sda

maybe you will see following error :

hdparm -I /dev/sda
-bash: hdparm: command not found

How install hdparm Command on Centos with Yum : #

Run below command :

# yum install hdparm

How install hdparm Command on Ubunto : #

# apt install hdparm

Then Try again , You see result someting like below Picture :

hdparam result - Linux useful disk commands

hdparam command result

as you can see we found following information about our disks :
Disk Model Number , Serial Number , device size , Speed and other .

How to use lshw Command in Linux to get disk information? #

You need to install lshw command using apt-get or yum command. To display all disks and storage controllers in the system, enter:

# lshw -class disk -class storag

Finding Out Linux Disks Names Only #

The following lshw command will quickly list installed disks including CD/DVD/BD drivers:

# lshw -short -C disk

lshw short c disk - Linux useful disk commands

 

Another option so to run the fdisk command as follows:

# fdisk -l

Use the grep command/egrep command to filter out loopback and other unwanted devices:

# fdisk -l | grep ‘^Disk /dev/’
# fdisk -l | grep ‘^Disk /dev/’ | egrep -v ‘/dev/(loop|mapper|md)’
Disk /dev/nvme0n1: 953.89 GiB, 1024209543168 bytes, 2000409264 sectors
Disk /dev/nvme1n1: 953.89 GiB, 1024209543168 bytes, 2000409264 sectors

The smartctl command #

The smartctl command act as a control and monitor Utility for SMART disks under Linux and Unix like operating systems. Type the following command to get information about /dev/sda (SATA disk):

# smartctl -d ata -a -i /dev/sda

Sample outputs:

smartctl - Linux useful disk commands

 

Powered by BetterDocs

Leave a Comment