56

We can get CPU information using lscpu command, is there any command to get hard disk information on Linux terminal, in a similar way?

1
  • 3
    What kind of information are you looking for? Edit your question to be more specific.
    – Otheus
    Apr 3, 2016 at 8:57

4 Answers 4

78

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.

2
  • Use gdisk for GPT partitioned diska
    – fpmurphy
    Apr 3, 2016 at 14:15
  • smartctl does NOT work on every storage device... specially old ones May 13, 2020 at 18:23
32

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/*
3
  • Using sysfs is portable and stable??
    – Otheus
    Apr 3, 2016 at 8:57
  • @Otheus unless you are using archaic kernel..
    – heemayl
    Apr 3, 2016 at 8:58
  • 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 /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
    – Otheus
    Apr 3, 2016 at 9:27
22

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.
1
  • By this command you can get disk's serial number even if it is connected via adapter to USB.
    – pbies
    Dec 25, 2019 at 0:52
9

You can use the following command:

lshw -class disk -class storage
1
  • shows only controller info, not actual disk info
    – Matt
    Jan 4, 2019 at 10:38

Not the answer you're looking for? Browse other questions tagged .