Commands to check Hard disk information and diagnostic

Solution Verified - Updated

Environment

  • Red Hat Enterprise Linux

Issue

  • What are the commands to see hard drive or LUN information
  • How to diagnose a hard drive problem using command line

Resolution

  • 'badblocks' command will be useful to check if there are any bad sectors present in the disk. But this can cause filesystem corruption on a live system. So always umount the filesytem before you run this command and make sure you have a known good backup of your data.

      # badblocks -n -vv /dev/sdX 
    

    See "How can I determine hard disk I/O errors are an issue in Red Hat Enterprise Linux?" for more information

  • smartctl tool will be helpful to find if hard disks are failing,

    See "How can I test if my hard disk is going bad?" for more information on smartctl

    # smartctl -d scsi -a /dev/sdi 
           
    === START OF INFORMATION SECTION ===
    Vendor:               COMPELNT
    Product:              Compellent Vol
    Revision:             0606
    User Capacity:        10,737,418,240 bytes [10.7 GB]
    Logical block size:   512 bytes
    LU is thin provisioned, LBPRZ=1
    Rotation Rate:        15000 rpm
    Logical Unit id:      0x6000d310032ca600000000000000000e
    Serial number:        00032ca6-0000000e
    Device type:          disk
    Local Time is:        Wed Oct 17 13:38:38 2018 CST
    SMART support is:     Available - device has SMART capability.
    SMART support is:     Disabled
    Temperature Warning:  Disabled or Not Supported
              
     === START OF READ SMART DATA SECTION ===
     SMART Health Status: OK
                 
    Error Counter logging not supported
                 
                  
    [GLTSD (Global Logging Target Save Disable) set. Enable Save with '-S on']
    Device does not support Self Test logging
    
  • ListHardware tool will be efficient to find more details on the disk.

lshw -c storage -c disk

*-usb:0
description: Mass storage device
product: USB3.0-CRW
vendor: Generic
physical id: 3
bus info: usb@2:3
logical name: scsi13
version: 2.04
serial: 20120501030900000
capabilities: usb-3.00 scsi emulated scsi-host
configuration: driver=usb-storage maxpower=800mA speed=5000Mbit/s
*-disk
description: SCSI Disk
product: SD/MMC
vendor: Generic-
physical id: 0.0.0
bus info: scsi@13:0.0.0
logical name: /dev/sda
version: 1.00
serial: 2012090114345300
capabilities: removable
configuration: ansiversion=6 logicalsectorsize=512 sectorsize=512
*-medium
physical id: 0
logical name: /dev/sda
*-storage
description: Non-Volatile memory controller
product: NVMe SSD Controller SM961/PM961
vendor: Samsung Electronics Co Ltd
physical id: 0
bus info: pci@0000:3c:00.0
version: 00
width: 64 bits
clock: 33MHz
capabilities: storage pm msi pciexpress msix nvm_express bus_master cap_list
configuration: driver=nvme latency=0
resources: irq:16 memory:ec000000-ec003fff

  • hdparm command is used to set or get various SATA/IDE device parameters. Refer the manual pages of hdparm for more details man hdparm.

      The `-H` option is used to read  the temperature from some (mostly Hitachi) drives.
                
      # hdparm -H /dev/sda
                    
      /dev/sda:
      SG_IO: bad/missing sense data, sb[]:  70 00 05 00 00 00 00 0d 00 00 00 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
       drive temperature (celsius) is:  under -20
       drive temperature in range:  yes
    
  • sg_inq command by default sends a SCSI INQUIRY command to the given device and then outputs the response.

    # sg_inq /dev/sdb 
    standard INQUIRY:
      PQual=0  Device_type=0  RMB=0  version=0x05  [SPC-3]
        [SPI: Clocking=0x0  QAS=0  IUS=0]
        length=255 (0xff)   Peripheral device type: disk
     Vendor identification: COMPELNT
     Product identification: Compellent Vol  
     Product revision level: 0606
     Unit serial number: 00032ca6-00000016    
    
  • Check from /sys filesytem for various parameter of a device where sdX is a LUN or individual hard drive.

    # cat /sys/block/sdi/device/model 
    Compellent Vol  
    
  • Server log files such as /var/log/dmesg , /var/log/messages record the errors if any medium or I/O error or Hardware error occur. Referring these files will help to identify the disk details.

  • A success status of any of the above is not equivalent to no problems but rather you'd need to run {vendor specific} hardware diagnostics to have more confidence that there isn't a problem.*

SBR
Components
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.