Guest User

Untitled

a guest
Jun 21st, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #
  2. # Finds all files in your filesystem and attempts to read all the blocks
  3. # referenced by the file. Files that contain bad blocks are noted in stdout.
  4. # Run as superuser.
  5. #
  6.  
  7. #!/bin/bash
  8.  
  9. count=0
  10.  
  11. echo "Finding all files..."
  12. find / -type f > /tmp/files
  13. total=`wc -l /tmp/files | awk '{print $1}'`
  14.  
  15. echo "Reading all files..."
  16. cat /tmp/files | while read -r file
  17. do
  18. let count=$count+1
  19. let mod=$count%1000
  20. if [ $mod -eq 0 ]
  21. then
  22. echo $count/$total
  23. fi
  24.  
  25. if [ -f "$file" ]; then
  26. dd if="$file" of=/dev/null > /dev/null 2>&1
  27. fi
  28.  
  29. if [ $? -ne 0 ]
  30. then
  31. echo Bad blocks found in: $file;
  32. fi
  33. done
Add Comment
Please, Sign In to add comment