Restore objects accidentally deleted by RM-RF with ext3grep

Source: Internet
Author: User

As an enterprise-level server, Linux is crucial to data security. accidental deletion of any valuable data is intolerable and may even cause a major disaster! As a Linux system administrator, you must have the data protection function. You must not only back up data, but also restore important data after accidental deletion. here we will introduce an open-source data recovery tool ext3grep, which can restore files accidentally deleted by RM-RF.
I. Principle of ext3grep:
Restoring a file using ext3grep does not depend on any file format. First, ext3grep uses the root inode to obtain all file information in the file system, including existing or deleted files, the information includes the file name, inode number, and then the inode is used in combination with the system log to query the location of the block where the inode is located, including the information of direct and indirect blocks, finally, use the DD command to back up the data information to restore the data!
After the file is deleted by mistake, the first thing to do is to immediately unmount the partition where the file is located or mount the partition in read-only mode, because after the file is deleted, the data in the file is retained on the disk. Unless the system allocates the block where the data is located, it will always exist, the first thing to do is to unload the partition where the file is located,
As for the root partition, You can restart the system, then enter the system in single-user mode, and mount the root partition in read-only mode:
Mount-O Ro, remount/
Ii. ext3grep Installation
Before installation, check whether e2fsprogs software has been installed. If you do not need to download and install e2fsprogs software, or else an error will be reported when you install ext3greep!
[[Email protected] ~] # Rpm-Qa | grep e2fs
E2fsprogs-devel-1.39-23.el5_5.1
E2fsprogs-libs-1.39-23.el5_5.1
E2fsprogs-1.39-23.el5_5.1
E2fsprogs-libs-1.39-23.el5_5.1
You can download the ext3grep source code package from the Internet:
Wget http://code.google.com/p/ext3grep/downloads/detail? Name1_ext3grep-0.10.2.tar.gz
Decompress, compile, and install
Tar zxf ext3grep-0.10.2.tar.gz
CD ext3grep-0.10.2
./Configure-Prefix =/usr/local/ext3grep
Make
Make install
3. Use ext3grep to restore data deleted by RM-RF
First, we simulate a disk partition and create a virtual device.
[[Email protected] ~] # Mkdir/disk create a mount point
[[Email protected] ~] # Mkdir/virtual
[[Email protected] ~] # Dd If =/dev/Zero of =/virtual/disk1 conut = 102400
[[Email protected] ~] # Mkfs-T ext3/vittual/disk1
[[Email protected] ~] # Mount-o loop/virtual/disk1/Disk
[[Email protected] ~] # Echo "This is a ext3grep test, thank you">/Disk/ext3grep-test.txt
Use Rm-RF to delete the file you just created
Rm-RF/Disk /*
Check that the file has been deleted.
3. Use ext3grep to restore the deleted file
Create a directory dedicated to storing recovered files
Mkdir restore
CD restore
Iv. File recovery process
Run
View deleted files
[[Email protected] restore] #/usr/local/ext3grep/bin/ext3grep/virtual/disk -- ls -- inode 2
. -- File type in dir_entry (r = regular file, D = directory, L = symlink)
|. -- D: deleted; R: reallocated
Indx next | inode | deletion time mode file name
================= + -------------- Data-from-inode ------ + ----------- + ======== =
0 1 D 2 drwxr-XR-X.
1 end D 2 drwxr-XR-x ..
2 end d 11 d 1340620814 mon Jun 25 18:40:14 2012 drwx ------ lost + found
3 end R 12 d 1340620814 mon Jun 25 18:40:14 2012 rrw-r -- ext3grep-test.txt

Start recovery

[[Email protected] restore] #/usr/local/ext3grep/bin/ext3grep/virtual/disk -- restore-file ext3grep-test.txt
Running ext3grep version 0.10.2
Warning: I don't know what ext3_feature_compat_ext_attr is.
Number of groups: 7
Minimum/maximum journal block: 16616/20729
Loading journal descriptors... sorting... Done
The oldest inode block that is still in the journal, appears to be from 1340620763 = mon Jun 25 18:39:23 2012
Number of descriptors in Journal: 20; min/MAX sequence numbers: 2/5
Writing output to directory restored_files/
Loading disk. ext3grep. stage2... done
Restoring ext3grep-test.txt
The ext3grep-test.txt file has been restored successfully. A restored_files directory is generated under the current directory, and the recovered files are placed there.
[[Email protected] restored_files] # ls
Ext3grep-test.txt
Summary: although this tool can restore files deleted by the RM-RF Command, as a system administrator, you should have a concept of backing up data every moment in your mind, after all, backup is king!


This article is from the "Linux" blog, please be sure to keep this source http://linuxengineer.blog.51cto.com/7391710/1440327

Restore objects accidentally deleted by RM-RF with ext3grep

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.