[Techtalk] finding bad files

James Sutherland james at deadnode.org
Mon Apr 13 18:34:21 UTC 2015


On Mon, Apr 13, 2015, at 05:37 PM, A. Mani wrote:
> On Mon, Apr 13, 2015 at 8:10 PM, Miriam English <mim at miriam-english.org>
> wrote:
> > My next thought was that I could do a fake copy of the files on the drive
> > out to /dev/null and log the standard output and standard error streams but
> > /dev/null can't handle writing directories.
> >
> > Any ideas?
> 
> cat

tar will do this quite neatly. Since it's probably a dying disk, you
could recover all the good files somewhere else at the same time:

tar cf - . | ( cd /media/newdisk/ ; tar xf - )

This will copy all the files it can over to /media/newdisk and report
errors on the console as it goes, killing two birds with one stone. Or,
for a simple file listing in ~/badfiles.txt:

tar cf - . > /dev/null 2> ~/badfiles.txt

Since it's probably a dying drive, using a tool like ddrescue to recover
everything you can to a fresh drive/partition is best. Wiping the drive
(overwriting everything) would make the drive map out all the bad
sectors it can - but when a drive starts giving errors like this, it's
probably too far gone to remap all the sectors affected.


James.


More information about the Techtalk mailing list