viper25

Recover data network drive (Linux + ddrescue)

Nov 19th, 2014
345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.21 KB | None | 0 0
  1. #Scan drives and re-create a partition table based on "guesses"
  2. sudo gpart /dev/sdc  
  3.  
  4. #Use the following commands to interrogate the drive:
  5.  
  6. dmesg
  7. sudo fdisk OR sudo fdisk -l
  8. sudo blkid
  9. lsblk
  10. mount
  11. lsusb
  12. usb-devices
  13. df -h
  14.  
  15. #Track logs to see mount errors. If all ok, proceed to mount (next step)
  16. tail -f /var/log/{kernel,dmesg,syslog}
  17.    
  18. #Mount a windows share to copy the backups to. Mount this drive (/media/ubuntu/casper-rw/jkmount) onto the target folder (in this case a folder on the network). This would be slow though. Faster is to use a USB disk
  19. sudo mount -t cifs //192.168.0.103/backups/laptop /media/ubuntu/casper-rw/jkmount -o username=admin,noexec
  20.  
  21. #List drives
  22. sudo fdisk -l
  23.  
  24. #Run disk mirror script
  25. sudo dd if=/dev/sda of=/media/ubuntu/casper-rw/jkmount/disk1.img bs=4M
  26. #Alternatively run ddrescue. GNU ddrescue is not a derivative of dd, nor is related to dd in any way except in that both can be used for copying data from one device to another. The key difference is that ddrescue uses a sophisticated algorithm to copy data from failing drives causing them as little additional damage as possible. It dumps all readable sectors to a file. If it hangs up on a huge chunk of bad sectors, you can run ddrescue backwards, reading the end of the disk toward the beginning. Then run SpinRite on the drive to see if it can recover any of the failed sectors. Run ddrescue again, which will only attempt the failed sectors from the first run. Finally, run the actual recovery software on the resulting image file.
  27. #Provide a log file so that you can resume ddrescue from the point it stopped. the r parameter is the number of retry passes the tool needs to do over bad sectors.
  28. sudo ddrescue -d -r3 /dev/sda media/ubuntu/casper-rw/jkmount/disk1.img /home/user/recovery.log
  29. #Recover directly to another disk
  30. ddrescue -d -f -r3 /dev/sda /dev/sdb /media/PNY_usb/rescue.logfile
  31.  
  32. #parse the log file using:
  33. ddrescuelog -t recovery.log
  34. #See the "rescued" entry to see how much data was recovered.
  35.  
  36. #Unmount
  37. sudo umount ~/mnt
  38.  
  39. #Restore using dd or ddrescue
  40. sudo dd if=/mnt/nas_tv/backup.img of=/dev/sda status=progress
  41.  
  42. www.howtogeek.com/howto/19446/make-a-drivea-image-using-an-ubuntu-live-cd/?PageSpeed=noscript
Advertisement
Add Comment
Please, Sign In to add comment