25

This question already has an answer here:

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

marked as duplicate by jimmij, slm Apr 3 '16 at 15:10

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

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

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.

  • Good answer. You missed a closing quote in the lsblk command but unfortunately I'm not allowed to make a 1-character edit. – marcvangend Apr 3 '16 at 12:41
  • Use gdisk for GPT partitioned diska – fpmurphy Apr 3 '16 at 14:15
14

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

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

You can use the following command:

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

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