As the title says, I am concerning about, how can we avoid data loss due to harddisk (either mechanical HDD or SSD) bad sectors.
\ More information \
Question is well defined. Question ends here. Let me try to provide more information. Storage device failure (hardware failure, excluding virus thingy first) mainly split into two types.
Entire disk fault. Anything mechanically and/or electronically goes wrong inside the disk, makes the disk not accessible.
Bad sector. Only a certain part is fault. The entire disk appears to be working fine. If that certain bad sector is not accessed/checked, we will never know there is a bad sector.
\ RAID cannot avoid data loss due to bad sectors \
RAID1, RAID5 or RAID6 can avoid data loss due to case 1. However, as far as I know, standard RAID will not scan and check all the data regularly, which means RAID cannot avoid data loss due to case 2. For example, in the case of RAID1 mirror. If a bad sector appears in the first disk, a file is corrupted in the first disk. At that time, we still have the mirrored file in the second disk. But we do not know there is a bad sector. Thus, the RAID1 array will not indicate a disk fault, and will not trigger a recovery. Then time goes on and on, more and more bad sectors appears. (Every hardware worn out, it is just a matter of time.) There is definitely a chance that the exact mirrored bit / mirrored part in the second disk suffer from a bad sector too. At this time, there are no more redundant copies. The affected data will be loss forever. Similarly, we will not notice this immediately. We will only find out this loss until we access that piece of data.
\ Is ZFS (a filesystem with checksum) a solution? \
Because of the concern that I wish to avoid data loss due to bad sectors, I started looking into the file checksum thingy. It seems that not many popular filesystems include checksum of every file. I have some knowledge with Gentoo Linux. Thus I am planning to use ZFS on Gentoo Linux.
The ideas of ZFS that "Administration of storage should be simple" and "Redundancy should be handled by the filesystem" are good. It seems to me that if a bad sector occurs in a ZFS disk, it will recovery it silently (Isn't it? I cannot confirm this yet). If more and more bad sectors arise in a ZFS disk, does it mean the size of that ZFS disk will shrink? If not, how can I notice when a bad sector happens? How do I know when the harddisk bad sectors are too many and I have to replace it with another healthy harddisk? I guess I need some ZFS monitors and ZFS utilities, which I cannot find much information on the Internet.