recovery Linux File that has been deleted by mistake

[root@xuegod63 ~]# mount /dev/cdrom /mnt/

It's divided into one area :sda4 

lookup :extundelete

It's divided into one area :sda4 

[root@localhost ~]# mkdir /tmp/sda4

[root@localhost ~]# mkfs.ext4 /dev/sda4      format

[root@xuegod63 Desktop]# echo $?

0

[root@localhost ~]# mount /dev/sda4 /tmp/sda4/

 [root@localhost ~]# df -Th  # View disk information

[root@xuegod63 Desktop]# mount /dev/sda4 /tmp/sda4

[root@xuegod63 Desktop]# df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/sda2             9.7G  3.8G  5.5G  41% /

tmpfs                 569M  264K  569M   1% /dev/shm

/dev/sda1             194M   28M  157M  15% /boot

/dev/sr0              3.4G  3.4G     0 100% /mnt

/dev/sda4            1012M   34M  928M   4% /tmp/sda4

Copy some files to test deletion :

[root@localhost ~]# cp /etc/passwd /tmp/sda4/

[root@localhost ~]# cp /etc/hosts /tmp/sda4/  

[root@localhost ~]# vim /tmp/sda4/a.txt          #vim edit a.txt Just write some data .

[root@localhost ~]# mkdir -p  /tmp/sda4/a/b/c

[root@localhost ~]# cp /tmp/sda4/a.txt /tmp/sda4/a

 

[root@localhost ~]# cp /tmp/sda4/a.txt /tmp/sda4/a/b/

Delete :

[root@xuegod63 ~]# mkdir /tmp/back

[root@xuegod63 ~]# cp -r /tmp/sda4/* /tmp/back

[root@xuegod63 ~]# cd /tmp/sda4/

[root@localhost ~]# rm -rf passwd hosts a   a.txt

[root@localhost ~]# ls /tmp/sda4/

lost+found

 

 

Uninstall the partition that needs to recover files :  inode

[root@xuegod63 sda4]# cd

[root@xuegod63 ~]# umount /tmp/sda4/

 

Install the software extundelete

[root@xuegod63 ~]# tar jxvf extundelete-0.2.4.tar.bz2

[root@xuegod63 ~]# cd extundelete-0.2.4

[root@xuegod63 extundelete-0.2.4]# ./configure

Configuring extundelete 0.2.4

configure: error: Can't find ext2fs library   # Report errors

[root@xuegod63 ~]# mount /dev/cdrom  /mnt/

[root@xuegod63 extundelete-0.2.4]# rpm -ivh /mnt/Packages/e2fsprogs-devel-1.41.12-11.el6.x86_64.rpm

[root@xuegod63 extundelete-0.2.4]#

[root@xuegod63 extundelete-0.2.4]# ./configure  # Check the installation environment and generate Makefile

[root@xuegod63 extundelete-0.2.4]# make  # compile

[root@xuegod63 extundelete-0.2.4]# make install  # install

http://www.cnblogs.com/jjzd/p/5785851.html

install e2fsprogs-devel-1.41.12-14.el6.x86_64.rpm

Start recovery :

Method 1:

adopt inode Node to view the deleted file name :

[root@xuegod63 ~]# mkdir test

[root@xuegod63 ~]# cd test/

[root@localhost ~]# extundelete /dev/sda4 --inode 2

...

lost+found                                        11

passwd                                            12             Deleted

hosts                                             13             Deleted

a                                                 8193           Deleted

a.txt                                             15             Deleted

 

adopt inode Node to recover :

[root@localhost ~]# extundelete  /dev/sda4 --restore-inode  12

NOTICE: Extended attributes are not restored.

Loading filesystem metadata ... 16 groups loaded.

Loading journal descriptors ... 32 descriptors loaded.

 [root@localhost ~]# ls RECOVERED_FILES/       # Recovery successful

file.12

[root@xuegod63 test]# diff /etc/passwd /root/test/RECOVERED_FILES/file.12

 

Method 2 , Recover... By filename

Method 2 , Recover... By filename

Recover a file :

[root@xuegod63 test]# rm -rf RECOVERED_FILES/

[root@localhost ~]# extundelete /dev/sda4 --restore-file  passwd

 

Restore a directory , Such as catalogue a All files under :

[root@localhost ~]# extundelete /dev/sda4 --restore-directory   a   # Restore directory a , no need

 

Recover all files

[root@localhost ~]# extundelete  /dev/sda4 --restore-all     

