Re: OT: finding damaged files on an XFS filesystem (Was Re: OT: fastest way to copy one drive to another)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 22Sep2018 14:09, Roger Heflin <rogerheflin@xxxxxxxxx> wrote:
If you have the original disk and can mount the filesystem then do this:

create a script like this and call it say /dir/testcatfile:
cat $1 > /dev/null
RC=$?
if [ ${RC} != 0 ] ; then
 echo "$1 is corrupt"
fi

Just a shell remark: because the shell considers any command to be a predicate, you can just go:

   cat "$1" >/dev/null || echo "$1 is corrupt"

i.e. assert the truth of the "cat" invocation (truth means success). Since "||" is short circuiting OR, just like C, the OR expression tries the first predicate (cat), and only tries the second if the first is false.

Truth or consequences.

chmod +x /dir/testcatfile

Then do this:
find /tmp -type f  -exec /dir/testcatfile {} \;

each file it gets an io error on will print out a message.

You can make this considerably faster via xargs:

 find /path/to/your/drive -type f -print0 \
 | xargs -0 cat -- >/dev/null 2>cat-errors.txt

which will try to cat everything in batches and report errors to "cat-errors.txt" for later review.

It should be substantially faster than the "find ... -exec script" version.

Cheers,
Cameron Simpson <cs@xxxxxxxxxx>
_______________________________________________
users mailing list -- users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/users@xxxxxxxxxxxxxxxxxxxxxxx



[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux