Hard Disk Drive

From Indie IT Wiki
Jump to: navigation, search

Windows Monitoring Software

HDD Guardian provides a Windows front-end for smartctl, a tool for querying S.M.A.R.T. data of your hard drive. With HDD Guardian you can survey your hard disk health, preventing data loss due to hard drive death.

Key features of HDD Guardian are:

  • easy device overview, with temperature, overall health and bad sectors indication
  • display an optional icon into the tray area for each local device
  • HDD Guardian tray icon change shield color if a device is failing
  • monitor virtual devices loaded from a shared smartctl output
  • displays device identity information
  • perform self-test and displays their results
  • allow enabling/disabling S.M.A.R.T., automatic offline data collection (an automatic test performed by device every four hours) and autosave of vendor-specific attributes
  • displays attributes information and graphs
  • displays device error log
  • allow to set device-specific attribute format and firmware debug
  • allow to set warnings behaviour
  • support for external (USB) devices, also in docking stations

Western Digital WD Warranty Check

http://wdsupport.wdc.com/warranty/serialinput.asp?custtype=end&requesttype=warranty&lang=en

Western Digital WD Support Area Product Registered

https://westerndigital.secure.force.com/ind/ID_ProductsRegistered

Stop Spinning USB Hard Disk Drive

Make sure it is not mounted, then run the following command...

sdparm --readonly --command=stop /dev/sdX

USB 3 Details

[48207.031486] usb 9-1: new SuperSpeed USB device number 2 using xhci_hcd

Checking For Bad Sectors

badblocks -s /dev/sdX1

Western Digital WD Idle Timer Load Cycle Count

http://www.jzab.de/content/wdidle-bootcd

or

http://www.ultimatebootcd.com/download.html

WDIDLE3 /D

or

http://idle3-tools.sourceforge.net/

thinkpad ~ # smartctl --device=sat --all /dev/sda |grep 'Load_Cycle_Count'
193 Load_Cycle_Count        0x0032   105   105   000    Old_age   Always       -       286710
thinkpad ~ # emerge -q sys-apps/idle3-tools
>>> Verifying ebuild manifests
>>> Emerging (1 of 1) sys-apps/idle3-tools-0.9.1
>>> Installing (1 of 1) sys-apps/idle3-tools-0.9.1
>>> Recording sys-apps/idle3-tools in "world" favorites file...
thinkpad ~ # idle3ctl -g /dev/sda
Idle3 timer set to 40 (0x28)
thinkpad ~ # idle3ctl -d /dev/sda
Idle3 timer disabled
Please power cycle your drive off and on for the new setting to be taken into account. A reboot will not be enough!

Self-Monitoring, Analysis and Reporting Technology System (S.M.A.R.T.)

Linux uses SmartMonTools to access the SMART information.

smartctl 5.43 2012-06-30 r3573 [x86_64-linux-3.3.8-gentoo] (local build)
Copyright (C) 2002-12 by Bruce Allen, http://smartmontools.sourceforge.net

The examples below use /dev/sda as the first internal hard disk drive, and /dev/sdb as the external usb drive.

Scan For Devices

smartctl --scan

Device Driver

smartctl --device=test /dev/sda

/dev/sda: Device of type 'scsi' [SCSI] detected
/dev/sda [SAT]: Device open changed type from 'scsi' to 'sat'
/dev/sda [SAT]: Device of type 'sat' [ATA] opened

So, we use the sat driver for this device.

Turn SMART Feature ON

smartctl --device=sat --smart=on /dev/sda

Information

smartctl --device=sat --all /dev/sda

Health Check

smartctl --device=sat --health /dev/sda

Tests - Internal Drives

Self-Test: Short (internal SATA)

smartctl --device=sat --test=short /dev/sda

Self-Test: Medium (internal SATA)

smartctl --device=sat --test=conveyance /dev/sda

Self-Test: Long (internal SATA)

smartctl --device=sat --test=long /dev/sda

Tests - USB External Drives

Self-Test: Short

smartctl --device=sat,16 --test=short /dev/sdb

Self-Test: Medium

smartctl --device=sat,16 --test=conveyance /dev/sdb

Self-Test: Long

smartctl --device=sat,16 --test=long /dev/sdb

The last long test on an external USB drive may need to be combined with this series of commands to stop the kernel from sleeping the drive:-

while true; do dd if=/dev/sdX iflag=direct count=1 of=/dev/null; sleep 60s; done

Tests Stop

smartctl --device=sat --abort /dev/sda

Show Test Logs

Terminal:~$

sudo smartctl --device=sat --log=selftest /dev/sdX

The output should look like the following:

smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.16.0-31-generic] (local build)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF READ SMART DATA SECTION ===
SMART Self-test log structure revision number 1
Num  Test_Description    Status                  Remaining  LifeTime(hours)  LBA_of_first_error
# 1  Extended offline    Completed without error       00%     62071         -
# 2  Short offline       Completed without error       00%     57922         -
# 3  Short offline       Completed without error       00%     51265         -

Show Hard Drive Details and Test Logs

Terminal:~$ 

sudo smartctl -i --device=sat --log=selftest /dev/sdX

The output should look like the following:

smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.13.0-38-generic] (local build)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Model Family:     Western Digital Caviar SE Serial ATA
Device Model:     WDC WD800JD-60JRA0
Serial Number:    WD-WMAMD2064823
Firmware Version: 05.01C05
User Capacity:    80,026,361,856 bytes [80.0 GB] 
Sector Size:      512 bytes logical/physical
Device is:        In smartctl database [for details use: -P show]
ATA Version is:   ATA/ATAPI-7 (minor revision not indicated)
Local Time is:    Tue Oct 14 13:06:35 2014 BST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

=== START OF READ SMART DATA SECTION ===
SMART Self-test log structure revision number 1
Num  Test_Description    Status                  Remaining  LifeTime(hours)  LBA_of_first_error
# 1  Extended offline    Completed without error       00%     62071         -
# 2  Short offline       Completed without error       00%     57922         -
# 3  Short offline       Completed without error       00%     51265         -

Daily, Weekly, Monthly Checks In CRON

# hard disk drive checks
@daily /usr/sbin/smartctl --device=sat --all /dev/sda && /usr/sbin/smartctl --device=sat --all /dev/sdb && /usr/sbin/smartctl --device=sat --all /dev/sdc
@weekly /usr/sbin/smartctl --device=sat --test=short /dev/sda && /usr/sbin/smartctl --device=sat --test=short /dev/sdb && /usr/sbin/smartctl --device=sat --test=short /dev/sdc
@monthly /usr/sbin/smartctl --device=sat --test=long /dev/sda && /usr/sbin/smartctl --device=sat --test=long /dev/sdb && /usr/sbin/smartctl --device=sat --test=long /dev/sdc

How To Stop A Hard Disk Drive From Power Management Sleep During SMART Tests

 while true; do dd if=/dev/sdX iflag=direct count=1 of=/dev/null; sleep 60s; done

Mac OS X / MacOS

./smartctl --help smartctl 6.5 2016-05-07 r4318 [Darwin 16.6.0 x86_64] (local build) Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org

Usage: smartctl [options] device

======================================= SHOW INFORMATION OPTIONS
 -h, --help, --usage
        Display this help and exit
 -V, --version, --copyright, --license
        Print license, copyright, and version information and exit
 -i, --info
        Show identity information for device
 --identify[=[w][nvb]]
        Show words and bits from IDENTIFY DEVICE data                (ATA)
 -g NAME, --get=NAME
       Get device setting: all, aam, apm, lookahead, security, wcache, rcache, wcreorder
 -a, --all
        Show all SMART information for device
 -x, --xall
        Show all information for device
 --scan
        Scan for devices
 --scan-open
        Scan for devices and try to open each device
