Use debugfs in Linux to restore files deleted by RM

Source: Internet
Author: User

The principle is that the deleted file is not actually retrieved from the hard disk, but the inode index deletes the relevant information. Therefore, you only need to find the block of the deleted file, to restore the deleted files.

The following method is used to test the ext3 file system. ext2 has not been used. Assume that the deleted file is located in/dev/sda5.

Debugfs

1. Run debugfs and enter the scheduling mode.

2. Run open/dev/sda5.

3. Execute LS-D dir to list the most recent operations on this directory. The <num> log deletion record is displayed.

4. Execute logdump-I <num> to display the log Content.

5. Find the block corresponding to the deleted file in the output and record the blockid.

6. Exit debugfs and run dd If =/dev/sda5 of =/tmp/saved BS = 1024 COUNT = 1 skip = blockid.

At this point, the deleted file is restored, but this method has a problem. If a large file is deleted, multiple blocks are occupied, which makes operations more troublesome.

In the debugging mode, debugfs is difficult to use. However, debugfs supports the-r option and can be executed in shell, that is, multiple-R are used to connect the commands to be executed, if you need to specify a parameter in the command, you need to add ""; otherwise, shell parsing may fail.

Testdisk is a useful tool. It was previously used to restore and back up the partition tables of the system, but not to restore files. If you have any problems in the future, try again.

Http://www.cgsecurity.org/wiki/TestDisk_Download

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.