1. 程式人生 > >Linux下如何檢視你的disk的資訊

Linux下如何檢視你的disk的資訊

可以使用smartctl來檢視你的disk的資訊;
smartctl的disk路徑和名字可以通過命令cat /proc/partitions 來得到。

sudo smartctl -d ata -a /dev/sda           
smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.10.0-327.36.3.el7.x86_64] (local build)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION
=== Device Model: MTFDDAK512MBF-xx Serial Number: xxx LU WWN Device Id: xxx Firmware Version: xxx User Capacity: 512,110,190,592 bytes [512 GB] Sector Size: 512 bytes logical/physical Rotation Rate: Solid State Device Device is: Not in smartctl database [for details use: -P showall] ATA Version is
: ACS-3 (unknown minor revision code: 0x011b) SATA Version is: SATA >3.1, 6.0 Gb/s (current: 6.0 Gb/s) Local Time is: Wed Dec 6 10:22:40 2017 CST SMART support is: Available - device has SMART capability. SMART support is: Enabled ...

從Device Model中,可以知道,我的硬碟是MTFDDAK512MBF,在網址google一下,就知道它是Micron產的,具體的內容為了安全考慮,我就不貼出來了。

smartctl中的type的解釋:
ATA, SCSI command sets and SAT

In the past there has been a clear distinction between storage devices that used the ATA and SCSI command sets. This distinction was often reflected in their device naming and hardware. Now various SCSI transports (e.g. SAS, FC and iSCSI) can interconnect to both SCSI disks (e.g. FC and SAS) and ATA disks (especially SATA). USB and IEEE 1394 storage devices use the SCSI command set externally but almost always contain ATA or SATA disks (or flash). The storage subsystems in some operating systems have started to remove the distinction between ATA and SCSI in their device naming policies.

99% of operations that an OS performs on a disk involve the SCSI INQUIRY, READ CAPACITY, READ and WRITE commands, or their ATA equivalents. Since the SCSI commands are slightly more general than their ATA equivalents, many OSes are generating SCSI commands (mainly READ and WRITE) and letting a lower level translate them to their ATA equivalents as the need arises. An important note here is that “lower level” may be in external equipment and hence outside the control of an OS.

SCSI to ATA Translation (SAT) is a standard (ANSI INCITS 431-2007) that specifies how this translation is done. For the other 1% of operations that an OS performs on a disk, SAT provides two options. First is an optional ATA PASS-THROUGH SCSI command (there are two variants). The second is a translation from the closest SCSI command. Most current interest is in the “pass-through” option.

The relevance to smartmontools (and hence smartctl) is that its interactions with disks fall solidly into the “1%” category. So even if the OS can happily treat (and name) a disk as “SCSI”, smartmontools needs to detect the native command set and act accordingly. As more storage manufacturers (including external SATA drives) comply with SAT, smartmontools is able to automatically distinguish the native command set of the device. In some cases the ‘-d sat’ option is needed on the command line.

There are also virtual disks which typically have no useful information to convey to smartmontools, but could conceivably in the future. An example of a virtual disk is the OS’s view of a RAID 1 box. There are most likely two SATA disks inside a RAID 1 box. Addressing those SATA disks from a distant OS is a challenge for smartmontools. Another approach is running a tool like smartmontools inside the RAID 1 box (e.g. a Network Attached Storage (NAS) box) and fetching the logs via a browser.