Restore deleted files using ext3grep in Linux (1)

Source: Internet
Author: User

LinuxHowRestoreDeleted files? Let's see how the author solves this problem!

The data of 10 Gb was deleted by mistake and almost collapsed. I tried all the conventional recovery software and it was useless. When I had to give up, I found the ext3grep open source stuff!

Data can be restored smoothly, so data deletion in linux is not terrible. What's terrible is that there is no restoration method after deletion. Let's take a look at the following operations!

 
 
  1. [root@localhost ~]# uname -a   
  2. Linux localhost.localdomain 2.6.18-8.el5 #1 SMP Fri Jan 26 14:15:21 EST 2007 i686 i686 i386 GNU/Linux 

In fact, it doesn't matter what version of the system!

Required Libraries

 
 
  1. [root@localhost ~]# rpm -qa |grep e2fsprogs  
  2. e2fsprogs-libs-1.39-8.el5  
  3. e2fsprogs-1.39-8.el5  
  4. e2fsprogs-devel-1.39-8.el5  

A e2fsprogs-libs is required, otherwise there will be problems with the installation of ext3grep later.

Partition:

 
 
  1. [root@localhost ~]# df -h  
  2. Filesystem Size Used Avail Use% Mounted on  
  3. /dev/mapper/VolGroup00-LogVol00  
  4. 6.2G 1.8G 4.2G 30% /  
  5. /dev/sda1 99M 11M 83M 12% /boot  
  6. /dev/mapper/VolGroup00-LogVol02  
  7. 1008M 34M 924M 4% /data  
  8. tmpfs 125M 0 125M 0% /dev/shm  

Software required

Http://code.google.com/p/ext3grep/downloads/list

Download Software first

 
 
  1. [root@localhost ~]# cd /root/src/  
  2. [root@localhost src]# wget http://ext3grep.googlecode.com/files/ext3grep-0.6.0.tar.gz src  
  3. [root@localhost src]# ls  
  4. ext3grep-0.6.0.tar.gz  
  5. [root@localhost src]# tar xfvz ext3grep-0.6.0.tar.gz  
  6. [root@localhost ext3grep-0.6.0]# ./configure  
  7. [root@localhost ext3grep-0.6.0]# make install  
  8. [root@localhost ext3grep-0.6.0]# ext3grep  
  9. 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 1008M 34M 924M 4% /data

The following italics are not mandatory:

In fact, it doesn't matter what partition is used here. You can also simulate it. The following is a simulation step:

 
 
  1. mkdir /data1/  
  2. cd /data1/  
  3. dd if=/dev/zero of=disk1 count=2048000 
  4. mkfs.ext3 disk1  
  5. mkdir -p /dfs/a  
  6. mount -o loop /data1/disk1 /dfs/a  

Here, we use the/data Partition to copy some files first.

 
 
  1. [root@localhost ~]# ]# cp /bin/ls /data/  
  2. [root@localhost ~]# ]# cp -rf /bin /data/  
  3. [root@localhost ~]# ]# ls -la /data/  
  4. total 136  
  5. drwxr-xr-x 4 root root 4096 Apr 21 17:37 .  
  6. drwxr-xr-x 25 root root 4096 Apr 21 17:11 ..  
  7. drwxr-xr-x 2 root root 4096 Apr 21 17:37 bin  
  8. drwx—— 2 root root 16384 Apr 21 17:15 lost+found  
  9. -rwxr-xr-x 1 root root 93560 Apr 21 17:37 ls  
  10. [root@localhost ~]#  

One sub-directory and one Executable File

Now delete the ls file and zcat under the bin

 
 
  1. [root@localhost ~]# rm /data/ls  
  2. rm: remove regular file `/data/ls’? y  
  3. [root@localhost ~]# rm /data/bin/zcat  
  4. rm: remove regular file `/data/bin/zcat’? y  
  5. [root@localhost ~]# ls -la /data/ls /data/bin/zcat  
  6. ls: /data/ls: No such file or directory  
  7. ls: /data/bin/zcat: No such file or directory  


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.