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
Install the TestDisk Data recovery tool
yum install testdisk -y
you may check the installed version using rpm -qi testdisk
Display all the partition on machine use testdisk /list
Suppose, I have 300MB file in LVM partition which I have created using fallocate -l 300M test_file1.img
I will remove these files and try to recover using testdisk tool.
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.
Select your disk here
Disk /dev/mapper/vg-lv_vg - 838 MB / 800 MiB - VMware, VMware Virtual S
Then click on Proceed
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”.
Click on “quit”
You have to choose “Analyse”
Select Quick Search and you can see your current partition structure listed.
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.
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