Home News Documentation Download Screenshots Credits Help

Intro [^]

Deleted or "lost" files can be recovered from failed or formatted drives and partitions, cdroms and memory cards using the software available in SystemRescueCD. Unless you can rule out hardware failure, you must not write to the failed device. The following software will passively try to recover your data from failed or failing hardware. If your data is not replaceable, do not attempt to write to the failed device if the following applications do not work but seek professional advice instead.

If your device is damaged, it is advisable to image the device and work on the image file for data recovery. If hardware failure is not the problem, you can recover data directly from the device.

To recover data from a failed device, you will need another device of equal or greater storage capacity onto which to save your data. If you need to make an image of the failed device, you will need yet another quantity of space.

I should state here, that I haven't used any of these tools recently (other than plain and simple dd, a long time ago, which I found to be very slow), so I couldn't recommend any of them. Any comments on a tool's usability found in this page, is just what I found on the Net.

Partition recovery [^]

If you made a mistake while partitioning and the partition no longer appears in the partition table, so long as you have not written data in that space, all your data is still there and can be restored.

When changing the partition table on your hard drive, you must ensure that no partition on the disk is mounted. This includes swap space. In order to restore your partition, execute:

swapoff -a
parted /dev/old_disk

Then, use the rescue option:

rescue START END

where START is the area of the disk where you believe the partition began and END is it's end. If parted finds a potential partition, it will ask you if you want to add it to the partition table.

Note: TestDisk can also be used to recover a "lost" partition.

Disk / files recovery [^]

Using dd [^]

In order to duplicate a disk to another disk, execute

dd if=/dev/old_disk of=/dev/new_disk conv=noerror,sync

or to create an image file

dd if=/dev/old_disk of=image_file conv=noerror

Be careful, if you are copying a disk, the destination must also be a disk, not a partition. If you are copying a partition, the destination partition must be large enough. Copying the whole disk is recommended.

To speed up the copy process, you can append bs=8k, it will read/write the disk by 16 sectors at a time.

Using dd_rescue [^]

Like dd, dd_rescue does copy data from one file or block device to another. You can specify file positions (called seek and skip in dd). There are several differences:

In order to duplicate a disk to another disk, execute

dd_rescue -A -v /dev/old_disk /dev/new_disk

or to create an image file

dd_rescue -A -v /dev/old_disk image_file

The copying should go very quickly until it hits a bad sector and then it will slow down to take smaller chunks of data. People have reported very good results with this technique.

Using GNU ddrescue [^]

The GNU site describes GNU ddrescue as a data recovery tool, and lists these features:

The algorithm of GNU ddrescue is as follows:

  1. Optionally read a log file describing the status of a multi-part or previously interrupted rescue.
  2. Read the non-damaged parts of the input file, skipping the damaged areas, until the requested size is reached, or until interrupted by the user.
  3. Try to read the damaged areas, splitting them into smaller pieces and reading the non-damaged pieces, until the hardware block size is reached, or until interrupted by the user.
  4. Try to read the damaged hardware blocks until the specified number of retries is reached, or until interrupted by the user.
  5. Optionally write a log file for later use.

Note: GNU ddrescue is considered to be the best recovery tool available.

In order to duplicate a disk to another disk, execute

ddrescue -vr3 /dev/old_disk /dev/new_disk logfile

or to create an image file

ddrescue -vr3 /dev/old_disk image_file logfile

If the disk is failing fast and you want to get the most data out of it on the first try, you should probably use "-n" on the first run. This will avoid splitting error areas. Subsequent runs can use "-r1" or "-r3", without "-n", to retry those error areas.

To summarise, we execute:

ddrescue -vn /dev/old_disk image_file logfile
ddrescue -v -r3 -C /dev/old_disk image_file logfile

Note: When working with CD-ROMs you should probably specific "-b 2048"

Using Foremost [^]

Foremost is a console program to recover files based on their headers, footers, and internal data structures. This process is commonly referred to as data carving. Foremost can work on image files, such as those generated by dd, Safeback, Encase, etc, or directly on a drive. The headers and footers can be specified by a configuration file or you can use command line switches to specify built-in file types. These built-in types look at the data structures of a given file format allowing for a more reliable and faster recovery.

It can be run on an image file created with any of the above tools, to extract files:

foremost -i image -o /recovery/foremost

Foremost can be instructed to recover only specific file types, using the -t command line parameter. In the following example Foremost will extract only jpg files:

foremost -t jpg -i image -o /recovery/foremost

Available types are: jpg, gif, png, bmp, avi, exe (Windows binaries and DLLs), wav, riff, wmv (will extract wma also), mov, pdf, ole (will extract any file using the OLE file structure; this includes PowerPoint, Word, Excel, Access, and StarWriter), doc, zip (will extract .jar files and Open Office docs as well; this includes SXW, SXC, SXI, and SX? for undetermined OpenOffice files), rar, html and cpp.

Using TestDisk [^]

TestDisk was primarily designed to help recover "lost" partitions and/or make non-booting disks bootable again when these symptoms are caused by faulty software, certain types of viruses or human error (such as accidentally deleting a Partition Table). Partition table recovery using TestDisk is really easy.

TestDisk can

Some great tutorials are available at TestDisk's site: "TestDisk Step By Step", "Running TestDisk", "Data Recovery Examples" etc.

Using PhotoRec [^]

PhotoRec is file data recovery software designed to recover "lost" files including video, documents and archives from Hard Disks and CDRom and "lost" pictures (thus, its 'Photo Recovery' name) from digital camera memory. PhotoRec ignores the filesystem and goes after the underlying data, so it will still work even if your media's filesystem has been severely damaged or re-formatted.

For more safety, PhotoRec uses read-only access to handle the drive or memory support you are about to recover "lost" data from.

Important: As soon as a pic or file is accidentally deleted, or you discover any missing, do NOT save any more pics or files to that memory device or hard disk drive; otherwise you may overwrite your "lost" data. This means that even using PhotoRec, you must not choose to write the recovered files to the same partition they were stored on.

A great tutorial titled "PhotoRec Step By Step" can be found at PhotoRec's site.

Links & resources [^]

This page is a compilation of the following pages:


Hard Drive Recovery, Ubuntu-Style

Recover Data and (deleted) Partition with Linux from Hard Drives, CD-ROMs or DVDs


gddrescue: a tool for recovering data from damaged media