Restore deleted files in the ext4 Partition

Source: Internet
Author: User
Tags testdisk photorec

Original article. Please indicate the source for reprinting. Thank you!
Author: Qinglin, blog name: feikong jingdu

 

Today, I am testing the code I just completed for backing up and recovering NTFS partitions in Linux. I am running a program to back up a m NTFS partition, then, after running another program to restore data to the MB partition, load the partition to/tmp/sdd1 to check whether the file is successfully restored.-I'm glad that it took a few weeks to restore the data, finally, I can breathe a sigh of relief!

 

Therefore, I want to further test it, so I want to delete the content in/tmp/sdd1 and restore it again to see if the data of the entire partition can be restored! Therefore, RM * runs quickly *. Then I found that a directory was not deleted. I thought, "No! I didn't copy the directory to this NTFS partition. "Then I checked the directory path and my project path, because I loaded/dev/sdd1 to/tmp/sdd1 under this directory, the directory is not switched. At this time, the heart is getting cooler! After so many projects and so many code files, no need to say: (--- crying!

 

Because the project has not yet created the svn code library, all the code is in my machine and there is no backup, day! Why is this hard work still affecting the project progress.

After a long time of data backup and recovery for the file system in windows, I plan to write a file recovery software for the NTFS partition. But now, in a Linux File System, sadly!

 

Search for ext4 partition file recovery now!

 

Found two, one is photorec and the other is extundelete.

 

Below is my file recovery history!

The data recovered by photorec is very messy and inaccurate. The following describes how to use extundelete to restore my data!

 

Source code of the downloaded extundelete (URL: http://extundelete.sourceforge.net /)

Here, we will emphasize that you should not download the code to the partition you want to restore. You should restore the partition of the file and do not perform any data read/write operations!

 

Therefore, I downloaded extundelete to the/tmp directory, decompress it, compile it!

Before compilation, you need to install two libraries: e2fsprogs and e2fslibs.

Sudo apt-Get install e2fsprogs e2fslibs-dev

This is installed in ubuntu10.04.

Then run make in the source code directory SRC to compile the file, and finally generate the extundelete executable file.

 

Then I will run

Sudo./extundelete/dev/sda9 -- restore-all

 

We recommend that you restore all deleted files.

 

After the program ends, a directory recovered_files will be generated under the program directory.

This directory contains all the deleted files, and you can find your deleted directories and files below, but I still cannot find many files, fortunately, the file I am looking for is a text file, so I used the grep command to find it.

 

CD recovered_files

 

In this directory, and then according to the content in your program file, for example, I want to find my partntfs class, because this file cannot be found, so I like this

Grep-RHN "partntfs "*

 

Based on the output content, I found this file

Fjb/. Mozilla/Firefox/omhuxrnc. Default/Cache/cf72b08ed01

 

Use Vim to open this file, which is really a file I need, so copy it out and rename it.

Therefore, we must restore all deleted files, because extundelete may rename the recovered files and place them in other directories.

 

Here, grep is used for searching. Therefore, some recovered files become hidden files and there are many recovered files. It is very troublesome to open the test one by one, so it is much faster to use grep for searching.

 

Finally, I am very lucky to have successfully restored the source code file of the entire project and re-compiled it --- succeeded!

 

If extundelete does not completely restore your file data, you can use the photorec and grep commands to restore it. photorec can retrieve some data, but some data will be messy, you need to piece it together! Photorec in testdisk, you only need to install testdisk to install photorec.

 

Ah, even if the data backup and recovery software is used, it will be carried here if you are not careful, so I would like to advise you, be sure to protect your data and back up your important data. After all, hard disks are valuable and data is priceless!

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.