在CentOS系統中,如果誤刪除了文件,可以使用extundelete
工具來嘗試恢復數據。以下是使用extundelete
進行數據恢復的詳細步驟:
sudo yum install e2fsprogs* -y
wget http://nchc.dl.sourceforge.net/project/extundelete/extundelete/0.2.4/extundelete-0.2.4.tar.bz2
tar -jxvf extundelete-0.2.4.tar.bz2
cd extundelete-0.2.4
./configure --prefix=/usr/local/extundelete
make && make install
cd /usr/local/extundelete/bin
./extundelete -v
掃描文件:
/usr/local/extundelete/bin/extundelete /dev/sdb2 --inode 2
恢復單個文件:
/usr/local/extundelete/bin/extundelete --restore-file 1.txt /dev/sdb2
RECOVERED_FILES/
目錄中。恢復整個分區:
/usr/local/extundelete/bin/extundelete --restore-all /dev/sdb2
RECOVERED_FILES/
目錄中。mount -o remount,rw /dev/sdb2
請注意,數據恢復的成功率取決于文件被刪除后磁盤是否被新的數據覆蓋。因此,一旦發現誤刪除文件,應盡快停止使用相關分區,并盡快嘗試恢復。