catkin,
Thank you for the good suggestions. Yes, I had read the smartmontools article before coming here. Yeah, it's not trivial, and I wondered if there might be an easy solution.
Below is the dumps for the worried drive. The bad sector seems to lie at the beginning of /dev/sd3 which is a part of a software RAID5 volume (/dev/md2). Fortunately, this volume is only for a backup repository file system and it can be easily set off-line (unmounted). So, I think running a simple program like the following on the first few thousand sectors can detect and trigger auto-remapping of the disk. Do you think I am correct?
fd = open("/dev/sda3", O_RDWR);
for (i = 0; i < 10000; i++) {
n = read(fd, buf, 512);
if (!n) break;
if (n != 512) {
fprintf(stderr, "Bad sector (%d)\n", i);
lseek(fd, -512, SEEK_CUR);
write(fd, buf, 512);
}
}
Thanks,
hiro
[root@shadow ~]# smartctl -l selftest /dev/sda
smartctl 5.39.1 2010-01-28 r3054 [i386-redhat-linux-gnu] (local build)
Copyright (C) 2002-10 by Bruce Allen,
http://smartmontools.sourceforge.net
=== START OF READ SMART DATA SECTION ===
SMART Self-test log structure revision number 1
Num Test_Description Status Remaining LifeTime(hours) LBA_of_first_error
# 1 Extended offline Completed without error 00% 1515 -
# 2 Extended offline Completed without error 00% 1499 -
# 3 Extended offline Completed: read failure 80% 1473 98047576
# 4 Extended offline Aborted by host 10% 1472 -
# 5 Short offline Completed without error 00% 1446 -
[root@shadow ~]# fdisk -lu /dev/sda
Disk /dev/sda: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders, total 3907029168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00042339
Device Boot Start End Blocks Id System
/dev/sda1 * 63 385559 192748+ fd Linux raid autodetect
/dev/sda2 385560 98044694 48829567+ fd Linux raid autodetect
/dev/sda3 98044695 3893609789 1897782547+ fd Linux raid autodetect
/dev/sda4 3893610496 3907028991 6709248 5 Extended
/dev/sda5 3893614592 3894638591 512000 82 Linux swap / Solaris