============================= SMARTCTL RUN-TIME BEHAVIOR OPTIONS
 -q TYPE, --quietmode=TYPE                                           (ATA)
        Set smartctl quiet mode to one of: errorsonly, silent, noserial
 -d TYPE, --device=TYPE
        Specify device type to one of: ata, scsi, nvme[,NSID], sat[,auto][,N][+TYPE], usbcypress[,X], usbjmicron[,p][,x][,N], usbprolific, usbsunplus, auto, test
 -T TYPE, --tolerance=TYPE                                           (ATA)
        Tolerance: normal, conservative, permissive, verypermissive
 -b TYPE, --badsum=TYPE                                              (ATA)
        Set action on bad checksum to one of: warn, exit, ignore
 -r TYPE, --report=TYPE
        Report transactions (see man page)
 -n MODE, --nocheck=MODE                                             (ATA)
        No check if: never, sleep, standby, idle (see man page)
========================= DEVICE FEATURE ENABLE/DISABLE COMMANDS
 -s VALUE, --smart=VALUE
       Enable/disable SMART on device (on/off)
 -o VALUE, --offlineauto=VALUE                                       (ATA)
       Enable/disable automatic offline testing on device (on/off)
 -S VALUE, --saveauto=VALUE                                          (ATA)
       Enable/disable Attribute autosave on device (on/off)
 -s NAME[,VALUE], --set=NAME[,VALUE]
       Enable/disable/change device setting: aam,[N|off], apm,[N|off],
       lookahead,[on|off], security-freeze, standby,[N|off|now],
       wcache,[on|off], rcache,[on|off], wcreorder,[on|off]
================================== READ AND DISPLAY DATA OPTIONS
 -H, --health
       Show device SMART health status
 -c, --capabilities                                            (ATA, NVMe)
       Show device SMART capabilities
 -A, --attributes
       Show device SMART vendor-specific Attributes and values
 -f FORMAT, --format=FORMAT                                          (ATA)
       Set output format for attributes: old, brief, hex[,id|val]
 -l TYPE, --log=TYPE
       Show device log. TYPE: error, selftest, selective, directory[,g|s],
                              xerror[,N][,error], xselftest[,N][,selftest],
                              background, sasphy[,reset], sataphy[,reset],
                              scttemp[sts,hist], scttempint,N[,p],
                              scterc[,N,M], devstat[,N], ssd,
                              gplog,N[,RANGE], smartlog,N[,RANGE],
                              nvmelog,N,SIZE
 -v N,OPTION , --vendorattribute=N,OPTION                            (ATA)
       Set display OPTION for vendor Attribute N (see man page)
 -F TYPE, --firmwarebug=TYPE                                         (ATA)
       Use firmware bug workaround:
       none, nologdir, samsung, samsung2, samsung3, xerrorlba, swapid
 -P TYPE, --presets=TYPE                                             (ATA)
       Drive-specific presets: use, ignore, show, showall
 -B [+]FILE, --drivedb=[+]FILE                                       (ATA)
       Read and replace [add] drive database from FILE
       [default is +/usr/local/etc/smart_drivedb.h
        and then    /usr/local/share/smartmontools/drivedb.h]
======================================= DEVICE SELF-TEST OPTIONS
 -t TEST, --test=TEST
       Run test. TEST: offline, short, long, conveyance, force, vendor,N,
                       select,M-N, pending,N, afterselect,[on|off]
 -C, --captive
       Do test in captive mode (along with -t)
 -X, --abort
       Abort any non-captive test on device
============================================== SMARTCTL EXAMPLES
 smartctl -a disk0                            (Prints all SMART information)
 smartctl -t long /dev/disk0              (Executes extended disk self-test)
 smartctl --smart=on --saveauto=on /dev/rdisk0 (Enables SMART on first disk)
 smartctl --attributes --log=selftest --quietmode=errorsonly /dev/disk0
                                       (Prints Self-Test & Attribute errors)
 smartctl -a IOService:/MacRISC2PE/pci@f4000000/AppleMacRiscPCI/ata-6@D/AppleKauaiATA/ATADeviceNub@0/IOATABlockStorageDriver/IOATABlockStorageDevice
                                                (You can use IOService: ...)
 smartctl -c IODeviceTree:/pci@f4000000/ata-6@D/@0:0
                                                      (... Or IODeviceTree:)