Test hard drive Bad Sectors in CentOS

Source: Internet
Author: User
Tags ide hard drive

Test hard drive Bad Sectors in CentOS

Hard Disk status testing tools: smartctl, Badblocks, hdparm

You can quickly see whether the hard disk is healthy by using smartctl. The command is as follows:

[Root @ qy ~] # Yum installsmartmontools-y

Start SMART

# Smartctl -- smart = on -- offlineauto = on -- saveauto = on/dev/sda

[Root @ qy ~] # Smartctl-a/dev/sda

Smartctl 5.42 2011-10-20 r3458 [i686-linux-2.6.18-194.el5PAE] (local build)

Copyright (C) 2002-11 by Bruce Allen, http://smartmontools.sourceforge.net

Vendor: SEAGATE

Product: ST3146356SS

Revision: HS09

User Capacity: 146,815,733,760 bytes [146 GB]

Logical block size: 512 bytes

Logical Unit id: 0x5000c50004fa837f

Serial number: 3QN0EL91

Device type: disk

Transport protocol: SAS

Local Time is: Fri Oct 31 10:45:58 2014 CST

Device supports SMART and is Enabled

Temperature Warning Disabled or NotSupported

SMART Health Status: OK # version does not match.

Current Drive Temperature: 30 C

Drive Trip Temperature: 68 C

Elements in grown defect list: 0 # is the bad track, commonly known as growth bad track.

Vendor (Seagate) cache information

Blocks sent to initiator = 3752023409

Blocks received from initiator = 3916316860

Blocks read from cache and sent to initialize = 4025399956

Number of read and write commands whose size <= segment size = 3339079605

Number of read and write commands whose size> segment size = 2746

Vendor (Seagate/Hitachi) factoryinformation

Number of hours powered up = 34120.02

Number of minutes until next internal SMART test = 1

Error counter log:

Errors Corrected byTotal Correction Gigabytes Total

ECC rereads/errorsalgorithm processed uncorrected

Fast | delayed rewrites correctedinvocations [10 ^ 9 bytes] errors

Read: 248894024 0 0248894024 248894024 85241.186 0

Write: 0 0 0 030998.996

Verify: 340001 00 340001 340001 141.757 0

Non-medium errorcount: 51 # Non-media error. This means that it is not a disk problem. It is generally caused by cable, transmission, and verification, which can be ignored.

No self-tests have been logged

Long (extended) Self Test duration: 1740 seconds [29.0 minutes]

You can run the following command to check whether the hard disk is good or bad:

[Root @ qy ~] # Smartctl-H/dev/sda

Smartctl 5.42 2011-10-20 r3458 [i686-linux-2.6.18-194.el5PAE] (local build)

Copyright (C) 2002-11 by Bruce Allen, http://smartmontools.sourceforge.net

SMART Health Status: OK

[Root @ localhost ~] # Smartctl-H/dev/sda

Smartctl 5.43 2012-06-30 r3573 [x86_64-linux-2.6.32-358.el6.x86_64] (local build)

Copyright (C) 2002-12 by Bruce Allen, http://smartmontools.sourceforge.net

=== Start of read smart data section ====

Smart status return: incomplete response, ATA output registers missing

SMART overall-health self-assessment test result: PASSED

Warning: This result is based on an Attribute check.

Both OK and PASSED belong to the disk normally.

The Badblocks tool is tested normally and has no bad track information:

The badblocks command can check the damaged blocks in the disk device. When executing this command, you must specify the disk device to be checked and the number of disk blocks for the device.

Badblocks-s // display progress-v // display execution details/dev/sda1

Badblocks-s // display progress-w // write to detect-v // display execution details/dev/sda2

Note: The mounted hard disks cannot be detected in writing mode.

[Root @ qy ~] # Badblocks-s-v/dev/sda

Checking blocks 0 to 143374740

Checking for bad blocks (read-only test): done

Passcompleted, 0 bad blocks found.

This disk has passed the test and has no bad sectors (Bad blocks ). You can use it with confidence.

The disk has a bad track ......

However, if another block is stuck during the detection process and the report shows that there are bad blocks ...... Your disk has bad sectors.

No matter what type of bad track, we recommend that you back up data first! Back up important data and try to fix it again. If you have important data but cannot read it (the disk is abnormal), immediately stop using this disk and ask a professional to fix it.

Use hdparm for testing

