centOS6.4 extundelete工具恢復rm -rf 刪除的目錄
PS:補充下,我在fedora 19上執行的時候遇到的一個問題:
1 [[email protected] extundelete-0.2.4]# ./configure 2 Configuring extundelete 0.2.4 3 configure: error: in `/usr/local/src/extundelete-0.2.4': 4 configure: error: C++ compiler cannot create executables 5 See `config.log' for more details
查看了下config.log檔案發現與gcc-c++有關。所以執行yum -y install gcc-c++這個庫後問題解決
1 總計 988 kB/s | 8.2 MB 00:08 2 Running transaction check 3 Running transaction test 4 Transaction test succeeded 5 Running transaction 6 正在安裝 : libstdc++-devel-4.8.1-1.fc19.i686 1/2 7 正在安裝 : gcc-c++-4.8.1-1.fc19.i686 2/2 8 驗證中 : libstdc++-devel-4.8.1-1.fc19.i686 1/2 9 驗證中 : gcc-c++-4.8.1-1.fc19.i686 2/2 10 11 已安裝: 12 gcc-c++.i686 0:4.8.1-1.fc1913 14 作為依賴被安裝: 15 libstdc++-devel.i686 0:4.8.1-1.fc19 16 17 完畢! 18 [[email protected] extundelete-0.2.4]# ./configure 19 Configuring extundelete 0.2.4 20 Writing generated files to disk 21 [[email protected] extundelete-0.2.4]# yum install gcc-c++
首先。Linux下很多人都喜歡用rm -rf去刪除目錄。但是rm --help提示這是一個非常危險的命令、謹慎用之。
這裡公司一臺伺服器。同事在操作的過程中誤刪掉一個目錄。而且是非常重要的。
嘗試恢復cat /etc/redhat-release 檢視為rhel4版本。很老了這就有一個問題出現yum無法用。
先用一個ext3grep 工具恢復。但是該工具--help 提示沒有針對目錄恢復的引數 只有一個all 我嘗試用時間戳恢復當時時間段的資料效果不理想、
而且跟要命的是當我檢視分割槽的時候df -aT發現這個刪除的目錄進入奇蹟般的劃分在了與/一個分割槽。0 0這意味著我掛載為只讀分割槽時要殺掉一
切與/根分割槽有關的程序;所有反覆思索後決定一個好的辦法:
USB行動硬碟安裝一個便攜Linux系統,並在其上面安裝extundelete工具因為這個工具需要幾個包的支援。而rhel4的系統現在yum已經無法使用
安裝支援包都很困難。索性放棄。
關於USB行動硬碟系統。與我們用的stat 硬碟安裝系統一樣。可以用光碟映象安裝選擇USB裝置為安裝裝置。或者用虛擬機器安裝都可以。這裡我就
不多說推薦虛擬機器Virtual Box和VMware(優點是你有映象但無法刻盤)。
好了進入centOS6.4後
下載extundelete:wget http://pkgs.fedoraproject.org/repo/pkgs/extundelete/extundelete-0.2.4.tar.bz2/77e626ad31433680c0a222069295d2ca/extundelete-0.2.4.tar.bz2
1 [[email protected] src]# wget http://pkgs.fedoraproject.org/repo/pkgs/extundelete/extundelete-0.2.4.tar.bz2/77e626ad31433680c0a222069295d2ca/extundelete-0.2.4.tar.bz2
1 [[email protected] src]# tar jxvf extundelete-0.2.4.tar.bz2
直接./configure make make install 但我執行./configure時報錯:
1 [[email protected] src]# cd extundelete-0.2.4 2 [[email protected] extundelete-0.2.4]# ./configure 3 Configuring extundelete 0.2.4 4 configure: error: Can't find ext2fs library
提示 ext2fs library 少幾個包的支援
1 [[email protected] extundelete-0.2.4]# yum -y install ext2fs
OK 在執行make三部曲
[[email protected] extundelete-0.2.4]# ./configure Configuring extundelete 0.2.4 Writing generated files to disk
當然如果你make完後就可以使用這個工具的
1 [[email protected] extundelete-0.2.4]# make 2 make -s all-recursive 3 Making all in src 4 extundelete.cc:571: 警告:未使用的引數‘flags’
直接在~/src/extundelete --help
[[email protected] extundelete-0.2.4]# src/extundelete --help
或者在執行 make install 這時會安裝到/usr/local/bin/extundelete 下
我還是推薦make完就成了。因為假如你要恢復的目錄正好是/usr 那你就還需要在./configure下加引數。浪費時間效果一樣
OK來演示下恢復吧
1 [[email protected] /]# df -h 2 檔案系統 容量 已用 可用 已用%% 掛載點 3 /dev/mapper/vg_vbok-gen 4 25G 541M 23G 3% / 5 tmpfs 943M 232K 943M 1% /dev/shm 6 /dev/sdb1 485M 36M 424M 8% /boot 7 /dev/mapper/vg_vbok-home 8 20G 172M 19G 1% /home 9 /dev/mapper/vg_vbok-opt 10 11G 156M 9.9G 2% /opt 11 /dev/mapper/vg_vbok-usr 12 39G 3.2G 34G 9% /usr 13 /dev/sdb3 51G 16K 51G 1% /vfat
我在/opt下建立了個目錄 “1“ 下面有多個子目錄和檔案。然後我將其刪除。
(看看現在的時間)並回到extundelete 安裝目錄下將opt目錄掛載為只讀為了保護資料防止重寫。
1 [email protected] /]# cd opt/ 2 [[email protected] opt]# ls 3 1 lost+found rh 4 [[email protected] opt]# date 5 2013年 10月 14日 星期一 16:44:55 CST 6 [[email protected] opt]# rm -rf 1 7 [[email protected] opt]# ls 8 lost+found rh 9 [[email protected] opt]# cd /usr/local/src/extundelete-0.2.4 10 [[email protected] extundelete-0.2.4]# mount -o remount,ro /dev/mapper/vg_vbok-opt
這裡說下我要用到的引數 src/extundelete --help
1 --restore-directory 'path' 2 Will restore directory 'path'. 'path' is relative to the 3 --restore-all Attempts to restore everything. 4 --after dtime Only process entries deleted on or after 'dtime'. 5 --before dtime Only process entries deleted before 'dtime'.
第一個是 恢復目錄 path為路徑後面跟要恢復那個目錄的路徑
第二個是 恢復所有
第三個是 恢復dtime這個時間戳以後刪除的檔案
第四個是恢復這個時間戳以前刪除的檔案 (這裡說下,卡時間恢復是非常好用的引數。你可以指定恢復那個時間到那個時間之間的資料)
基本這幾個選項就夠恢復了,當然還有--restore-files 引數來恢復單個檔案。
OK開始
我上面在刪除的時間date了下系統時間所以我就來生成下 刪除前和刪除後的時間戳用來定位我要恢復的目錄,然後利用工具恢復刪除的目錄
[[email protected] extundelete-0.2.4]# date -d "2013-10-14 16:43" +%s 1381740180 [[email protected] extundelete-0.2.4]# date -d "2013-10-14 16:58" +%s 1381741080 [[email protected] extundelete-0.2.4]# src/extundelete /dev/mapper/vg_vbok-opt --after /1381740180 --before 1381741080 --restore-directory 1
OK恢復完成,這裡要注意的是在用恢復目錄選項的時候,後面接的目錄是以opt後的目錄。也就是說 /dev/mapper/vg-vbox-opt 已經代表了/opt這個目錄我們只需要接著寫 opt後面的目錄 例如要恢復/opt/1/2/3 這個目錄 我們後面的路徑為 1/2/3 就可以恢復3這個目錄了 當然有時間戳指定時間段後就可以用--restore-all恢復這個時間段刪除的所有資料了。OK
1 NOTICE: Extended attributes are not restored. 2 Loading filesystem metadata ... 86 groups loaded. 3 Loading journal descriptors ... 91 descriptors loaded. 4 Searching for recoverable inodes in directory 1 ... 5 9 recoverable inodes found. 6 Looking through the directory structure for deleted files ... 7 1 recoverable inodes still lost. 8 [[email protected] extundelete-0.2.4]# cd RECOVERED_FILES/ 9 [[email protected] RECOVERED_FILES]# LS 10 -bash: LS: command not found 11 [[email protected] RECOVERED_FILES]# ls 12 1 13 [[email protected] RECOVERED_FILES]# cd 1 14 [[email protected] 1]# ls 15 11 22 16 [[email protected] 1]# cd 11/ 17 [[email protected] 11]# ls 18 2 a 19 [[email protected] 11]# cd ../22/c 20 -bash: cd: ../22/c: 不是目錄 21 [[email protected] 11]# cd ../22/c
資料 完好無損。
在講/opt這個分割槽掛載回讀寫的,不會的可以reboot重啟下也可以
相關推薦
centOS6.4 extundelete工具恢復rm -rf 刪除的目錄
PS:補充下,我在fedora 19上執行的時候遇到的一個問題: 1 [[email protected] extundelete-0.2.4]# ./configure 2 Configuring extundelete 0.2.4 3 configure: error: in `/us
利用extundelete工具恢復Centos6.5中誤刪除的文件
tun 新建 開啟 系統 本地用戶 img e2fsprogs src cover 實驗目的:利用extundelete工具恢復誤刪除的文件實驗環境:在Linux系統中安裝一臺Centos6.5在Centos6.5中新增磁盤並創建分區,模擬刪除並進行回復的操作設置文件共享權
CentOS 恢復 rm -rf * 誤刪資料--extundelete
一、 將磁碟分割槽掛載為只讀 這一步很重要,並且在誤刪除檔案後應儘快將磁碟掛載為只讀。越早進行,恢復的成功機率就越大。 1. 檢視被刪除檔案位於哪個分割槽 [root@localhost ~]# mount/dev/mapper/VolGroup-lv_roo
linux ext3 ext4 檔案系統 rm -rf刪除後資料快速恢復
linux ext3 ext4 rm -rf刪除後資料快速恢復辦法: rm -rf 後一定不要再在所在分割槽上增加和修改檔案!!!否則會把已刪除檔案覆蓋掉!!! 1.檢視磁碟檔案系統格式:ext3 [[email protected]_45_128_cento
rm -rf 刪除文件後磁盤空間不釋放
總結當一個服務器的磁盤空間滿了後,執行rm -rf命令以後,磁盤空間沒有被釋放可以使用lsof | grep delete命令來查看刪除進程,然後kill掉相關的進程以後就可以釋放空間了rm -rf 刪除文件後磁盤空間不釋放
Linux - rm -rf 刪除檔案指定移動檔案位置 (李作強)
rm -rf 刪除檔案指定移動檔案位置。 建立回收站機制,它並不真正執行刪除操作,而是將檔案移動到一個特定目錄,可以設定定時清除回收站,或者在回收站裡面的檔案大小達到一定容量時(或者用時間做判斷)執行刪除操作以騰出空間。可以寫個shell指令碼替換rm命令,或者在需要刪除檔案的時候使用mv命
Linux rm -rf刪除檔案不釋放空間的解決辦法
前幾天發現在Linux系統下有一個很大的無用檔案,於是用rm -rf 刪除,然後用df -h檢視磁碟空間,發現即使檔案被刪除了,但檔案所佔用的空間並未釋放,十分疑惑,於是在網上找到了解決方案,即使用lsof | grep deleted檢視佔用的程序並kill相
linux下如何恢復rm命令刪除的檔案
在linux下rm -rf 是一個很可怕的命令,因為下達這個命令意味著一旦刪除的檔案是無法挽回的,事實是如此嗎?真的沒有補救措施了嗎?答案是委婉了,在一定的條件下可以補救,大家可能熟悉windows下刪除的補救措施是通過相關的軟體實現的,在linux下同樣可以做到補救,但是
CentOS 恢復 rm -rf * 誤刪資料
一、 將磁碟分割槽掛載為只讀 這一步很重要,並且在誤刪除檔案後應儘快將磁碟掛載為只讀。越早進行,恢復的成功機率就越大。 1. 檢視被刪除檔案位於哪個分割槽 [root@localhost ~]# mount/dev/mapper/VolGroup-lv_root on / type ext
rm -rf 刪除檔案失敗
TF卡為ext2,用指令碼不斷向TF卡中追加式的寫檔案。每個檔案5M,寫滿400個檔案之後刪除。重複此操作 1) 單純寫TF卡的讀寫操作,寫2次TF卡正常 2) 寫了2次之後重啟裝置,再繼續寫,寫到第444的時候出錯,test_ucsrunlog_44.log檔案不能
Linux中如何恢復rm命令誤刪除的文件之extundelete編譯安裝及使用
可用 並且 地址 cat inode res 丟失 lin 所在 1、下載extundelete包,安裝依賴 我用的是Centos系統,在安裝extundelete之前需要安裝e2fsprogs,e2fsprogs-libs,e2fsprogs-devel。 yum in
恢復磁碟誤刪除的資料--extundelete工具
1.extundelete是什麼 2.extundelete恢復資料 2.1 epel 倉庫安裝 yum install extundelete -y ...........................................................
Rm –rf誤刪除了一個數據檔案,而備份集恰好損壞,請寫出恢復步驟
Oracle使用者下: rm -rf /u01/app/oracle/oradata/vastdb/users01.dbf ps -ef | grep ora_lgwr ps命令將某個程序顯示出來 grep命令是查詢 中間的|是管道命令 是指ps命令與g
linux_檔案刪除的恢復(rm -rf *)
檔案刪除,需要進行恢復。 1. lsof 檔案剛剛被刪除,想要恢復,先嚐試lsof. #lsof |grep data.file1 # cp /proc/xxx/xxx/xx /dir/data.file1 2. 如果lsof不能看到檔
centos rm -rf 恢復刪除的檔案
Linux下執行 rm 並不會真正刪除,而是將inode節點中的扇區刪除,同時釋放資料塊。在資料塊被系統重新分配前,這部分資料還是可以找回來的。 網上說在刪除檔案後要立即unmount這個分割槽,這樣做其實是為了讓外界不再寫入,我們也可以設定為readonly模式代替。當然,如果為了不影響其它應用的執行
Oracle資料庫資料檔案rm -rf誤刪除後恢復
Oracle資料庫中表空間的資料檔案在基於OS系統級別被rm -rf 刪除後,只要資料庫在刪除後一直未被shutdown,那麼就可以手動恢復,恢復的前提是Oracle安裝在Linux系統下,下面是一個例項模擬 1. 在資料庫open的時候,直接刪除users表空間中的
Linux防止“rm -rf /”誤刪除
com 程序 -a user get prev tar acc 安裝 說明:不解釋了,運維應該在每臺服務器都去配置這個問題以減少災難的發生 方法: 1、safe-rm safe-rm是一個開源軟件用來替代不太安全的rm,可以在/etc/safe-rm.conf中配置路
在linux下使用debugfs恢復rm刪除的文件
恢復在linux下使用debugfs恢復rm刪除的文件?? 以下方法在ext3的文件系統上測試通過, 以下是通過root來實現的?主要借助debugfs fdisk /dev/vdamkdir /mnt/testmount /dev/vda3 /mnt/test1 運行debugfs,進入調度模式[root
linux系統下文件夾以及文件的權限查看及修改;以及文件和文件夾刪除 rm -rf 命令的使用
系統 chang html 更改 修改文件 art 文件名 mage 管理命令 1、直接查看文件或者文件夾的權限命令: >>ll 或者 >>ls -l r代表讀取權限,w寫權限,x代表執行權限 第一個代表文件類型,-代表是普通文件,d代表是文
MongoDB 4.0 備份恢復工具引數介紹
# ./mongo --version MongoDB shell version v4.0.2 git version: fc1573ba18aee42f97a3bb13b67af7d837826b47 OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2