How To Recover lost Data Using Testdisk On Linux

You have to install the EPEL repository on Centos / Redhat machine because this won’t be available in the default repository. we can recover deleted and lost files in Linux using the testdisk tool. let’s see how to recover lost data. we can also install testdisk when command not available.

How To Recover lost Data Using Testdisk On Linux:

yum install epel-release -y

Check Out: How To Configure Rsyslog Centralized Log Server On Linux

Install the TestDisk Data recovery tool

yum install testdisk -y

How To Recover lost

you may check the installed version using rpm -qi testdisk

testdisk install linux

Display all the partition on machine use testdisk /list

recover files with testdisk

Suppose, I have 300MB file in LVM partition which I have created using fallocate -l 300M test_file1.img

recover deleted files linux

I will remove these files and try to recover using testdisk tool.

Check Out: Step To Merge Branches In Git & Send To GitLab Server

Now we will try to recover the lost data and run the below command.


Then hit on Create and it will display all the drives.

recover lost files linux

Select your disk here

Disk /dev/mapper/vg-lv_vg - 838 MB / 800 MiB - VMware, VMware Virtual S

 how to recover deleted files in unix using commands

Then click on Proceed

how to restore permanently deleted files

Check Out: How To Upgrade Ubuntu Desktop From 18.04 To 19.04

The system will automatically be selected. In my case, it’s [None ] Non partitioned media. It might be because I’m running on VMWare and “Enter”.

recover deleted files linux command line

Click on “quit”

You have to choose “Analyse”

Select Quick Search and you can see your current partition structure listed.

Check Out: How To Uninstall Mono Cross-Platform On Ubuntu 18.04

If you click on List, you can see all the files including which I deleted.

Press ‘p’ to see the lost files.

Select the lost file and press ‘C’ to copy in the destination directory.

Check Out: How To Upgrade Kibana Version From 4.x To 7.x CentOS 7

If the destination is correct, press ‘C’.

After these steps, you have to press’ q’ and return back to the main menu. Keep pressing ‘quit’ to see the console.

As you can see files have been recovered.

You’re done testdisk install linux recover files with testdisk recover deleted files linux recover lost files linux

Share on:

I'm the founder of Curious Viral. I hope this blog will provide you complete information about Linux Technology & I would like to share my technical knowledge with you which I have learned during this period.

Other Posts You May Like...

1 thought on “How To Recover lost Data Using Testdisk On Linux”

  1. Thanks for the explanation!
    One question – how do I know which directory to save the recovered data in? I have a completely empty 1 TB hard drive that I want to save the data in, but I don’t understand the numbers and letters in the section of choosing which directory. I tried just guessing and selecting the one with highest numbers, but it tried to save to my smaller SSD and ran out of room.
    Can I set up a directory on the empty HDD that I will be able to recognize while running Photorec?



Leave a comment