As reported by other sources, the drive needs to try to write to that area of the disk.
NB: This could be a warning sign of a drive failure (it's classified by Ubuntu and others as "old-age" and not "pre-fail", however).
0. Backup and remove important files from the disk
I'm using this in a NAS drive as part of my primary backup strategy, so I wanted to be absolutely sure that this drive is reliable. I backed up needed files and emptied out the drive for further testing (in case it failed the tests and files became unrecoverable).
0.5. Document SMART errors
You're fixing SMART errors, so take a photo etc. of what the SMART status is. In my case, I have errors in 0x197 and 0x198. My goal is to see 0x197 go down (to zero?) by writing every byte of the disk, thus triggering the drive to mark each sector as good or bad.
1. fsck
I used ubuntu live 24.04. I started the gui Disks app to determine the /dev/sdX/ location of the drive.
sudo fsck -yfv /dev/sdX1
y: for some filesystem-specific checkers, the -y option will cause the fs-specific fsck to always
attempt to fix any detected filesystem corruption automatically. Sometimes an expert may be able
to do better driving the fsck manually. Note that not all filesystem-specific checkers implement
this option. In particular fsck.minix(8) and fsck.cramfs(8) do not support the -y option as of
this writing.
f: Force checking even if the file system seems clean.
v: Verbose mode.
I got:
Inode 18 extent tree (at level 2) could be narrower. Optimize? yes [from -y]
[snip]
/lost+found not found. Create? yes
2. Write empty files to disk
Mount the drive (I used Ubuntu Disks).
# cding to the path makes the dd command simpler
cd /path/to/drive
dd if=/dev/zero bs=8M count=$((1*1024*1024)) | dd of=emptyfile.bin bs=8M
dd = copy a file
dev/zero = empty bytes
bs = block size (allegedly fastest, per SE; but this is drive and phase of moon specific, feel free to do your own tests)
count = 1 TB
of = filename
bs = block size
I monitored that the transfer was working through System Monitor and listening to HDD sounds of the computer. You could probably use iotop on the terminal. I got 80+ MBps which is only a bit below the 100-150 I might see on a good day. It's fast enough for me to not try to fix it.
3. Confirm SMART fix
This is theoretical for me so far. After filling the disk (7.9 TB total, 7.5 TB used, 0 bytes free) I see the same results.
At some point, I got 0x05 Reallocated Sector Count up to 1 from 0. Ubuntu Disks shows 417 bad sectors but the pending sector count is 416.
I've tried a SMART self test (quick) but haven't noticed any changes.
Notes
I originally filled 7 of the 8 terabytes without fsck. But I kept getting no space left on device
. Fsck allowed me to continue. This drive was pulled from an OpenMediaVault 5.x install and it's possible that the extant tree error started there.
https://serverfault.com/questions/786648/when-is-fsck-dangerous
Difference between S.M.A.R.T. error 0x05 (Reallocated sector) and 0xC6 (Uncorrectable sector)
https://superuser.com/a/882216
chkdsk /f /r
in windows or fsck/e2fsck in linux. after running them the pending sector count should drop to zero, and (hopefully) the reallocated sector count will go up. Note however that if your reallocated sector count is more than a few, and grows at more than a trickle, you should probably stop trusting the disk. Bad sectors tend to grow exponentially to time, and are a critical indicator of disk health.