Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

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 ?

Thanks for your help....

share|improve this question

2 Answers 2

up vote 4 down vote accepted

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
share|improve this answer
    
So I have to add /dev/ with the result manually.........? –  Haris Apr 1 at 10:24
    
yes, sorry to make it so hard, it's some homework for you ;-) –  gogoud Apr 1 at 11:09
    
Hi, thanks for reply....I already completed the homework... :-) –  Haris Apr 1 at 11:11

Try this:

blkid | awk -F":" '{print $1}'
share|improve this answer
    
Actually I don’t need partition only device, like sda,sdb,sdc etc –  Haris Apr 1 at 10:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.