Test hard disk read/write speed

# Hdparm-Tt/dev/sda

/Dev/sda:

Timingcachedreads:

1918MBin2. 00 seconds = 959.62 MB/sec

Timingbuffereddiskreads: 184MBin3. 00 seconds = 61.26 MB/sec

Hdparm can be detected to display and set the parameters of the IDE or SCSI hard disk.

Syntax:

Hdparm [-partition hiiqttvyyz] [-a <cache partition>] [-A <0 or 1>] [-c <I/O mode>] [-d <0 or 1>] [-k <0 or 1>] [-K <0 or 1>] [-m <Number of partitions>] [-n <0 or 1>] [-p <PIO mode>] [-P <Number of partitions>] [-r <0 or 1>] [-S <time>] [-u <0 or 1>] [-W <0 or 1>] [-X <transmission mode>] [device]

-A <cache partition> sets the number of partitions that are pre-stored in the block area when the file is read. If the <cache partition> option is not added, the current setting is displayed. -A <0 or 1> enables or disables the cache function when reading files. -C <I/O mode> sets the IDE32-bit I/O mode. -C: detects the power management mode of the IDE hard disk. -D <0 or 1> sets the DMA mode of the disk. -F writes the data in the memory buffer to the hard disk and clarifies the buffer. -G: displays the disk's magnetic track, Head, magnetic area, and other parameters. -H: displays help. -I displays the hardware specification information of the hard disk, which is provided by the hard disk itself at startup. -I directly reads the hardware specification information provided by the hard disk. -K <0 or 1> to reset the hard disk, retain the-dmu parameter settings. -K <0 or 1> to reset the hard disk, retain the-APSWXZ parameter settings. -M <number of magnetic partitions> sets the number of partitions accessed by multiple hard disk partitions. -N <0 or 1> indicates an error that occurs when the hard disk is written. -P <PIO mode> sets the PIO mode of the hard disk. -P <number of magnetic partitions> sets the number of partitions in the cache of the hard disk. -When executing subsequent parameters, q does not display any information on the screen. -R <0 or 1> sets the read/write mode of the hard disk. -S <time> sets the waiting time before the hard disk enters power-saving mode. -T to evaluate the Read efficiency of the hard disk. -T the reading efficiency of the flat hard disk cache. -U <0 or 1> allows other interruption requests to be executed simultaneously during hard disk access. -V displays the hard disk settings. -W <0 or 1> sets the hard disk write cache. -X <transmission mode> sets the transmission mode of the hard disk. -Y enables the IDE hard drive to power-saving mode. -Y: Enable the IDE hard drive to sleep. -Z disables automatic power saving for some Seagate hard disks.

You can run the sg_vpd command to view the disk speed. The sg_vpd command is one of sg3_utils tools.

: Http://sg.danny.cz/sg/sg3_utils.html

VPD: Vital Product Data

[Root @ qy sg3_utils-1.39] # sg_vpd/dev/sda

About smart hard disk detection command supplement:

Smartctl-a <device> check whether the SMART technology is enabled for the device. Smartctl-son <device> If the SMART technology is not enabled, use this command to enable the SMART technology. Smartctl-tshort <device> background hard disk detection, which takes a short time; smartctl-tlong <device> background hard disk detection, which takes a long time; smartctl-C-tshort <device> foreground hard disk detection, short time consumption; smartctl-C-tlong <device> front-end hard disk detection, long time consumption. It is actually using the hard disk SMART self-check program. Smartctl-X <device> interrupts the hard disk detected in the background. Smartctl-lselftest <device>: displays the disk Detection Log. Smartctl-lerror <device> displays the hard disk error summary.

First, use the dmesg tool to confirm the device symbol of the hard disk. For example, if an IDE hard disk is connected to the Slave location on the PrimaryIDE bus, the hard disk device symbol is/dev/hdb. h in hdb indicates IDE. If it is sdb, it indicates SATA and SCSI, the last subtitle B represents the Primary bus, and the second hard disk is the Slave location. Check whether the SMART support is enabled for the hard disk:

# Smartctl-I/dev/sda

Smartctl5.402010-10-16r3189 [i386-redhat-linux-gnu] (localbuild)

Copyright (C) 2002-10byBruceAllen, http://smartmontools.sourceforge.net

=== STARTOFINFORMATIONSECTION ===

DeviceModel: HITACHIHTS543225L9SA00

