如何在Linux上查找硬盘规格/详细信息
时间:2020-01-09 14:16:27 来源:igfitidea点击:
您能否告诉我一个Linux命令,以使用命令行选项来查找有关我的硬盘的信息,例如在Linux操作系统下的描述,产品名称,总线类型,大小和缓存内存大小?
Linux随附各种命令来查找有关硬盘驱动器的信息。
我建议使用hdparm命令,该命令可提供命令行接口,以供库存的Linux ATA/IDE设备驱动程序子系统支持的各种硬盘ioctl。
此命令直接从驱动器读取/请求标识信息,例如磁盘大小,描述以及更多信息,这些信息以新的扩展格式显示。
使用lsblk命令找出硬盘信息
如下运行lsblk命令以列出有关所有可用或指定的块设备的信息:
# lsblk # lsblk /dev/DISK # lsblk /dev/sda
因此,我有两个处于RAID-1模式且具有加密分区的NVMe SSD:
nvme0n1 259:0 0 953.9G 0 disk ├─nvme0n1p1 259:1 0 953M 0 part /boot/efi ├─nvme0n1p2 259:2 0 3.7G 0 part │ └─md0 9:0 0 3.7G 0 raid1 /boot └─nvme0n1p3 259:3 0 949.2G 0 part └─md1 9:1 0 949.1G 0 raid1 └─md1_crypt 253:0 0 949.1G 0 crypt ├─theitroad-swap 253:1 0 119.2G 0 lvm [SWAP] └─theitroad-root 253:2 0 829.9G 0 lvm / nvme1n1 259:4 0 953.9G 0 disk ├─nvme1n1p1 259:5 0 953M 0 part ├─nvme1n1p2 259:6 0 3.7G 0 part │ └─md0 9:0 0 3.7G 0 raid1 /boot └─nvme1n1p3 259:7 0 949.2G 0 part └─md1 9:1 0 949.1G 0 raid1 └─md1_crypt 253:0 0 949.1G 0 crypt ├─theitroad-swap 253:1 0 119.2G 0 lvm [SWAP] └─theitroad-root 253:2 0 829.9G 0 lvm /
另一个选择是运行以下命令以列出所有磁盘及其名称:
# ls -lF /dev/disk/by-id/
Linux显示块设备,例如硬盘驱动器属性
打开终端应用程序,然后执行blkid命令:
# blkid
/dev/sda1: UUID="35D0-69B0" TYPE="vfat" PARTUUID="50f81f2e-9c4c-43ce-896d-7a55bee67397" /dev/sda2: UUID="985b0131-765b-4d1e-94fa-8c86491dad4d" TYPE="ext4" PARTUUID="00c44b9a-47b7-4ad3-b5ed-66a011f924b1
hdparm命令
打开终端并输入以下命令以查找有关/dev/sda的信息:
# hdparm -I /dev/sda
或者
$ sudo hdparm -I /dev/sda
输出示例:
/dev/sda: ATA device, with non-removable media Model Number: ST3500630AS Serial Number: 9XXYZ845YZ Firmware Revision: 3.AAK Standards: Supported: 7 6 5 4 Likely used: 7 Configuration: Logical max current cylinders 16383 16383 heads 16 16 sectors/track 63 63 - device size with M = 1024*1024: 476940 MBytes device size with M = 1000*1000: 500107 MBytes (500 GB) Capabilities: LBA, IORDY(can be disabled) Queue depth: 32 Standby timer values: spec'd by Standard, no device specific minimum R/W multiple sector transfer: Max = 16 Current = 16 Recommended acoustic management value: 254, current value: 0 DMA: mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 udma4 udma5 *udma6 Cycle time: min=120ns recommended=120ns PIO: pio0 pio1 pio2 pio3 pio4 Cycle time: no flow control=120ns IORDY flow control=120ns Commands/features: Enabled Supported: * SMART feature set Security Mode feature set * Power Management feature set * Write cache * Look-ahead * Host Protected Area feature set * WRITE_BUFFER command * READ_BUFFER command * Native Command Queueing (NCQ) * Phy event counters Device-initiated interface power management * Software settings preservation Security: Master password revision code = 65534 supported not enabled not locked frozen not expired: security count not supported: enhanced erase Checksum: correct
lshw命令
您需要使用apt-get或yum命令安装lshw命令。
要显示系统中的所有磁盘和存储控制器,请执行:
# lshw -class disk -class storage
输出示例:
*-storage description: Mass storage controller product: 5-in-1 Multimedia Card Reader (SD/MMC/MS/MS PRO/xD) vendor: Texas Instruments physical id: 1.2 bus info: pci@0000:03:01.2 version: 00 width: 32 bits clock: 33MHz capabilities: storage pm bus_master cap_list configuration: driver=tifm_7xx1 latency=64 maxlatency=4 mingnt=7 resources: irq:19 memory:f19fa000-f19fafff resources: irq:32 ioport:6e70(size=8) ioport:6e78(size=4) ioport:6e80(size=8) ioport:6e88(size=4) ioport:6ea0(size=32) memory:fed1e000-fed1e7ff *-disk:0 description: ATA Disk product: TOSHIBA MK5061GS vendor: Toshiba physical id: 0 bus info: scsi@0:0.0.0 logical name: /dev/sda version: MF00 serial: 71XYZYYYY size: 465GiB (500GB) capabilities: partitioned partitioned:dos configuration: ansiversion=5 signature=00025d42 *-cdrom description: DVD-RAM writer product: BD-RE UJ232A vendor: MATSHITA physical id: 1 bus info: scsi@1:0.0.0 logical name: /dev/cdrom logical name: /dev/cdrw version: 1.10 capabilities: removable audio cd-r cd-rw dvd dvd-r dvd-ram configuration: ansiversion=5 mount.fstype=udf mount.options=ro,nosuid,nodev,noexec,relatime,utf8 state=mounted status=ready *-medium physical id: 0 logical name: /dev/cdrom logical name: /media/cdrom0 configuration: mount.fstype=udf mount.options=ro,nosuid,nodev,noexec,relatime,utf8 state=mounted *-disk:1 description: ATA Disk product: ST9500420ASG vendor: Seagate physical id: 0.0.0 bus info: scsi@2:0.0.0 logical name: /dev/sdb version: 0004 configuration: ansiversion=5 guid=8795c9fc-5238-11e1-84e2-00216aca9b10
仅查找Linux磁盘名称
以下lshw命令将快速列出已安装的磁盘,包括CD/DVD/BD驱动程序:
# lshw -short -C disk
输出示例:
H/W path Device Class Description ======================================================== /0/100/1f.2/0 /dev/sda disk 500GB TOSHIBA MK5061GS /0/100/1f.2/1 /dev/cdrom disk BD-RE UJ232A /0/100/1f.2/1/0 /dev/cdrom disk /0/100/1f.2/0.0.0 /dev/sdb disk 500GB ST9500420ASG
另一个选择是运行fdisk命令,如下所示:
# fdisk -l
使用grep命令/egrep命令来过滤回送和其他有害设备:
# fdisk -l | grep '^Disk /dev/' # fdisk -l | grep '^Disk /dev/' | egrep -v '/dev/(loop|mapper|md)'
Disk /dev/nvme0n1: 953.89 GiB, 1024209543168 bytes, 2000409264 sectors Disk /dev/nvme1n1: 953.89 GiB, 1024209543168 bytes, 2000409264 sectors
Linux GUI磁盘实用程序
可以将gnome-disk-utility/gnome-disks用于以下目的:
- 获取有关已安装磁盘及其当前运行状况的信息。
- 管理和配置磁盘驱动器。
- 配置媒体。
- 设置软件RAID设备等。
输入以下命令或通过访问应用程序>系统工具>磁盘实用程序来启动磁盘实用程序:
$ palimpsest
或者
$ gnome-disks
smartctl命令
smartctl命令充当Linux和Unix之类的操作系统下SMART磁盘的控制和监视实用程序。
执行以下命令以获取有关/dev/sda(SATA磁盘)的信息:
# smartctl -d ata -a -i /dev/sda
输出示例:
smartctl 5.40 2010-07-12 r3124 [x86_64-unknown-linux-gnu] (local build) Copyright (C) 2002-10 by Bruce Allen, http://smartmontools.sourceforge.net === START OF INFORMATION SECTION === Device Model: TOSHIBA MK5061GSYF Serial Number: 71XXXYYZ Firmware Version: MF000D User Capacity: 500,107,862,016 bytes Device is: Not in smartctl database [for details use: -P showall] ATA Version is: 8 ATA Standard is: Exact ATA specification draft version not indicated Local Time is: Fri Feb 24 05:27:29 2012 IST SMART support is: Available - device has SMART capability. SMART support is: Enabled === START OF READ SMART DATA SECTION === SMART overall-health self-assessment test result: PASSED Total time to complete Offline data collection: ( 120) seconds. Offline data collection capabilities: (0x5b) SMART execute Offline immediate. Auto Offline data collection on/off support. Suspend Offline collection upon new command. Offline surface scan supported. Self-test supported. No Conveyance Self-test supported. Selective Self-test supported. SMART capabilities: (0x0003) Saves SMART data before entering power-saving mode. Supports SMART auto save timer. Error logging capability: (0x01) Error logging supported. General Purpose Logging supported. Short self-test routine recommended polling time: ( 2) minutes. SMART Attributes Data Structure revision number: 128 Vendor Specific SMART Attributes with Thresholds: ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE 1 Raw_Read_Error_Rate 0x000b 100 100 050 Pre-fail Always - 0 3 Spin_Up_Time 0x0027 100 100 001 Pre-fail Always - 1650 5 Reallocated_Sector_Ct 0x0033 100 100 050 Pre-fail Always - 0 9 Power_On_Hours 0x0032 099 099 000 Old_age Always - 34237 12 Power_Cycle_Count 0x0032 100 100 000 Old_age Always - 120 SMART Error Log Version: 1 No Errors Logged SMART Self-test log structure revision number 1 Num Test_Description Status Remaining LifeTime(hours) LBA_of_first_error # 1 Short offline Interrupted (host reset) 40% 343 # 2 Short offline Completed without error 00% 186 SMART Selective self-test log data structure revision number 1 SPAN MIN_LBA MAX_LBA CURRENT_TEST_STATUS 1 0 0 Not_testing 2 0 0 Not_testing 3 0 0 Not_testing Selective self-test flags (0x0): After scanning selected spans, do NOT read-scan remainder of disk. If Selective self-test is pending on power-up, resume after 0 minute delay.
关于RAID和SCSI磁盘的注释
对于基于SCSI和基于硬件RAID的设备,请尝试以下命令:
- sdparm命令获取SCSI/SATA设备信息。
- scsi_id命令通过SCSI INQUIRY重要产品数据(VPD)查询SCSI设备。
- 使用smartctl检查Adaptec RAID控制器后面的磁盘
- 使用smartctl检查3Ware RAID卡后面的硬盘