How to restore data on ext3

Source: Internet
Author: User

I met at work, checked online articles, and found that few actually passed, it was really angry. I found the software and performed a practical operation to ensure stable recovery.
Test Environment
[Root @ localhost ~] # Uname-
Linux localhost. localdomain 2.6.18-8. EL5 #1 SMP Fri Jan 26 14:15:21 est 2007 i686 i686 i386 GNU/Linux

Required Libraries
[Root @ localhost ~] # Rpm-Qa | grep e2fsprogs
E2fsprogs-libs-1.39-8.el5
E2fsprogs-1.39-8.el5
E2fsprogs-devel-1.39-8.el5
Partition status
[Root @ localhost ~] # DF-H
Filesystem size used avail use % mounted on
/Dev/mapper/VolGroup00-LogVol00
6.2 GB 1.8g 4.2g 30%/
/Dev/sda1 99 m 11 m 83 m 12%/boot
/Dev/mapper/VolGroup00-LogVol02
1008 M 34 m 924 M 4%/Data
Tmpfs 125 m 0 125 m 0%/dev/SHM
Software required
Http://code.google.com/p/ext3grep/downloads/list
Download Software first
[Root @ localhost ~] # Cd/root/src/
[Root @ localhost SRC] # wget http://ext3grep.googlecode.com/files/ext3grep-0.6.0.tar.gz SRC
[Root @ localhost SRC] # ls
Ext3grep-0.6.0.tar.gz
[Root @ localhost SRC] # tar xfvz ext3grep-0.6.0.tar.gz
[Root @ localhost ext3grep-0.6.0] #./configure
[Root @ localhost ext3grep-0.6.0] # make install
[Root @ localhost ext3grep-0.6.0] # ext3grep
Running ext3grep version 0.6.0
Compile the program and test the program. After all the tasks are completed, start the recovery process.
My directory is/Data Partition. I first formatted the partition. I put a file in the root directory and a file in a subdirectory.
/Dev/mapper/VolGroup00-LogVol02 1008 M 34 m 924 M 4%/Data
Copy Point file past
[Root @ localhost ~] #] # Cp/bin/ls/data/
[Root @ localhost ~] #] # Cp-RF/bin/data/
[Root @ localhost ~] #] # Ls-La/data/
Total 136
Drwxr-XR-x 4 Root 4096 Apr 21.
Drwxr-XR-x 25 Root 4096 Apr 21 ..
Drwxr-XR-x 2 root Root 4096 Apr 21 Bin
Drwx -- 2 root Root 16384 Apr 21 17: 15 lost + found
-Rwxr-XR-x 1 Root 93560 Apr 21 ls
[Root @ localhost ~] #
One sub-directory and one Executable File
Now delete the LS file and zcat under the bin
[Root @ localhost ~] # Rm/data/ls
RM: Remove regular file '/data/ls '? Y
[Root @ localhost ~] # Rm/data/bin/zcat
RM: Remove regular file '/data/bin/zcat '? Y
[Root @ localhost ~] # Ls-La/data/ls/data/bin/zcat
Ls:/data/LS: no such file or directory
Ls:/data/bin/zcat: no such file or directory
If the file does not exist, we can restore it.
First, unmount the partition.
[Root @ localhost ~] # Umount/dev/mapper/VolGroup00-LogVol02
[Root @ localhost ~] # DF-H
Filesystem size used avail use % mounted on
/Dev/mapper/VolGroup00-LogVol00
6.2 GB 1.8g 4.2g 30%/
/Dev/sda1 99 m 11 m 83 m 12%/boot
Tmpfs 125 m 0 125 m 0%/dev/SHM
Confirm uninstallation and use ext3grep to restore.
[Root @ localhost ~] # Ext3grep/dev/mapper/VolGroup00-LogVol02-ls-inode 2
Scan partitions will be created here
[Root @ localhost ~] # Ext3grep/dev/mapper/VolGroup00-LogVol02-ls-inode 2
[Root @ localhost ~] # Ext3grep/dev/mapper/VolGroup00-LogVol02-restore-file ls
Running ext3grep version 0.6.0
Warning: I don't know what ext3_feature_compat_ext_attr is.
Number of groups: 8
Minimum/maximum journal block: 585/8787
Loading journal descriptors... Sorting... Done
Number of descriptors in Journal: 58; min/MAX sequence numbers: 2/5
Loading VolGroup00-LogVol02.ext3grep.stage2... Done
Restoring ls
[Root @ localhost ~] # Ext3grep/dev/mapper/VolGroup00-LogVol02-restore-file bin/ls
Running ext3grep version 0.6.0
Warning: I don't know what ext3_feature_compat_ext_attr is.
Number of groups: 8
Minimum/maximum journal block: 585/8787
Loading journal descriptors... Sorting... Done
Number of descriptors in Journal: 58; min/MAX sequence numbers: 2/5
Loading VolGroup00-LogVol02.ext3grep.stage2... Done
Restoring bin/ls
[Root @ localhost ~] # Ls-La restored_files/
Total 124
Drwxr-XR-x 3 Root 4096 Apr 21.
Drwxr-X-5 root Root 4096 Apr 21 ..
-Rwxr-XR-x 1 Root 93560 Apr 21 ls
[Root @ localhost ~] # Ext3grep/dev/mapper/VolGroup00-LogVol02-restore-file bin/zcat
Running ext3grep version 0.6.0
Warning: I don't know what ext3_feature_compat_ext_attr is.
Number of groups: 8
Minimum/maximum journal block: 585/8787
Loading journal descriptors... Sorting... Done
Number of descriptors in Journal: 58; min/MAX sequence numbers: 2/5
Loading VolGroup00-LogVol02.ext3grep.stage2... Done
Restoring bin/zcat
[Root @ localhost ~] # Ls-La restored_files/bin/
Total 188
Drwxr-XR-x 2 root Root 4096 Apr 21.
Drwxr-XR-x 3 Root 4096 Apr 21 ..
-Rwxr-XR-x 1 Root 62136 Apr 21 zcat
Check whether all files are restored to the restored_files directory. The size is the same.
References
Http://www.xs4all.nl /~ Carlo17/howto/undelete_ext3.html

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.