SerialNumber: 090116fb2f32ylg28jea

FirmwareVersion: FBEZC48C

UserCapacity: 250,059,350,016 bytes

Deviceis: Notinsmartctldatabase [fordetailsuse:-Pshowall]

ATAVersionis: 8

ATAStandardis: ATA-8-ACSrevision3f

LocalTimeis: WedMay2510: 10: 392011CST

SMARTsupportis: Available-devicehasSMARTcapability.

SMARTsupportis: Enabled // indicates that smart support is Enabled.

If you see SMARTsupportis: Disabled, it indicates that SMART is not enabled. Run the following command to start SMART

# Smartctl -- smart = on -- offlineauto = on -- saveauto = on/dev/sda

Smartctl5.402010-10-16r3189 [i386-redhat-linux-gnu] (localbuild)

Copyright (C) 2002-10byBruceAllen, http://smartmontools.sourceforge.net

=== STARTOFENABLE/DISABLECOMMANDSSECTION ===

SMARTEnabled.

SMARTAttributeAutosaveEnabled.

SMARTAutomaticOfflineTestingEnabledeveryfourhours.

Now the SMART function of the hard disk has been enabled. Run the following command to check the health status of the hard disk:

# Smartctl-H/dev/sda

Smartctl5.402010-10-16r3189 [i386-redhat-linux-gnu] (localbuild)

Copyright (C) 2002-10byBruceAllen, http://smartmontools.sourceforge.net

=== STARTOFREADSMARTDATASECTION ===

SMARToverall-healthself-assessmenttestresult: PASSED

Note the result following the result: PASSED, which indicates that the hard disk is in good health. If Failure is displayed, it is best to change the hard disk to the server immediately. SMART can only report that the disk is no longer healthy, but it is not clear how long it will continue to run after the alarm. Generally, the SMART alarm parameters are reserved. After a disk alarm is triggered, it will not be broken on the spot. Generally, it can last for a period of time. Some hard disk SMART alarms continue to run for several years, some hard drive SMART will be broken several days after an error is reported. However, once an alarm is triggered, you are lucky to be unable ......

# Smartctl-A/dev/sda view disk details

# Smartctl-son/dev/sda if the SMART technology is not enabled, use this command to open the SMART technology.

# Smartctl-tshort/dev/sda background hard disk detection, short time consumption;

# Smartctl-tlong/dev/sda background hard disk detection, which takes a long time;

# Smartctl-C-t/dev/sdashort front-end hard disk detection, short time consumption;

# Smartctl-C-t/dev/sdalong front-end hard disk detection, which takes a long time. It is actually using the hard disk SMART self-check program.

# Smartctl-X/dev/sda interrupt background detection hard disk.

# Smartctl-lselftest/dev/sda: displays the hard disk Detection Log.

# Smartctl-lerror/dev/sda displays the hard disk error summary.

If you need to regularly log on to the server to run smartctl, linux also provides the system process smartd, edit the configuration file: 1vi/etc/smartd. conf

Most of this configuration file may be commented out. You only need to write the configuration related to the current Hard Disk:

/Dev/sda-H-mtest@test123123.com // monitor the disk health status and ignore it when PASSED is reported in SMART. Once a Failure occurs, you can immediately notify the user of the specified email address by email.

/Dev/sda-a-madmin@example.com, root @ localhost // monitor all attributes of the disk and ignore it when PASSED is reported in SMART. Once a Failure occurs, you can immediately notify the user of the specified email address by email.

/Dev/twa0-d3ware, 0-a-sL /.. /.. /7/00 // monitor all attributes of the first ATA disk on the 3ware9000 controller, and perform self-detection of long format at-on every Sunday

/Dev/sg2-dareca, 1-a-sL /.. /(01 | 15 )/. /22 // monitor all attributes of the first SATA disk on the ArecaRaid controller and perform self-detection of long format at -- On the 15th and 12th days of each week month

-S (O /.. /.. /. /(00 | 06 | 12 | 18) | S /.. /.. /. /01 | L /.. /.. /6/03) // perform offline self-check at, and every day, and perform Short-format self-check between and every day, perform self-check in long format from to every week.

After configuring smartd. conf, execute

/Etc/init. d/smartdrestart

For other configurations related to smartd. conf, see:

Http://smartmontools.sourceforge.net/man/smartd.conf.5.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.