Examples[edit]
https://www.smartmontools.org/wiki/BadBlockHowto describes how to handle bad blocks by using the tools manually. The script fixbad on this page helps to automate this process.
Please find below some examples for the usage of the script.
disk Digda[edit]
Where is it mounted?[edit]
sudo mount | grep Digda
/dev/sdb1 on /media/wf/Digda type ext2 (rw,nosuid,nodev,relatime,uhelper=udisks2)
get basic info and check[edit]
get basic info
- using fixbad -i
- using smartctl -i
- using hdparm -I
see the details below
check:
fixbad /dev/sdb -c
checking Current_Pending_Sector count for /dev/sdb partition /dev/sdb1 blocksize 4096 startsector
197 Current_Pending_Sector 0x0032 252 252 000 Old_age Always - 0
Current_Pending_Sector is zero!
So this drive has no bad block issues.
The fixbad script tries to summarize the most important information for the bad block fixing needs.
fixbad /dev/sdb -i
Model Family: SAMSUNG SpinPoint F4 EG (AF)
Device Model: SAMSUNG HD204UI
Serial Number: S2H7J9EZC04171
User Capacity: 2,000,398,934,016 bytes [2.00 TB]
Sector Size: 512 bytes logical/physical
Rotation Rate: 5400 rpm
Model Number: SAMSUNG HD204UI
Serial Number: S2H7J9EZC04171
Partition: /dev/sdb1
Blocksize: 4096
smartctl[edit]
sudo smartctl -i /dev/sdb
smartctl 6.6 2016-05-31 r4324 [x86_64-linux-4.15.0-72-generic] (local build)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF INFORMATION SECTION ===
Model Family: SAMSUNG SpinPoint F4 EG (AF)
Device Model: SAMSUNG HD204UI
Serial Number: S2H7J9EZC04171
LU WWN Device Id: 5 0024e9 203f40fb7
Firmware Version: 1AQ10001
User Capacity: 2,000,398,934,016 bytes [2.00 TB]
Sector Size: 512 bytes logical/physical
Rotation Rate: 5400 rpm
Form Factor: 3.5 inches
Device is: In smartctl database [for details use: -P show]
ATA Version is: ATA8-ACS T13/1699-D revision 6
SATA Version is: SATA 2.6, 3.0 Gb/s
Local Time is: Mon Oct 5 11:41:44 2020 CEST
==> WARNING: Using smartmontools or hdparm with this
drive may result in data loss due to a firmware bug.
****** THIS DRIVE MAY OR MAY NOT BE AFFECTED! ******
Buggy and fixed firmware report same version number!
See the following web pages for details:
http://knowledge.seagate.com/articles/en_US/FAQ/223571en
http://www.smartmontools.org/wiki/SamsungF4EGBadBlocks
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
sudo hdparm -I /dev/sdb
/dev/sdb:
ATA device, with non-removable media
Model Number: SAMSUNG HD204UI
Serial Number: S2H7J9EZC04171
Firmware Revision: 1AQ10001
Transport: Serial, ATA8-AST, SATA 1.0a, SATA II Extensions, SATA Rev 2.5, SATA Rev 2.6
Standards:
Used: unknown (minor revision code 0x0028)
Supported: 8 7 6 5
Likely used: 8
Configuration:
Logical max current
cylinders 16383 16383
heads 16 16
sectors/track 63 63
--
CHS current addressable sectors: 16514064
LBA user addressable sectors: 268435455
LBA48 user addressable sectors: 3907029168
Logical Sector size: 512 bytes
Physical Sector size: 512 bytes
device size with M = 1024*1024: 1907729 MBytes
device size with M = 1000*1000: 2000398 MBytes (2000 GB)
cache/buffer size = unknown
Form Factor: 3.5 inch
Nominal Media Rotation Rate: 5400
Capabilities:
LBA, IORDY(can be disabled)
Queue depth: 32
Standby timer values: spec'd by Standard, no device specific minimum
R/W multiple sector transfer: Max = 16 Current = ?
Advanced power management level: disabled
Recommended acoustic management value: 254, current value: 0
DMA: mdma0 mdma1 *mdma2 udma0 udma1 udma2 udma3 udma4 udma5 udma6
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:
* SMART feature set
Security Mode feature set
* Power Management feature set
* Write cache
* Look-ahead
* Host Protected Area feature set
* WRITE_BUFFER command
* READ_BUFFER command
* NOP cmd
* DOWNLOAD_MICROCODE
Advanced Power Management feature set
Power-Up In Standby feature set
* SET_FEATURES required to spinup after power up
SET_MAX security extension
Automatic Acoustic Management feature set
* 48-bit Address feature set
* Device Configuration Overlay feature set
* Mandatory FLUSH_CACHE
* FLUSH_CACHE_EXT
* SMART error logging
* SMART self-test
* General Purpose Logging feature set
* 64-bit World wide name
* WRITE_UNCORRECTABLE_EXT command
* {READ,WRITE}_DMA_EXT_GPL commands
* Segmented DOWNLOAD_MICROCODE
* Gen1 signaling speed (1.5Gb/s)
* Gen2 signaling speed (3.0Gb/s)
* Native Command Queueing (NCQ)
* Host-initiated interface power management
* Phy event counters
* NCQ priority information
DMA Setup Auto-Activate optimization
Device-initiated interface power management
* Software settings preservation
* SMART Command Transport (SCT) feature set
* SCT Read/Write Long (AC1), obsolete
* SCT Write Same (AC2)
* SCT Error Recovery Control (AC3)
* SCT Features Control (AC4)
* SCT Data Tables (AC5)
Security:
Master password revision code = 65534
supported
not enabled
not locked
not frozen
not expired: security count
supported: enhanced erase
344min for SECURITY ERASE UNIT. 344min for ENHANCED SECURITY ERASE UNIT.
Logical Unit WWN Device Identifier: 50024e9203f40fb7
NAA : 5
IEEE OUI : 0024e9
Unique ID : 203f40fb7
Checksum: correct
disk wendi[edit]
Where is it mounted?[edit]
sudo mount | grep wendi
/dev/sdb1 on /media/wf/wendi type ext3 (rw,nosuid,nodev,relatime,data=ordered,uhelper=udisks2)
get basic info and check[edit]
fixbad /dev/sdb -i -c
Model Family: SAMSUNG SpinPoint F4 EG (AF)
Device Model: SAMSUNG HD204UI
Serial Number: S2H7J9EZB05266
User Capacity: 2,000,398,934,016 bytes [2.00 TB]
Sector Size: 512 bytes logical/physical
Rotation Rate: 5400 rpm
Model Number: SAMSUNG HD204UI
Serial Number: S2H7J9EZB05266
Partition: /dev/sdb1
Blocksize: 4096
checking Current_Pending_Sector count for /dev/sdb partition /dev/sdb1 blocksize 4096 startsector
197 Current_Pending_Sector 0x0032 252 252 000 Old_age Always - 0
Current_Pending_Sector is zero!
disk riako[edit]
check for bad sectors
fixbad /dev/sdb -i -c
Model Family: Western Digital Green
Device Model: WDC WD40EZRX-00SPEB0
Serial Number: WD-WCC4E3LNJA7X
User Capacity: 4,000,787,030,016 bytes [4.00 TB]
Sector Sizes: 512 bytes logical, 4096 bytes physical
Rotation Rate: 5400 rpm
Model Number: WDC WD40EZRX-00SPEB0
Serial Number: WD-WCC4E3LNJA7X
Partition: /dev/sdb1
Blocksize: 4096
checking Current_Pending_Sector count for /dev/sdb partition /dev/sdb1 blocksize 4096 startsector 2048
197 Current_Pending_Sector 0x0032 200 200 000 Old_age Always - 30
Current_Pending_Sector is not zero but 30
running short smartctl test for /dev/sdb ...
find defect file system block
fixbad /dev/sdb -x
1 Short offline
progress: 90%
lba: 1374590864
file system block: 171823602
2 Selective offline
progress: 50%
lba: 1374590880
file system block: 171823604
use debugfs to find corresponding file
sudo debugfs /dev/sdb1
debugfs 1.44.1 (24-Mar-2018)
debugfs: testb 171823602
Block 171823602 marked in use
debugfs: icheck 171823602
Block Inode number
171823602 61244964
debugfs: ncheck 61244964
Inode Pathname
61244964 /vmware/carme10/Windows 10 x64-s006.vmdk
write sectors - this is the dangerous part protected by having to enter the serial number of the disk!
fixbad /dev/sdb -r 16 -s WD-WCC4E3LNJA7X -f -x
1 Extended offline
progress: 90%
lba: 1374590889
file system block: 171823605
repairing sector 1374590889 to 1374590889+16 on /dev/sdb ...
4 Short offline
progress: 90%
lba: 1374590864
file system block: 171823602
repairing sector 1374590864 to 1374590864+16 on /dev/sdb ...
5 Selective offline
progress: 50%
lba: 1374590880
file system block: 171823604
repairing sector 1374590880 to 1374590880+16 on /dev/sdb ...
disk hypno[edit]
get device info and check for pending sectors[edit]
fixbad /dev/sdb -i -c
Model Family: Western Digital Green
Device Model: WDC WD30EZRX-00D8PB0
Serial Number: WD-WMC4N0H2L71F
User Capacity: 3,000,592,982,016 bytes [3.00 TB]
Sector Sizes: 512 bytes logical, 4096 bytes physical
Rotation Rate: 5400 rpm
Model Number: WDC WD30EZRX-00D8PB0
Serial Number: WD-WMC4N0H2L71F
Partition: /dev/sdb1
Blocksize: 4096
checking Current_Pending_Sector count for /dev/sdb partition /dev/sdb1 blocksize 4096 startsector 2048
197 Current_Pending_Sector 0x0032 199 066 000 Old_age Always - 844
Current_Pending_Sector is not zero but 844
running short smartctl test for /dev/sdb ...
do a selective test as a dry run[edit]
wait for the test result[edit]
fixbad /dev/sdb -v -w selective
: 1 1 5860533167 Self_test_in_progress [10% left] (5196737056-5196802591)
Completed: 1 1 5860533167 Completed_read_failure [10% left] (5196737056-5196802591)
cautiously start trying the repair[edit]
dry run[edit]
wf@fur:~/source/bash/mp$ fixbad /dev/sdb -d --try
attempting to fix sector 5196802591 on /dev/sdb
repairing sector 5196802591 to 5196802591+8 on /dev/sdb ...
hdparm --repair-sector 5196802591 --yes-i-know-what-i-am-doing /dev/sdb
hdparm --repair-sector 5196802592 --yes-i-know-what-i-am-doing /dev/sdb
hdparm --repair-sector 5196802593 --yes-i-know-what-i-am-doing /dev/sdb
hdparm --repair-sector 5196802594 --yes-i-know-what-i-am-doing /dev/sdb
hdparm --repair-sector 5196802595 --yes-i-know-what-i-am-doing /dev/sdb
hdparm --repair-sector 5196802596 --yes-i-know-what-i-am-doing /dev/sdb
hdparm --repair-sector 5196802597 --yes-i-know-what-i-am-doing /dev/sdb
hdparm --repair-sector 5196802598 --yes-i-know-what-i-am-doing /dev/sdb
get serial number for write operation protection removal[edit]
fixbad /dev/sdb -s
WD-WMC4N0H2L71F
use serial number and -f parameter to execute fix[edit]
wf@fur:~/source/bash/mp$ fixbad /dev/sdb -s WD-WMC4N0H2L71F -f --try
attempting to fix sector 5196802591 on /dev/sdb
repairing sector 5196802591 to 5196802591+8 on /dev/sdb ...
cat /tmp/smart_repaired.log
/dev/sdb:
re-writing sector 5196802591: succeeded
/dev/sdb:
re-writing sector 5196802592: succeeded
/dev/sdb:
re-writing sector 5196802593: succeeded
/dev/sdb:
re-writing sector 5196802594: succeeded
/dev/sdb:
re-writing sector 5196802595: succeeded
/dev/sdb:
re-writing sector 5196802596: succeeded
/dev/sdb:
re-writing sector 5196802597: succeeded
/dev/sdb:
re-writing sector 5196802598: succeeded