Extract Linux hard drive information without additional tools

I need to get information about a hard disk (e.g. physical disk capacity, model, etc.). I know that this is possible using various utilities such as lshw and hdparm . However, I need to get information without using any utility that cannot be installed, only with what is available by default for each Linux system.

How do I get hard drive information, such as disk capacity and serial number, using preinstalled tools on Linux?

+4
source share
3 answers

If you think cat is a utility in your “forbidden” circle, please ignore the answer.

to get the disk model you could:

  cat /proc/scsi/scsi 

here with my laptop it prints:

 kent$ cat /proc/scsi/scsi Attached devices: Host: scsi0 Channel: 00 Id: 00 Lun: 00 Vendor: ATA Model: ST9250410ASG Rev: 0004 Type: Direct-Access ANSI SCSI revision: 05 Host: scsi1 Channel: 00 Id: 00 Lun: 00 Vendor: MATSHITA Model: DVD+-RW UJ892 Rev: 1.01 Type: CD-ROM 

he has information about the model. I did not know how to do this. /proc/partitions shows blocks with no bandwidth.

+12
source
 cat /proc/partitions 

Lists which HD devices have capacity. grep in this for your interesting drive.

 cat /proc/diskstats 

This is less clear, but probably contains some answers.

And as birg891 already pointed out, you can scan the /dev/disk/by-* directories, but probably they will not provide much useful information (this is my experience).

Better you get the opportunity to use hdparm . To get information about the manufacturer, if you can restore it at all, you need to send a certain command to the device, which is easy with hdparm but hard to achieve without using tools. I do not know how to execute ioctl() using only bash.

+3
source

You can try scrolling / dev / disk / by -id. If you know the different brands of hard drives, they usually have a listing by model. For example, I know that seagate contains hard drive information in its model numbers. So, if you poke / dev / disk / by -id, you can get the model number and see it online.

+2
source

Source: https://habr.com/ru/post/1489474/


All Articles