Last active
May 21, 2021 18:32
-
-
Save gregjhogan/505a3782cf6cda6ec08b0adc83f36aba to your computer and use it in GitHub Desktop.
relocate bad block
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://wiki.archlinux.org/title/Identify_damaged_files#Force_the_disk_to_reallocate_bad_block | |
# scan entire disk for bad blocks (slow but complete) | |
sudo badblocks -v -b 4096 /dev/sda | |
# smartctl test find bad block (fast but not complete) | |
sudo smartctl -t short /dev/sda | |
# get block number of error | |
sudo smartctl -a /dev/sda | |
... | |
Num Test_Description Status Remaining LifeTime(hours) LBA_of_first_error | |
# 1 Short offline Completed: read failure 90% 41746 45093016 | |
... | |
# test reading bad block (should fail) | |
sudo hdparm --read-sector 45093016 /dev/sda | |
# write 0 (which should relocate) | |
sudo hdparm --repair-sector 45093016 --yes-i-know-what-i-am-doing /dev/sda | |
# repeat smartctl test find bad block | |
sudo smartctl -t short /dev/sda | |
# no more bad blocks | |
sudo smartctl -a /dev/sda | |
... | |
Num Test_Description Status Remaining LifeTime(hours) LBA_of_first_error | |
# 1 Short offline Completed without error 00% 41746 - | |
# 2 Short offline Completed: read failure 90% 41746 45093016 | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment