Recuperando disco ext4

Primeiramente gostaria de salientar que não sou o autor principal do conteúdo deste artigo. A minha intenção é de mostrar o que outros autores tem realizado (referenciando links para o conteúdo original) neste blog até como um guia pessoal para uso próprio e ainda compartilhar minhas anotações e pequenas modificações que realizo no conteúdo, desejando que possa ajudar mais alguém em algum lugar.
First and foremost, I take no credit for any of this post’s content. I am really just taking what others have done (which I have links to bellow) and am putting it on my blog for a personal reference and hopefully the small changes that I made to their guides will help someone somewhere.


Before you start with anything like partition recover run:
fsck -t ext4 -b 32768 <device>

If that doesn't work try TestDisk, or Scalpel


Use any method to install the following package:


Run gnuddrescue like this:

ddrescue [options] infile outfile [logfile]

So, if /dev/sda is unreadable, you will need to acquire another disk (or other media) onto which to save the output image. You will need to have more room on the new media than on the failed disk.

sudo ddrescue -r 3 /dev/sda /media/usbdrive/image /media/usbdrive/logfile

Run successive passes like this:

sudo ddrescue -r 3 -C /dev/sda /media/usbdrive/image /media/usbdrive/logfile

and gnuddrescue will use the log file to only read the gaps with errors. In both cases, the -r option determines the number of times gddrescue will try to read when it encounters an error (-1 = infinity).

From Forensics Wiki:

First you copy as much data as possible, without retrying or splitting sectors:

  • ddrescue --no-split /dev/hda1 imagefile logfile 

Now let it retry previous errors 3 times, using uncached reads:

  • ddrescue --direct --max-retries=3 /dev/hda1 imagefile logfile 

If that fails you can try again but retrimmed, so it tries to reread full sectors:

  • ddrescue --direct --retrim --max-retries=3 /dev/hda1 imagefile logfile 

Other examples:

These two examples are taken directly from the ddrescue info pages. 

Example 1: Rescue an ext2 partition in /dev/hda2 to /dev/hdb2 

ddrescue -r3 /dev/hda2 /dev/hdb2 logfile
e2fsck -v -f /dev/hdb2
mount -t ext2 -o ro /dev/hdb2 /mnt

Example 2: Rescue a CD-ROM in /dev/cdrom 

ddrescue -b 2048 /dev/cdrom cdimage logfile 

write cdimage to a blank CD-ROM