快轉到主要內容

使用 extundelete 恢复rm误操作

·438 字·1 分鐘
Y Cheung
作者
Y Cheung
Blogger, Programer & Traveler.
  • 系统:CentOS 7
  • 文件系统:EXT4

今天 YCHEUNG 不小心用 rm 命令误删了一个名字奇奇怪怪的文件,因为名字太奇怪想不起来它是啥,怕是重要文件,所以急急忙忙去找办法恢复。

随手一找就看到可以用 linux 自带的文件恢复工具 debugfs 来进行恢复,但是只能恢复 ext2 文件系统的文件…. 于是 YCHEUNG 用 mount 命令查看了一下,文件系统是 ext4 的…呵呵呵呵…..orz…..

然后看到有人说比较便利的方法是用 extundelete 工具,它可以直接用 yum install extundelete 安装,也可以参照官网的说明编译安装。

恢复文件前先让主机offline哦~

一个简单的命令: $extundelete --restore-directory /var/aaa/ -o /var/bbb/restore /dev/xvda 第一个文件路径是你误删的文件所在文件夹,第二个路径被恢复的文件存放路径, 第三个是设备名。

 1$extundelete --restore-directory /var/aaa/ -o /var/bbb/restore /dev/xvda
 2
 3
 4NOTICE: Extended attributes are not restored.
 5WARNING: EXT3_FEATURE_INCOMPAT_RECOVER is set.
 6The partition should be unmounted to undelete any files without further data loss.
 7If the partition is not currently mounted, this message indicates 
 8it was improperly unmounted, and you should run fsck before continuing.
 9If you decide to continue, extundelete may overwrite some of the deleted
10files and make recovering those files impossible.  You should unmount the
11file system and check it with fsck before using extundelete.
12Would you like to continue? (y/n) 

最后,由于想起来那个文件是什么,也就没继续尝试下去。

以后要慎用 rm 命令了,呜呜呜~

相關文章

FEDORA安装electron-builder报错make:g++:命令未找到之解决

·354 字·1 分鐘
系统环境: Fedora 24 Node v4.5.0 NPM v2.15.9 NPM安装electron-builder报错 # 1$npm install electron-builder --save=dev 2npm WARN package.json [email protected] No repository field. 3npm WARN package.json [email protected] No README data 4 5> [email protected] install /var/www/html/test/node_modules/dev/node_modules/inotify 6> node-gyp rebuild 7 8make: Entering directory '/var/www/html/test/node_modules/dev/node_modules/inotify/build' 9 CXX(target) Release/obj.target/inotify/src/bindings.o 10make: g++:命令未找到 11inotify.target.mk:97: recipe for target 'Release/obj.target/inotify/src/bindings.o' failed 12make: *** [Release/obj.target/inotify/src/bindings.o] Error 127 13make: Leaving directory '/var/www/html/test/node_modules/dev/node_modules/inotify/build' 14gyp ERR! build error 15gyp ERR! stack Error: `make` failed with exit code: 2 16gyp ERR! stack at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules.bundled/node-gyp/lib/build.js:276:23) 17gyp ERR! stack at emitTwo (events.js:87:13) 18gyp ERR! stack at ChildProcess.emit (events.js:172:7) 19gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12) 20gyp ERR! System Linux 4.7.4-200.fc24.x86_64 21gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" 22gyp ERR! cwd /var/www/html/test/node_modules/dev/node_modules/inotify 23gyp ERR! node -v v4.5.0 24gyp ERR! node-gyp -v v3.4.0 25gyp ERR! not ok 26npm WARN optional dep failed, continuing [email protected] 27npm WARN deprecated [email protected]: This package is deprecated. Use Object.assign. 28npm WARN optional dep failed, continuing [email protected] 29npm WARN optional dep failed, continuing [email protected] 30npm ERR! Linux 4.7.4-200.fc24.x86_64 31npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "electron-builder" "--save=dev" 32npm ERR! node v4.5.0 33npm ERR! npm v2.15.9 34npm ERR! code ELIFECYCLE 35 36npm ERR! [email protected] install: `node-gyp rebuild` 37npm ERR! Exit status 1 38npm ERR! 39npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'. 40npm ERR! This is most likely a problem with the inotify package, 41npm ERR! not with npm itself. 42npm ERR! Tell the author that this fails on your system: 43npm ERR! node-gyp rebuild 44npm ERR! You can get information on how to open an issue for this project with: 45npm ERR! npm bugs inotify 46npm ERR! Or if that isn't available, you can get their info via: 47npm ERR! 48npm ERR! npm owner ls inotify 49npm ERR! There is likely additional logging output above. 50 51npm ERR! Please include the following file with any support request: 52npm ERR! /var/www/html/test/npm-debug.log 解决方法: # 安装G++ $sudo dnf install gcc-c++

ubuntu vps上的文件权限配置

·238 字·1 分鐘
设置目录内所有文件及文件夹(包括子文件夹内)的权限为-rw-r–r–(644): chmod -R 644 * 设置目录内所有文件(不包括子文件夹内)的权限为-rw-r–r–(644):

Unity AvProVideo Plugin 中設置影片在安卓SD卡上的絕對地址

·359 字·1 分鐘
Media Play 設置 # Video Location 選擇 Absolute Path Or URL。 找到安卓設備SDCard的根目錄(ROOT PATH) # 如果電腦上安裝了adb工具,使用指令 adb shell echo $EXTERNAL_STORAGE 打印SD Card Root directory。 如果安卓設備上安裝了terminal工具,(比如Terminal Emulator for Android),使用指令 ls 根據經驗篩選可能的目錄。 一般而言,SD卡的根目錄可能但不限於以下幾種: /mnt/sdcard /storage/sdcard0 /storage/sdcard /sdcard 設置權限 # 在 AndroidManifest.xml 文件中的<uses-sdk前添加以下語句: 1<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> 通常該文件位於Assets/Plugins/Android/文件夾內,該配置文件詳解請參閱官方文檔《App Manifest》(有中文版)。