You Are Here: Home » How-To » Linux

How To Recover Deleted Files in Linux Using PhotoRec

By Ricky on January 25th, 2011 

PhotoRec is a data recovery software designed to recover a variety of files from different types of media like hard disk, flash drives, CD-ROMs etc. It is designed to recover a number of file types including audio files, video files, pictures, archives etc. PhotoRec works great even of you have accidentally formated the storage drive. Photorec is more suited for recovery of a large number of files, say from a formatted drive, rather than just one or two files.

Before you try to recover deleted files using PhotoRec (or with most of the data recovery software, for that matter) keep in mind that if the file was deleted a long time ago, the probability of its recovery is low.

The first thing you need to do is install PhotoRec. It is available for most of the major Linux distributions. In Ubuntu, use the command below to install it.

$ sudo apt-get install photorec

In Fedora, PhotoRec comes as a part of the TestDisk package. Install it with the command given below.

$ sudo yum install testdisk

After installing, you can start PhotoRec from the command line with the command

$ sudo photorec

This is what you will get when you start PhotoRec.

Your disks will be listed here. Select the appropriate one and proceed.

You will be asked to select the partition table type now. If the filesystem on your disk is EXT3, EXT4, NTFS etc. select Intel/PC.

After you choose the appropriate partition table, you will be presented with the screen below. This is where you can select what type of files you want to recover and set various other options.

To select the file types you want PhotoRec to look for, go to File Opt. (Use the left-right arrow keys.)

Now, use the up-down arrow keys to go navigate and left-right arrow keys to select/deselect. After you are done, press "b" to save the settings. After saving, Quit to return back to the previous menu.

Now, use the left-right arrow key again to select Search. Now you will be asked to select the file system used to store the deleted files. Pick the appropriate one and press Enter.

In the next menu, you can specify where you want the recovered files to be stored. Do not store in the same partition from which you are attempting to recover. Once you are in the desired location, press y.

Now the recovery will start and it is a matter of waiting. The recovered files will be stored in directories named recup_dir.X.


How To Recover Deleted Files in Linux Using PhotoRec was originally published on on January 25, 2011 - 12:36 pm (Indian Standard Time)