Broken Disk - Try to recover data
If your disk seems to be broken, grub is taking a very long time to start,
and when you try to start your linux you receive the following errors:
[ 729.867659] sd 0:0:0:0: [sda] Unhandled sense code
[ 729.867661] sd 0:0:0:0: [sda] Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE
[ 729.867665] sd 0:0:0:0: [sda] Sense Key : Medium Error [current] [descriptor]
[ 729.867669] Descriptor sense data with sense descriptors (in hex):
[ 729.867671] 72 03 11 04 00 00 00 0c 00 0a 80 00 00 00 00 00
and finally your kernel doesn't boot. If you try to mount your file system in a live distro and it says that your fs is damaged and an fsck from that live give you an error message like this:
Error reading block xxxxxx (Attempt to read block from filesystem resulted in a short read )
and finally the bios disk check fails, and you feel doomed: EVERYTHING LOST!
This guide is what you are looking for :D (in my case with all these errrors i saved everything that was on the disk).
So let's start
First of all you need to download: a special distro created for that purpose:
- System Rescue CD
and you need also:
- A drive that has free space enough to contain a file big as the partition you are trying to rescue
Once you created a cd and booted into that system (it is obviously a live system) you have to type the following command:
dd_rescue /dev/sdXY /path/to/dumpfile.img -l rescue.log
Where:
- /dev/sdXY is your borken device partition that you need to recover
- dumpfile is the file that will contain the partition rescued. The file should be stored into an external drive with enough space.
- -l rescue.log is a log! :)
Once finished the log should be similar to that:
dd_rescue: (warning): read /dev/sda5 (29856055.0k): Success!
Bad block reading /dev/sda5: 59712110
dd_rescue: (info): ipos: 29856055.5k, opos: 29856055.5k, xferd: 29856055.5k
* errs: 15, errxfer: 7.5k, succxfer: 29856048.0k
+curr.rate: 0kB/s, avg.rate: 12530kB/s, avg.load: 8.3%
>x--------------------------x.............< 68% ETA: 0:18:16
Then you create a loopdevice to handle the dumpfile:
losetup /dev/loop0 path/to/dumpfile.img
then check the filesystem:
fsck -y /dev/loop0
Using -y parameter you say to fsck to assume yes to every question of the tool. (In a fs with many errors you can expect a huge amount of questions :) )
Then once fsck is finished try to mount the loopdevice:
mount -t fstype /dev/loop0 /mnt/disk
Where fstype is the filesystem type of the partition you rescued.
If you are lucky enough now you have recovered all your data from the broken fs/disk.
P.s. Probably my english is not very good :) I'm sorry :)