With a drying drive (that has more and more bad sectors), on an ext4-journaled partition, a
cp operation will sometimes complete without error, but the written data will either be wrong, or just won't be readable (Invalid Argument errors after reading part of it), just after the file was created.
Is there a file-system that would prevent such events (ZFS maybe)?
Or are there any command-line applications I could use instead of
cp, to check that the copied data is fine, before I remove the source?
I could just md5 both the source file, and the newly created file, but that sounds like a hack to me.
Update: I guess I didn't explain enough about why I'm asking this, and thus everyone assumed something that isn't.
I do not want to continue using this drive. This drive has been disconnected from the moment I noticed the problem. What I want is prevent what happened here from happening again with other drives.
I have a script that uses cp to regularly copy some files from drive1 to drive2, then from drive2 to drive3 soon after. The problem I faced was that cp didn't complain when it copied from drive1 to drive2, even though the data on drive2 was unreadable when it came time to copy it to drive3. At that point, my copy from drive1 was already deleted (because I needed free space, and my script didn't report any error, thus why I assumed the data on drive2 was OK). So I lost files.
So my question is: what is the best way to stop that from happening again in the future? Should I just use a file-system with checksums, or use a copy tool that does checksums itself?