
[root@docking ~]# echo "This is DeleteFile test." > deletefile.txt[root@docking ~]# lsdeletefile.txt[root@docking ~]# cat >> deletefile.txt Add SomeLine into deletefile forfun.
[root@docking ~]# lsdeletefile.txt[root@docking ~]# cat deletefile.txt This is DeleteFile test.Add SomeLine into deletefile forfun.
[root@docking ~]# rm -f deletefile.txt [root@docking ~]# ls
[root@docking ~]# lsof | grep deletefilecat 21796 root 1w REG 253,163138860 /root/deletefile.txt (deleted)
[root@docking ~]# cd /proc/21796/fd[root@docking fd]# ll总用量 0lrwx------ 1 root root 641月 1822:210 -> /dev/pts/0l-wx------ 1 root root 641月 1822:211 -> /root/deletefile.txt (deleted)lrwx------ 1 root root 641月 1822:212 -> /dev/pts/0恢复操作:[root@docking fd]# cp 1 ~/deletefile.txt.backup[root@docking fd]# cat ~/deletefile.txt.backup This is DeleteFile test.Add SomeLine into deletefile forfun.
mkdir backuptestcd backuptestmkdir deletetestmkdir deletetest/innerfolderecho"Delete a folder test." > deletetest/innerfolder/deletefile.txt echo"tcpdump:x:172:72::/:/sbin/nologin" > tmppasswd
taroballs@taroballs-PC:/media/taroballs/taroballs/backuptest$ cd ..taroballs@taroballs-PC:/media/taroballs/taroballs$ tree backuptest/backuptest/├── deletetest│ └── innerfolder│ └── deletefile.txt└── tmppasswd
taroballs@taroballs-PC:/media/taroballs/taroballs$ rm -rf backuptest/taroballs@taroballs-PC:/media/taroballs/taroballs$ ls -l
extundelete下载地址:http://extundelete.sourceforge.net/wget https://nchc.dl.sourceforge.net/project/extundelete/extundelete/0.2.4/extundelete-0.2.4.tar.bz2解压该文件tar jxvf extundelete-0.2.4.tar.bz2
[root@docking ~]# tar jxvf extundelete-0.2.4.tar.bz2 tar (child): bzip2:无法 exec: 没有那个文件或目录tar (child): Error isnot recoverable: exiting nowtar: Child returned status 2tar: Error isnot recoverable: exiting now则使用yum -y install bzip2进行解决[root@docking ~]# tar jxvf extundelete-0.2.4.tar.bz2 extundelete-0.2.4/extundelete-0.2.4/acinclude.m4extundelete-0.2.4/missingextundelete-0.2.4/autogen.shextundelete-0.2.4/aclocal.m4extundelete-0.2.4/configureextundelete-0.2.4/LICENSEextundelete-0.2.4/README...................................................cd extundelete-0.2.4./configure
[root@docking extundelete-0.2.4]# ./configure Configuring extundelete 0.2.4configure: error: in `/root/extundelete-0.2.4':configure: error: C++ compiler cannot create executablesSee `config.log' for more details则使用yum -y install gcc-c++解决.
[root@docking extundelete-0.2.4]# ./configure Configuring extundelete 0.2.4configure: error: Can't find ext2fs library则使用yum -y install e2fsprogs e2fsprogs-devel来解决。#Ubuntu的解决办法为sudo apt-get install e2fslibs-dev e2fslibs-dev
[root@docking extundelete-0.2.4]# ./configure Configuring extundelete 0.2.4Writing generated files to disk[root@docking extundelete-0.2.4]#
[root@docking extundelete-0.2.4]# makemake -s all-recursiveMaking all in srcextundelete.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 installMaking install in src /usr/bin/install -c extundelete '/usr/local/bin'extundelete安装完成.
taroballs@taroballs-PC:~$ df -lh文件系统 容量 已用 可用 已用% 挂载点udev 1.9G 01.9G 0% /devtmpfs 387M 1.8M 385M 1% /run/dev/sda2 92G 61G 26G 71% /tmpfs 1.9G 49M 1.9G 3% /dev/shmtmpfs 5.0M 4.0K 5.0M 1% /run/locktmpfs 1.9G 01.9G 0% /sys/fs/cgroup/dev/sda3 104G 56G 44G 57% /hometmpfs 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 0100% /media/taroballs/2018-01-16-12-36-00-00taroballs@taroballs-PC:~$ cd /media/taroballs/taroballs/taroballs@taroballs-PC:/media/taroballs/taroballs$ 可以看到,我们的目录/media/taroballs/taroballs挂载到/dev/sdb1 这个文件系统中.
taroballs@taroballs-PC:~$ df -lh | grep/dev/sdb1/dev/sdb1 6.8G 4.1G 2.8G 60% /media/taroballs/taroballsumount这个目录taroballs@taroballs-PC:~$ umount /media/taroballs/taroballstaroballs@taroballs-PC:~$ df -lh | grep/dev/sdb1taroballs@taroballs-PC:~$
taroballs@taroballs-PC:~$ mkdir recovertesttaroballs@taroballs-PC:~$ cd recovertest/taroballs@taroballs-PC:~/recovertest$
taroballs@taroballs-PC:/media/taroballs/taroballs$ sudo extundelete /dev/sdb1 --inode 2NOTICE: Extended attributes are not restored.Loading filesystem metadata ... 8 groups loaded.Group:0Contents of inode 2:..省略N行File name | Inode number | Deleted status. 2.. 2deletetest 12 Deletedtmppasswd 14 Deleted
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恢复文件是放到了当前目录RECOVERED_FILES。查看恢复的文件:taroballs@taroballs-PC:~/recovertest$ cat tmppasswd tcpdump:x:172:72::/:/sbin/nologin
extundelete /dev/sdb1 --restore-directory deletetestNOTICE: 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 ...
taroballs@taroballs-PC:~/recovertest$ extundelete /dev/sdb1 --restore-allNOTICE: 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└── tmppasswd2 directories, 2 files
taroballs@taroballs-PC:~/recovertest$ extundelete /dev/sdb1 --restore-inode 14NOTICE: 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
$ extundelete --helpUsage: extundelete [options] [--] device-fileOptions:--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_FILESwith their inode numberas extension (ie, file.12345).--restore-file 'path' Will restore file 'path'. 'path' is relative to rootof the partitionand does notstartwith a '/' The restored fileis created in the currentdirectoryas'RECOVERED_FILES/path'.--restore-files 'path' Will restore files which are listed in the file 'path'.Each filename should be in the same formatas an optionto--restore-file, and there should be one per line.--restore-directory 'path' Will restoredirectory'path'. 'path'isrelativeto the root directoryof the file system. The restoreddirectoryis created in the outputdirectoryas'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 blocksizeas the blocksizewhen opening the file system. The number should be the numberof 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: listof 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 specifiedlevel will be turned off. If the parameter is'=filename', messages with that level will be writtento filename. -o directorySave the recovered files to the named directory. The restored files are created in a directory named 'RECOVERED_FILES/'by default.


认准红帽官方授权
微思-红帽官方授权合作伙伴!


— Linux文章推荐 —









系统集成
认证培训
买设备,找我们
IT维保,找我们
IT培训,找我们