Linu deleted File recovery by mistake

Source: Internet
Author: User

PS: Red font is an important part, look carefully

When you are aware of the accidental deletion of files, you should never write more frequently, otherwise your data recovery will be very small. And what we want to do is, the first time the service on the server all stop, directly killall process name or kill-9 PID. Then delete the deleted files from the partition, re-mount the RO, read-only (Mount-o ro/dev/sdb2/data/).

First, the use of System Tools Debugfs recover deleted files mistakenly

1. First create a directory and file;

[[email protected] ~]# mkdir ceshi[[email protected] ~]# echo 111 > Ceshi/1.txt


2. Delete all files under the Ceshi directory;

[Email protected] ~]# RM-RF ceshi/*


3. Using the system's own restore tool Debugfs to repair;

[Email protected] ~]# Debugfsdebugfs 1.41.12 (17-may-2010) debugfs:open/dev/mapper/volgroup-lv_root


4. Use the ls-d parameter to display the directory where the file was just deleted;

Debugfs:ls-d/root/ceshi/144661 (12).   128522 (4084).. <128531> (4072) 1.txt


5. Display <> angle brackets is the file inode number we are looking for;

Debugfs:logdump-i <131458>


6. After execution, display a screen of information, we need this line, and remember the value of the following (that is, the red section);

Blocks: (0+1): 127754 (2+1): 1768711539 (3+1): 7894382 (tind): 1953724787


7. Exit Debugfs and execute the following command;

Debugfs:q[[email protected] ~]# dd if=/dev/mapper/volgroup-lv_root of=/root/ceshi/1.txt.bak bs=4096 count=1 skip=30# if= input Device # of= output Social Security # bs= Specifies the size of a block # count= how many blocks need dump# skip= Blocks: (0+1): After value


8. See if the 1.txt.bak file is generated in the/root/ceshi/directory;

[Email protected] ~]# cat/root/ceshi/1.txt.bak111


Ii. use of Extundelete to recover deleted files by mistake

1. Install the dependency package with Yum;

[[email protected] ~]# yum-y install e2fsprogs*[[email protected] ~]# yum-y install gcc* #extundelete GCC environment required at compile time


2. Download and install extundelete;

[Email protected] ~]# wget http://nchc.dl.sourceforge.net/project/extundelete/extundelete/0.2.4/extundelete-0.2.4.tar.bz2


3. Unpacking, configuration, compiling and installation;

[[email protected] ~]# TAR-JXVF extundelete-0.2.4.tar.bz2[[email protected] ~]# CD Extundelete-0.2.4[[email protected] E  xtundelete-0.2.4]#./configure--prefix=/usr/local/extundelete [[email protected] extundelete-0.2.4]# make && Make install


4. Test whether the installation is successful;

[Email protected] extundelete-0.2.4]# Cd/usr/local/extundelete/bin[[email protected] bin]#./extundelete- Vextundelete version 0.2.4LIBEXT2FS version 1.41.12Processor is little endian.


5. Scan the LVM partition for accidental deletion of files;

[Email protected] bin]#/usr/local/extundelete/bin/extundelete/dev/mapper/volgroup-lv_root--inode 2

6. Restore the Aaa.txt file;

[Email protected] bin]#/usr/local/extundelete/bin/extundelete--restore-file aaaa.txt/dev/mapper/volgroup-lv_root [Email protected] bin]#/usr/local/extundelete/bin/extundelete--restore-all/dev/sdb2 #恢复分区


7. View the recovery files;

[[email protected] bin]# ls-l recovered_files/The recovered files are also in./recovered_files/, can restore depends on your luck good.


This article is from the Chen. "Blog, be sure to keep this provenance http://chenxiaojian.blog.51cto.com/9345444/1622378

Linu deleted File recovery by mistake

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.