Linux – Get all hardisk list (/dev/sd*)Using command line

command linehard-disklinux

I need to get all the hardisk connected to my PC like,

 /dev/sda
 /dev/sdb
 /dev/sdc

later I have to use it in script and monitor using iostat

I alrady found fdisk command, it seems to be hard for me to extract all the device from the output of fdisk using grep.

Is there any simple way ?

Best Answer

easier than fdisk for your purpose is lsblk:

$ lsblk --nodeps
NAME MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda    8:0    0 223.6G  0 disk
sdb    8:16   0 298.1G  0 disk
sr0   11:0    1    12M  0 rom

or if you just want the drives:

$ lsblk --nodeps -n -o name
sda
sdb
sr0
Related Question