511152409.jpg
hdparm命令提供了一个命令行的接口用于读取和设置IDE或SCSI硬盘参数。
yum install -y hdparm

hdparm - get/set hard disk parameters - version v9.43, by Mark Lord.

Usage: hdparm [options] [device ...]

Options:
-a Get/set fs readahead
-A Get/set the drive look-ahead flag (0/1)
-b Get/set bus state (0 off, 1 on, 2 tristate)
-B Set Advanced Power Management setting (1-255)
-c Get/set IDE 32-bit IO setting
-C Check drive power mode status
-d Get/set using_dma flag
-D Enable/disable drive defect management
-E Set cd/dvd drive speed
-f Flush buffer cache for device on exit
-F Flush drive write cache
-g Display drive geometry
-h Display terse usage information
-H Read temperature from drive (Hitachi only)
-i Display drive identification
-I Detailed/current information directly from drive
-J Get/set Western DIgital "Idle3" timeout for a WDC "Green" drive (DANGEROUS)
-k Get/set keep_settings_over_reset flag (0/1)
-K Set drive keep_features_over_reset flag (0/1)
-L Set drive doorlock (0/1) (removable harddisks only)
-m Get/set multiple sector count
-M Get/set acoustic management (0-254, 128: quiet, 254: fast)
-n Get/set ignore-write-errors flag (0/1)
-N Get/set max visible number of sectors (HPA) (VERY DANGEROUS)
-p Set PIO mode on IDE interface chipset (0,1,2,3,4,...)
-P Set drive prefetch count
-q Change next setting quietly
-Q Get/set DMA queue_depth (if supported)
-r Get/set device readonly flag (DANGEROUS to set)
-R Get/set device write-read-verify flag
-s Set power-up in standby flag (0/1) (DANGEROUS)
-S Set standby (spindown) timeout
-t Perform device read timings
-T Perform cache read timings
-u Get/set unmaskirq flag (0/1)
-U Obsolete
-v Use defaults; same as -acdgkmur for IDE drives
-V Display program version and exit immediately
-w Perform device reset (DANGEROUS)
-W Get/set drive write-caching flag (0/1)
-x Obsolete
-X Set IDE xfer mode (DANGEROUS)
-y Put drive in standby mode
-Y Put drive to sleep
-z Re-read partition table
-Z Disable Seagate auto-powersaving mode
--dco-freeze Freeze/lock current device configuration until next power cycle
--dco-identify Read/dump device configuration identify data
--dco-restore Reset device configuration back to factory defaults
--direct Use O_DIRECT to bypass page cache for timings
--drq-hsm-error Crash system with a "stuck DRQ" error (VERY DANGEROUS)
--fallocate Create a file without writing data to disk
--fibmap Show device extents (and fragmentation) for a file
--fwdownload Download firmware file to drive (EXTREMELY DANGEROUS)
--fwdownload-mode3 Download firmware using min-size segments (EXTREMELY DANGEROUS)
--fwdownload-mode3-max Download firmware using max-size segments (EXTREMELY DANGEROUS)
--fwdownload-mode7 Download firmware using a single segment (EXTREMELY DANGEROUS)
--idle-immediate Idle drive immediately
--idle-unload Idle immediately and unload heads
--Istdin Read identify data from stdin as ASCII hex
--Istdout Write identify data to stdout as ASCII hex
--make-bad-sector Deliberately corrupt a sector directly on the media (VERY DANGEROUS)
--offset use with -t, to begin timings at given offset (in GiB) from start of drive
--prefer-ata12 Use 12-byte (instead of 16-byte) SAT commands when possible
--read-sector Read and dump (in hex) a sector directly from the media
--repair-sector Alias for the --write-sector option (VERY DANGEROUS)
--security-help Display help for ATA security commands
--trim-sector-ranges Tell SSD firmware to discard unneeded data sectors: lba:count ..
--trim-sector-ranges-stdin Same as above, but reads lba:count pairs from stdin
--verbose Display extra diagnostics from some commands
--write-sector Repair/overwrite a (possibly bad) sector directly on the media (VERY DANGEROUS)

-a<快取分区>:设定读取文件时,预先存入块区的分区数,若不加上<快取分区>选项,则显示目前的设定;
-A<0或1>:启动或关闭读取文件时的快取功能;
-c<I/O模式>:设定IDE32位I/O模式;
-C:检测IDE硬盘的电源管理模式;
-d<0或1>:设定磁盘的DMA模式;
-f:将内存缓冲区的数据写入硬盘,并清楚缓冲区;
-g:显示硬盘的磁轨,磁头,磁区等参数;
-h:显示帮助;
-i:显示硬盘的硬件规格信息,这些信息是在开机时由硬盘本身所提供;
-I:直接读取硬盘所提供的硬件规格信息;
-k<0或1>:重设硬盘时,保留-dmu参数的设定;
-K<0或1>:重设硬盘时,保留-APSWXZ参数的设定;
-m<磁区数>:设定硬盘多重分区存取的分区数;
-n<0或1>:忽略硬盘写入时所发生的错误;
-p<PIO模式>:设定硬盘的PIO模式;
-P<磁区数>:设定硬盘内部快取的分区数;
-q:在执行后续的参数时,不在屏幕上显示任何信息;
-r<0或1>:设定硬盘的读写模式;
-S<时间>:设定硬盘进入省电模式前的等待时间;
-t;评估硬盘的读取效率;
-T:平谷硬盘快取的读取效率;
-u<0或1>:在硬盘存取时,允许其他中断要求同时执行;
-v:显示硬盘的相关设定;
-w<0或1>:设定硬盘的写入快取;
-X<传输模式>:设定硬盘的传输模式;
-y:使IDE硬盘进入省电模式;
-Y:使IDE硬盘进入睡眠模式;
-Z:关闭某些Seagate硬盘的自动省电功能。

[root@gcp ~]# hdparm /dev/sda
/dev/sda:
SG_IO: bad/missing sense data, sb[]: 70 00 05 00 00 00 00 0a 00 00 00 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
multcount = 0 (off)
readonly = 0 (off)
readahead = 8192 (on)
geometry = 3916/255/63, sectors = 62914560, start = 0
#geometry = 19457[柱面数]/255[磁头数]/63[扇区数], sectors = 312581808[总扇区数], start = 0[起始扇区数]

测试硬盘的读取速度
-t :执行设备读取时序
-T :执行缓存读取时间
[root@gcp ~]# hdparm -tT /dev/sda
/dev/sda:
Timing cached reads: 18266 MB in 2.00 seconds = 9144.87 MB/sec
Timing buffered disk reads: 322 MB in 3.01 seconds = 106.82 MB/sec
为了检测更精准,这个操作应该重复2-3次 。这显示了无需访问磁盘,直接从 Linux 缓冲区缓存中读取的速度。这个测量实际上是被测系统的处理器、高速缓存和存储器的吞吐量的指标
如:for i in 1 2 3; do hdparm -tT /dev/hda; done

SATA 硬盘的连接速度
hdparm -I /dev/sda | grep -i speed

检测硬盘的电源管理模式:
hdparm -C /dev/sda
/dev/sda:
drive state is: standby [省电模式]

#硬盘坏道修复方法
检查:smartctl -l selftest /dev/sda
卸载:umount /dev/sda*
修复:badblocks /dev/sda

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

Captcha Code