instalación de la herramienta extundelete
- Dirección de descarga de Extundelete: http://extundelete.sourceforge.net/
-
wget https://nchc.dl.sourceforge.net/project/extundelete/extundelete/0.2.4/extundelete-0.2.4.tar.bz2
Descomprima el archivo tar jxvf extundelete-0.2.4.tar.bz2
Si se informa este error:
[root@docking ~]# tar jxvf extundelete-0.2.4.tar.bz2
tar (child): bzip2:无法 exec: 没有那个文件或目录
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
Luego usa yum -y install bzip2 para resolver:
[root@docking ~]# tar jxvf extundelete-0.2.4.tar.bz2
extundelete-0.2.4/
extundelete-0.2.4/acinclude.m4
extundelete-0.2.4/missing
extundelete-0.2.4/autogen.sh
extundelete-0.2.4/aclocal.m4
extundelete-0.2.4/configure
extundelete-0.2.4/LICENSE
extundelete-0.2.4/README
...................................................
cd extundelete-0.2.4
./configure
Si este paso informa un error:
[root@docking extundelete-0.2.4]# ./configure
Configuring extundelete 0.2.4
configure: error: in `/root/extundelete-0.2.4':
configure: error: C++ compiler cannot create executables
See `config.log' for more details
Luego use yum -y install gcc-c++ para resolver.
Si aún informa un error después de ejecutar el paso anterior,
[root@docking extundelete-0.2.4]# ./configure
Configuring extundelete 0.2.4
configure: error: Can't find ext2fs library
Utilice yum -y install e2fsprogs e2fsprogs-devel para resolver.
La solución de Ubuntu es sudo apt-get install e2fslibs-dev e2fslibs-dev
Si no hay ningún accidente, la configuración debería poder completarse exitosamente aquí.
[root@docking extundelete-0.2.4]# ./configure
Configuring extundelete 0.2.4
Writing generated files to disk
[root@docking extundelete-0.2.4]#
Finalmente haga y luego haga la instalación.
[root@docking extundelete-0.2.4]# make
make -s all-recursive
Making all in src
extundelete.cc: 在函数‘ext2_ino_t find_inode(ext2_filsys, ext2_filsys, ext2_inode*, std::string, int)'中:
extundelete.cc:1272:29: 警告:在 {} 内将‘search_flags'从‘int'转换为较窄的类型‘ext2_ino_t {aka unsigned int}' [-Wnarrowing]
buf, match_name2, priv, 0};
^
[root@docking extundelete-0.2.4]# make install
Making install in src
/usr/bin/install -c extundelete '/usr/local/bin'
La instalación de extundelete está completa.
Escanee en busca de archivos eliminados accidentalmente:
Utilice df -lh para ver las monturas:
taroballs@taroballs-PC:~$ df -lh
文件系统 容量 已用 可用 已用% 挂载点
udev 1.9G 0 1.9G 0% /dev
tmpfs 387M 1.8M 385M 1% /run
/dev/sda2 92G 61G 26G 71% /
tmpfs 1.9G 49M 1.9G 3% /dev/shm
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/sda3 104G 56G 44G 57% /home
tmpfs 387M 40K 387M 1% /run/user/1000
/dev/sda4 70G 20G 47G 30% /media/taroballs/d8423f8c-d687-4c03-a7c8-06a7fb57f96d
/dev/sdb1 6.8G 4.1G 2.8G 60% /media/taroballs/taroballs
/dev/sr0 4.0G 4.0G 0 100% /media/taroballs/2018-01-16-12-36-00-00
taroballs@taroballs-PC:~$ cd /media/taroballs/taroballs/
taroballs@taroballs-PC:/media/taroballs/taroballs$
Como puedes ver, nuestro directorio /media/taroballs/taroballs
Móntelo en el sistema de archivos /dev/sdb1.
Desmontamos nuestro disco de montaje como por ejemplo:
taroballs@taroballs-PC:~$ df -lh | grep /dev/sdb1
/dev/sdb1 6.8G 4.1G 2.8G 60% /media/taroballs/taroballs
desmontar este directorio
taroballs@taroballs-PC:~$ umount /media/taroballs/taroballs
taroballs@taroballs-PC:~$ df -lh | grep /dev/sdb1
taroballs@taroballs-PC:~$
#记得删除一定要后umount哦,不然二次写入谁也帮不了你呢。
Recuperación por nodo de inodo
taroballs@taroballs-PC:~$ mkdir recovertest
taroballs@taroballs-PC:~$ cd recovertest/
taroballs@taroballs-PC:~/recovertest$
Ejecutar restaurar extundelete /dev/sdb1 --inode 2
taroballs@taroballs-PC:/media/taroballs/taroballs$ sudo extundelete /dev/sdb1 --inode 2
NOTICE: Extended attributes are not restored.
Loading filesystem metadata ... 8 groups loaded.
Group: 0
Contents of inode 2:
.
.省略N行
File name | Inode number | Deleted status
. 2
.. 2
deletetest 12 Deleted
tmppasswd 14 Deleted
La carpeta que eliminamos fue descubierta al escanear y ahora realizamos la operación de recuperación.
(1) Restaurar un solo archivo tmppasswd
taroballs@taroballs-PC:~/recovertest$ extundelete /dev/sdb1 --restore-file passwd
NOTICE: Extended attributes are not restored.
Loading filesystem metadata ... 8 groups loaded.
Loading journal descriptors ... 46 descriptors loaded.
Successfully restored file tmppasswd
Los archivos recuperados se colocan en el directorio actual RECOVERED_FILES.
Ver archivos recuperados:
taroballs@taroballs-PC:~/recovertest$ cat tmppasswd
tcpdump:x:172:72::/:/sbin/nologin
(2) Prueba de eliminación del directorio de recuperación
extundelete /dev/sdb1 --restore-directory deletetest
NOTICE: Extended attributes are not restored.
Loading filesystem metadata ... 8 groups loaded.
Loading journal descriptors ... 46 descriptors loaded.
Searching for recoverable inodes in directory deletetest ...
5 recoverable inodes found.
Looking through the directory structure for deleted files ...
(3) restaurar todo
taroballs@taroballs-PC:~/recovertest$ extundelete /dev/sdb1 --restore-all
NOTICE: Extended attributes are not restored.
Loading filesystem metadata ... 8 groups loaded.
Loading journal descriptors ... 46 descriptors loaded.
Searching for recoverable inodes in directory / ...
5 recoverable inodes found.
Looking through the directory structure for deleted files ...
0 recoverable inodes still lost.
taroballs@taroballs-PC:~/recovertest$ tree
backuptest/
├── deletetest
│ └── innerfolder
│ └── deletefile.txt
└── tmppasswd
2 directories, 2 files
(4) Restaurar el inodo especificado
taroballs@taroballs-PC:~/recovertest$ extundelete /dev/sdb1 --restore-inode 14
NOTICE: Extended attributes are not restored.
Loading filesystem metadata ... 8 groups loaded.
Loading journal descriptors ... 46 descriptors loaded.
taroballs@taroballs-PC:~/recovertest$ cat file.14
tcpdump:x:172:72::/:/sbin/nologin
#注意恢复inode的时候,恢复 出来的文件名和之前不一样,需要单独进行改名。
Finalmente, se adjunta el uso de extundelete:
$ extundelete --help
Usage: extundelete [options] [--] device-file
Options:
--version, -[vV] Print version and exit successfully.
--help, Print this help and exit successfully.
--superblock Print contents of superblock in addition to the rest.
If no action is specified then this option is implied.
--journal Show content of journal.
--after dtime Only process entries deleted on or after 'dtime'.
--before dtime Only process entries deleted before 'dtime'.
Actions:
--inode ino Show info on inode 'ino'.
--block blk Show info on block 'blk'.
--restore-inode ino[,ino,...]
Restore the file(s) with known inode number 'ino'.
The restored files are created in ./RECOVERED_FILES
with their inode number as extension (ie, file.12345).
--restore-file 'path' Will restore file 'path'. 'path' is relative to root
of the partition and does not start with a '/'
The restored file is created in the current
directory as 'RECOVERED_FILES/path'.
--restore-files 'path' Will restore files which are listed in the file 'path'.
Each filename should be in the same format as an option
to --restore-file, and there should be one per line.
--restore-directory 'path'
Will restore directory 'path'. 'path' is relative to the
root directory of the file system. The restored
directory is created in the output directory as 'path'.
--restore-all Attempts to restore everything.
-j journal Reads an external journal from the named file.
-b blocknumber Uses the backup superblock at blocknumber when opening
the file system.
-B blocksize Uses blocksize as the block size when opening the file
system. The number should be the number of bytes.
--log 0 Make the program silent.
--log filename Logs all messages to filename.
--log D1=0,D2=filename Custom control of log messages with comma-separated
Examples below: list of options. Dn must be one of info, warn, or
--log info,error error. Omission of the '=name' results in messages
--log warn=0 with the specified level to be logged to the console.
--log error=filename If the parameter is '=0', logging for the specified
level will be turned off. If the parameter is
'=filename', messages with that level will be written
to filename.
-o directory Save the recovered files to the named directory.
The restored files are created in a directory
named 'RECOVERED_FILES/' by default.