We can get CPU information using lscpu
command, is there any command to get hard disk information on Linux terminal, in a similar way?
-
3What kind of information are you looking for? Edit your question to be more specific. – Otheus Apr 03 '16 at 08:57
4 Answers
If you are looking for partitioning information you can use fdisk
or parted
.
If you are more interested into how the various partitions are associated with the mount points try lsblk
which I often use as:
lsblk -o "NAME,MAJ:MIN,RM,SIZE,RO,FSTYPE,MOUNTPOINT,UUID"
to include UUID
info.
And finally smartctl -a /dev/yourdrive
gives you detailed info like:
=== START OF INFORMATION SECTION ===
Device Model: WDC WD40EFRX-68WT0N0
Serial Number: WD-WCC4E4LA4965
LU WWN Device Id: 5 0014ee 261ca5a3f
Firmware Version: 82.00A82
User Capacity: 4,000,787,030,016 bytes [4.00 TB]
Sector Sizes: 512 bytes logical, 4096 bytes physical
Rotation Rate: 5400 rpm
Device is: Not in smartctl database [for details use: -P showall]
ATA Version is: ACS-2 (minor revision not indicated)
SATA Version is: SATA 3.0, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is: Sun Apr 3 10:59:55 2016 CEST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
and more.
Some of these commands need to be run sudo to get all info.

- 79,293
-
-
smartctl
does NOT work on every storage device... specially old ones – Yousha Aleayoub May 13 '20 at 18:23
You can use lshw
:
sudo lshw -c disk
But for newer kernels, i would suggest the portable and stable way of reading from sysfs
:
/sys/block/sd*/device/*

- 56,300
-
-
-
I'm asking because I have no idea. There seems to be no requirement that
/sys
is actually mounted, and I don't recall seeing it on certain embedded flavors. I also have no idea if it is declared "stable" by the linux kernel maintainers or if, as has been in the past, its interface might change from version to version.BTW: You might want to note
– Otheus Apr 03 '16 at 09:27/sys/block/sd*
will pick up only scsi disks. You'd have to do something more clever to figure out what block devices are actually disks, and some way to distinguish virtual from physical, eliminate loop, ram, and device mapper devices
Another one you can try in addition to what has already been suggested is:
hdparm -I /dev/sda
From the manpage:
DESCRIPTION
hdparm provides a command line interface to various kernel interfaces
supported by the Linux SATA/PATA/SAS "libata" subsystem and the older
IDE driver subsystem. Many newer (2008 and later) USB drive
enclosures now also support "SAT" (SCSI-ATA Command Translation) and
therefore may also work with hdparm. E.g. recent WD "Passport"
models and recent NexStar-3 enclosures. Some options may work
correctly only with the latest kernels.

- 72,889
-
By this command you can get disk's serial number even if it is connected via adapter to USB. – pbies Dec 25 '19 at 00:52