Use experience :

Empty directory or empty file recovery failed .

recovery Linux File that has been deleted by mistake ( note ) More articles about

  1. linux Next rm The recovery method of deleting database file by mistake

    stay linux redhat 5.4 edition ,rm Share the recovery process of deleting database files by mistake . No problem with the test , You can use . 1. First test rm Delete database file by mistake [oracle@primary dbwdn]$ ll total ...

  2. recovery Ext3 File deleted under ( turn )

    recovery Ext3 File deleted under ( turn ) Preface Here is a tutorial that will teach you how to Ext3 In the file system of rm Lost files . Delete file Suppose we have a file called ‘test.txt’ $ls -il test.txt 1 ...

  3. linux Lower generation core dump File methods and settings

    linux Lower generation core dump File methods and settings     from:http://www.cppblog.com/kongque/archive/2011/03/07/141262.html core ...

  4. linux Next volume tar.bz Merge and unzip files

    linux Next volume tar.bz Merge and unzip files example : linux.tar.bz2.001;linux.tar.bz2.002;linux.tar.bz2.003; First cat linux.tar.b ...

  5. linux Next php Upload file note

    linux Next php Upload file note 1. Modify upload directory permissions linux Modify the permissions of all subdirectories in a directory chmod -R 777 html Modify a directory so that any user can use write and read permissions chmod a+rwx html2. set up ...

  6. Linux Traversing the directory and file , Change permissions

    Linux Traversing the directory and file , Change permissions introduction : I am here Linux The structures, android when , take eclipse And sdk Copied to the /usr/ Next time , There will always be unreadable , Unable to write sample . Solution : There are two options : One . Will reply ...

  7. linux Next java call .so Method of file 1: JNI

    Excerpt from http://blog.163.com/squall_smile/blog/static/6034984020129296931793/ https://my.oschina.net/simabe ...

  8. Linux Next Vi The configuration file .vimrc file

    Linux Next Vi The configuration file .vimrc file To configure vim The best way to do this is to create a .vimrc file , I usually use root account , So it's in /root/ Next build a .vimrc file :vi /root ...

  9. Linux Next Two machine files / Folder Copy each other

    Linux Next Two machine files / Folder Copy each other There are two machines :A:*.101 And B:*.102. hold A Under the .temp/var/a.txt copy to B Mechanical /text/ Under the table of contents : Get into B machine :scp root ...

Random recommendation

  1. Study ExtJs The course is elementary

    Set up the environment :myeclipse10 +tomcat6+jdk6 Create a new one webproject( start-up myeclipse:file--new--webproject) Import related js and css( Baidu download is good . ...

  2. json Transform and optimize no refresh paging

    index.html dd

  3. linux Next java Environment configuration

    It's a very simple three line command ! $ sudo add-apt-repository ppa:webupd8team/java$ sudo apt-get update$ sudo apt-get ins ...

  4. js:setTimeout And setInterval Compare

    stay javascript There are two very useful functions in :setTimeout and setInterval , It's all timers : But there are some differences between the two : 1. setTimeout function usage :setTimeout(fn, ...

  5. prevent apache Next, directly enter the directory to access the file

    Some project links expose the file address on the server , How to access files to be accessed Method 1 : Add a new one under the project entry file .htaccess file (apache Open rewrite mode to load this file , Otherwise, this file configuration will not take effect ) Add... To the document ...

  6. near 5 year 133 individual Java Interview question list

    Java Interviews change over time . In the past days , When you know String and StringBuilder The difference between the two allows you to go straight to the second round of interviews , But now the problem is getting higher and higher , The interviewer asked more questions . In my ...

  7. AFNetworking (3.1.0) The source code parsing < 6、 ... and >

    This time we'll continue with the folder Serialization Next class AFURLResponseSerialization. This presentation will not be split , On the whole .h and .m file . agreement AFURLResponseSerializ ...

  8. Use MapReduce take HDFS Data import to HBase( One )

    package com.bank.service; import java.io.IOException; import org.apache.hadoop.conf.Configuration;im ...

  9. Android adopt HTTP POST Request Internet data

    @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); s ...

  10. BASE64- client (js) Overweight - Server side (c#) decode ,URL Pass on “ Chinese character parameters ” resolvent

    HttpUtility.UrlEncode stay Encode When , Convert the space to a plus sign ('+'), stay Decode Change the plus sign to a space when you want to , But browsers can't understand the plus sign as a space , So if the file name contains ...