Saving data from “dying” HDD – LVM & ext3

Saving data from “dying” HDD – LVM & ext3

Posted by

Couple of days I restarted my machine running Debian Wheezy and for my surprise I was not able to boot. I was using encryption for the entire disk. I was able to unlock the disk but not able to mount the partitions. Nice … time to panic … After I took enough time panicking I decided that better start thinking practically and act according to my common sense. But first things first:

The error I’ve got was:

I/O error, dev sda, sector 504267
EXT3-fs (dm-1): error: can’t read group descriptor 7
mount: mounting /dev/mapper/epsian-root on /root failed: Invalid argument
mount: mounting /dev on /root/dev failed: No such file or directory
Target filesystem doesn’t have requested /sbin/init

Yep – doesn’t sound good. Here are the steps I took and the process I followed (it worked for me and I was able to save almost everything):

  1. Boot live linux distro (in my case Ubuntu from USB)
  2. run cryptsetup to unlock the driveTry to find your device with luksDump option – if it is a LUKS partition the following command will give you details about the partition like Cypher name and Cypher mode. In my case the disk was /dev/sd5
    # cryptsetup -v luksDump /dev/sda5Unlock the device (I assume that you now your password)
    # cryptsetup -v luksOpen /dev/sda5 sda5_crypt
  3. List the volumes
    # lvdisplay (I had only 2 – root and swap)
  4. start/enable your volume
    # vgchange -a y epsian
    If all is OK your lovume should be active
  5. try to run fsck to check your drive (for me this doesn’t work)
    # fsck /dev/mapper/epsian-root
    As a result of this operation I got
    fsck.ext3: Attempt to read block from filesystem resulted in short read while trying to open /dev/mapper/epsian-root
    Could this be a zero-length partition?

    So time for another approac
  6. create image of your drive with dd by telling the tool to ignore the bad blocks. That might take some time. My approximately 500GB HDD was imaged for about 9 hours to external USB 3 drive
    # dd if=/dev/mapper/epsian-root of=/media/exthdd/rescue.iso bs=64k conv=noerror,sync
  7. run fsck for the .iso file
    # fsck.ext3 /media/exthdd/rescue.iso
    For me the autorepare option -p didn’t work and i needed to answer countles number of questions with “yes”. There is another option -y which will assume that you answer with “yes” to all the questions. If you do not want to see and supervise the process I highly recommend using it.
  8. try to mount the iso file
    # mount /media/exthdd/rescue.iso /opt -o loop
  9. Save your files 🙂

That was my process. It might work for someone as well.

Leave a Reply

Your email address will not be published. Required fields are marked *