Repairing a Defective Sector

September 18, 2008

Repairing a Defective Sector

If a disk on your system has a defective sector, you can repair it by following procedures in this section. You might become aware of defective sectors when you do the following:

  • Run surface analysis on a diskFor more information on the analysis feature of the format utility, see The analyze Menu.The defective area reported while your system is running might not be accurate. Since the system does disk operations many sectors at a time, it is often hard to pinpoint exactly which sector caused a given error. To find the exact sector(s), use How to Identify a Defective Sector by Using Surface Analysis.
  • Get multiple error messages from the disk driver concerning a particular portion of the disk while your system is running.Messages that are related to disk errors look like the following:
    WARNING: /io-unit@f,e0200000/sbi@0,0/QLGC,isp@1,10000/sd@3,0 (sd33):
    	Error for command 'read' Error Level: Retryable
    	Requested Block 126, Error Block: 179
    	Sense Key: Media Error
    	Vendor 'name':
    	ASC = 0x11 (unrecovered read error), ASCQ = 0x0, FRU = 0x0

    The preceding console message indicates that block 179 might be defective. Relocate the bad block by using the format utility’s repair command or use the analyze command with the repair option enabled.

ProcedureHow to Identify a Defective Sector by Using Surface Analysis

Become superuser or assume an equivalent role.

  1. Unmount the file system in the slice that contains the defective sector.
    # umount /dev/dsk/device-name

    For more information, see mount(1M).

  2. Invoke the format utility.
    # format
  3. Select the affected disk.
    Specify disk (enter its number):1
    selecting c0t2d0:
    [disk formatted]
    Warning: Current Disk has mounted partitions.
  4. Select the analyze menu.
    format> analyze
  5. Set up the analysis parameters by typing setup at the analyze> prompt. Use the parameters shown here:
    analyze> setup
    Analyze entire disk [yes]? n
    Enter starting block number [0, 0/0/0]: 12330
    Enter ending block number [2052287, 2035/13/71]: 12360
    Loop continuously [no]? y
    Repair defective blocks [yes]? n
    Stop after first error [no]? n
    Use random bit patterns [no]? n
    Enter number of blocks per transfer [126, 0/1/54]: 1
    Verify media after formatting [yes]? y
    Enable extended messages [no]? n
    Restore defect list [yes]? y
    Create defect label [yes]? y
  6. Use the read command to find the defect.
    analyze> read
    Ready to analyze (won't harm SunOS). This takes a long time,
    but is interruptible with Control-C. Continue? y
            pass 0
       2035/12/1825/7/24
            pass 1
    Block 12354  (18/4/18), Corrected media error (hard data ecc)
       25/7/24
    ^C
    Total of 1 defective blocks repaired.

ProcedureHow to Repair a Defective Sector

  1. Become superuser or assume an equivalent role.
  2. Invoke the format utility.
    # format
  3. Select the disk that contains the defective sector.
    Specify disk (enter its number): 1
    selecting c0t3d0
    [disk formatted]
    format>
  4. Select the repair command.
    format> repair
  5. Type the defective block number.
    Enter absolute block number of defect: 12354
       Ready to repair defect, continue? y
       Repairing block 12354 (18/4/18)...ok.
    format>

    If you are unsure of the format that is used to identify the defective sector, see How to Identify a Defective Sector by Using Surface Analysis for more information.

Tips and Tricks for Managing Disks

Use the following tips to help you manage disks more efficiently.

Debugging format Sessions

Invoke format -M to enable extended and diagnostic messages for ATA and SCSI devices.

In this example, the series of numbers under Inquiry: represent the hexadecimal value of the inquiry data that is displayed to the right of the numbers.

# format -M
Searching for disks...done
AVAILABLE DISK SELECTIONS:
  0. c0t1d0 <SUN1.05 cyl 2036 alt 2 hd 14 sec 72>
     /iommu@f,e0000000/sbus@f,e0001000/espdma@f,400000/esp@f,800000/sd@1,0
  1. c0t3d0 <SUN1.05 cyl 2036 alt 2 hd 14 sec 72>
     /iommu@f,e0000000/sbus@f,e0001000/espdma@f,400000/esp@f,800000/sd@3,0

Specify disk (enter its number): 0
selecting c0t3d0
[disk formatted]
format> inquiry
Inquiry:
00 00 02 02 8f 00 00 12 53 45 41 47 41 54 45 20     ........NAME....
53 54 31 31 32 30 30 4e 20 53 55 4e 31 2e 30 35     ST11200N SUN1.05
38 33 35 38 30 30 30 33 30 32 30 39 00 00 00 00     835800030209....
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00     ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00     ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00     ................
00 43 6f 70 79 72 69 67 68 74 20 28 63 29 20 31     .Copyright (c) 1
39 39 32 20 53 65 61 67 61 74 65 20 41 6c 6c 20     992 NAME    All
72 69 67 68 74 73 20 72 65 73 65 72 76 65 64 20     rights reserved
30 30 30                                            000
Vendor:   name
Product:  ST11200N SUN1.05
Revision: 8358
format>