我们可以通过lscpu
命令获取CPU信息,在Linux终端上有没有类似的命令可以获取硬盘信息?
答案1
如果您正在查找分区信息,可以使用fdisk
或parted
。
如果您对各个分区如何与挂载点关联更感兴趣,请尝试lsblk
我经常使用的方法:
lsblk -o "NAME,MAJ:MIN,RM,SIZE,RO,FSTYPE,MOUNTPOINT,UUID"
包含UUID
信息。
最后smartctl -a /dev/yourdrive
为您提供详细信息,例如:
=== 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
和更多。
其中一些命令需要运行 sudo 才能获取所有信息。
答案2
您可以使用lshw
:
sudo lshw -c disk
但对于较新的内核,我建议采用可移植且稳定的读取方式sysfs
:
/sys/block/sd*/device/*
答案3
除了已经建议的之外,您还可以尝试的另一种方法是:
hdparm -I /dev/sda
从联机帮助页:
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.
答案4
您可以使用以下命令:
lshw -class disk -class storage