ILD

恢复rm -fr删除的文件
作者:YUAN JIANPENG 邮箱:yuanjp@hust.edu.cn
发布时间:2018-6-28 站点:Inside Linux Development

刚才一不小心执行了kernel_clean,把辛苦配置的内核.config文件给删除了。


安装恢复工具:

1
sudo apt-get install extundelete


使用df查看分区的设备文件:

1
2
3
4
5
6
7
8
9
10
11
sudo df
Filesystem     1K-blocks     Used Available Use% Mounted on
udev             4006212        0   4006212   0% /dev
tmpfs             805316     9692    795624   2% /run
/dev/sda2       14287344 10909076   2629468  81% /
tmpfs            4026564     3296   4023268   1% /dev/shm
tmpfs               5120        8      5112   1% /run/lock
tmpfs            4026564        0   4026564   0% /sys/fs/cgroup
/dev/sda1         291252     3480    287772   2% /boot/efi
/dev/sda3      100541880 41949856  53461684  44% /work
tmpfs             805316       80    805236   1% /run/user/1000

可以发现设备文件是/dev/sda3


执行恢复命令:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
sudo extundelete --recover-file pi/pi3_dev/output/linux-4.14/.config /dev/sda3
extundelete: unrecognized option '--recover-file'
No action specified; implying --superblock.
extundelete: Some unrecognized options were found. Use --help for a usage message.
extundelete: Error parsing command-line options.
herbert@herbert-pc:/tmpsudo extundelete --restore-file pi/pi3_dev/output/linux-4.14/.config /dev/sda3
NOTICE: Extended attributes are not restored.
WARNING: EXT3_FEATURE_INCOMPAT_RECOVER is set.
The partition should be unmounted to undelete any files without further data loss.
If the partition is not currently mounted, this message indicates 
it was improperly unmounted, and you should run fsck before continuing.
If you decide to continue, extundelete may overwrite some of the deleted
files and make recovering those files impossible.  You should unmount the
file system and check it with fsck before using extundelete.
Would you like to continue? (y/n
y']
Loading filesystem metadata ... 781 groups loaded.
Loading journal descriptors ... 31454 descriptors loaded.
Successfully restored file pi/pi3_dev/output/linux-4.14/.config


注意:

要恢复的路径是分区中的路径,-o选项指定的路径不能使用绝对路径,是相对于当前目录的路径。


参考

https://blog.csdn.net/dayancn/article/details/54692111

https://blog.csdn.net/liucc09/article/details/51644173


Copyright © linuxdev.cc 2017-2024. Some Rights Reserved.