可能是早上没睡醒吧,想删除/project/videos/
目录下的所有MP4文件,输入命令
rm -rf * .mp4
优雅的按下回车键,准备打开书愉快的阅读一会.莫名的觉得哪里不对劲,嘿嘿嘿,傻$%$了,命令输错了,应该是
rm -rf *.mp4
这下好了/project/videos/
目录被清空了(庆幸只是自己本地系统,也不是系统根目录).好吧,不用看书了,准备恢复吧
1. 查看挂载在哪的
df -h
/dev/sda2 219G 127G 81G 62% /
或者
mount
/dev/sda2 on / type ext4 (rw,relatime,errors=remount-ro,data=ordered)
2. 进入debugfs
调度模式
sudo debugfs
open /dev/sda2/
ls -d /project/videos/
3. 找到你刚才删除的文件的iNode
(就是<number>
),如:
<3807499> (32) 11_tmpFile_progress.txt <3808904> (64) 13_tmpFile.mp4
<3808905> (40) 13_tmpFile_downloadProgress.txt
<3808906> (28) 13_tmpFile.mp4.jpg <3808907> (64) 13_tmpFile.mp4palette.png
<3808908> (28) 13_tmpFile.mp4.gif <3808909> (140) 13_tmpFile_progress.txt
<3808910> (36) 13_tmpFile_converted_HD.mp4
<3808911> (72) 13_tmpFile_converted_SD.mp4
<3807460> (36) 13_tmpFile_converted_Low.mp4
<3808913> (40) 20_tmpFile_downloadProgress.txt
<3808914> (3588) 20_tmpFile_progress.txt
<3808915> (40) 19_tmpFile_downloadProgress.txt
<3808916> (3500) 19_tmpFile_progress.txt
<3808917> (3468) 19_tmpFile_converted_Low.mp4
<3808919> (3412) 18_tmpFile_progress.txt
<3808920> (36) 18_tmpFile_converted_HD.mp4
<3808921> (3344) 18_tmpFile_converted_Low.mp4
<3808924> (64) 22_tmpFile.mp4palette.png <3808925> (28) 22_tmpFile.mp4.gif
<3808926> (104) 22_tmpFile_progress.txt
<3808927> (36) 22_tmpFile_converted_HD.mp4
<3808928> (36) 22_tmpFile_converted_Low.mp4 <3808929> (828) 23_tmpFile.mp4
<3808930> (24) 18_tmpFile.mp4
<3808931> (132) 18_tmpFile_downloadProgress.txt
<3808932> (28) 18_tmpFile.mp4.jpg <3808933> (64) 18_tmpFile.mp4palette.png
<3808934> (28) 18_tmpFile.mp4.gif <3808935> (104) 18_tmpFile_progress.txt
4. 恢复<3807499> (32) 11_tmpFile_progress.txt
quit (退出debugfs模式)
extundelete --restore-inode 3807499 /dev/sda2
5. 在执行命令的当前目录下会生成文件夹RECOVERED_FILES
,恢复的文件在里边
注意: 在第2步其实应该先重新挂载为只读模式,要不然会很混乱(我装系统都弄在了 / 下边 没法演示了).祝你好运,最好是把rm
命令别名成mv
吧.下次不要手抖了!!!
mount -r -n -o remount /data