在Linux下使用hdparm命令获取或设置硬盘参数是否安全?
时间:2020-01-09 10:41:06 来源:igfitidea点击:
hdparm命令提供了一个命令行界面,以供库存的Linux ATA/IDE设备驱动程序子系统支持的各种硬盘ioctl。
某些选项可能仅在最新的内核中才能正常工作。
获取硬盘信息您可以安全地使用hdparm获取硬盘信息。
例如,尝试使用以下命令来获取有关SCSI硬盘的信息(以root用户身份登录):
hdparm /dev/s
da
或获取详细信息:
hdparm I /dev/hda
输出:
/dev/hdb: ATA device, with non-removable media Model Number: SAMSUNG SP0822N Serial Number: S06QJ10Y123456 Firmware Revision: WA100-31 Standards: Used: ATA/ATAPI-6 T13 1410D revision 1 Supported: 7 6 5 4 & some of 7 Configuration: Logical max current cylinders 16383 65535 heads 16 1 sectors/track 63 63 - CHS current addressable sectors: 4128705 LBA user addressable sectors: 156368016 LBA48 user addressable sectors: 156368016 device size with M = 1024*1024: 76351 MBytes device size with M = 1000*1000: 80060 MBytes (80 GB) Capabilities: LBA, IORDY(can be disabled) Queue depth: 1 Standby timer values: spec'd by Standard, no device specific minimum R/W multiple sector transfer: Max = 16 Current = ? Recommended acoustic management value: 254, current value: 0 DMA: mdma0 mdma1 mdma2 udma0 udma1 *udma2 udma3 udma4 udma5 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: NOP cmd * READ BUFFER cmd * WRITE BUFFER cmd * Host Protected Area feature set * Look-ahead * Write cache * Power Management feature set Security Mode feature set SMART feature set * FLUSH CACHE EXT command * Mandatory FLUSH CACHE command * Device Configuration Overlay feature set * 48-bit Address feature set Automatic Acoustic Management feature set SET MAX security extension * DOWNLOAD MICROCODE cmd * SMART self-test * SMART error logging Security: Master password revision code = 65534 supported not enabled not locked not frozen not expired: security count supported: enhanced erase 50min for SECURITY ERASE UNIT. 50min for ENHANCED SECURITY ERASE UNIT. HW reset results: CBLID- below Vih Device num = 1 determined by the jumper Checksum: correct
您还可以找出硬盘读取或写入(缓存)数据的速度。
运行以下命令2-3次以获得有意义的结果:
hdparm tT /dev/hda
输出:
/dev/hda: Timing cached reads: 1008 MB in 2.00 seconds = 502.96 MB/sec Timing buffered disk reads: 54 MB in 3.09 seconds = 17.46 MB/sec
设置硬盘参数设置参数可能很危险。
您的OS/Linux内核经过优化,可以自动检测大多数硬盘的正确设置。
不要尝试使用hdparm命令设置新值。
错误的参数可能会导致数据丢失和/或损坏。
阅读所有选项的hdparm手册页。
您可以在Debian Linux下使用/etc/hdparm.conf来配置硬盘。
在RedHat Linux下,尝试/etc/sysconfig/harddisk文件。
注意:请勿修改以上文件,请保留文件原样,除非您确切知道自己在做什么。