Chinaunix首页 | 论坛 | 博客
  • 博客访问: 237941
  • 博文数量: 59
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 592
  • 用 户 组: 普通用户
  • 注册时间: 2014-04-01 12:51
个人简介

你们都是我的客户,所以,我对你们是透明的

文章分类

全部博文(59)

文章存档

2016年(29)

2015年(30)

分类: LINUX

2015-11-20 10:33:45

a、sdb分区,挂载到/data
[root@localhost ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-LogVol01
                      6.3G  1.8G  4.2G  30% /
tmpfs                 372M     0  372M   0% /dev/shm
/dev/sda1             194M   28M  156M  16% /boot
[root@localhost ~]# mkdir /data
[root@localhost ~]# mkfs.ext4 /dev/sdb1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
262144 inodes, 1048233 blocks
52411 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1073741824
32 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736

Writing inode tables: done                           
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information:
done

This filesystem will be automatically checked every 29 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[root@localhost ~]#
[root@localhost ~]# mount /dev/sdb1 /data
[root@localhost ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-LogVol01
                      6.3G  1.8G  4.2G  30% /
tmpfs                 372M     0  372M   0% /dev/shm
/dev/sda1             194M   28M  156M  16% /boot
/dev/sdb1             4.0G   72M  3.7G   2% /data

b、安装几个包,extundelete所必须
[root@localhost yum.repos.d]# yum install -y gcc gcc-c++ e2fsprogs e2fsprogs-libs e2fsprogs-devel

c、安装extundelete
[root@localhost yum.repos.d]# cd
[root@localhost ~]# ls -rtl
total 152
-rw-r--r--. 1 root root 108472 Nov 19 00:54 extundelete-0.2.4.tar.bz2
-rw-r--r--. 1 root root   7572 Nov 19 20:48 install.log.syslog
-rw-r--r--. 1 root root  26876 Nov 19 20:50 install.log
-rw-------. 1 root root   1325 Nov 19 20:50 anaconda-ks.cfg
[root@localhost ~]# tar -xf extundelete-0.2.4.tar.bz2
[root@localhost ~]# ls
anaconda-ks.cfg  extundelete-0.2.4  extundelete-0.2.4.tar.bz2  install.log  install.log.syslog
[root@localhost ~]# cd extundelete-0.2.4
[root@localhost extundelete-0.2.4]# ls
acinclude.m4  autogen.sh   configure     depcomp     LICENSE      Makefile.in  README
aclocal.m4    config.h.in  configure.ac  install-sh  Makefile.am  missing      src
[root@localhost extundelete-0.2.4]# ./configure
Configuring extundelete 0.2.4
Writing generated files to disk
[root@localhost extundelete-0.2.4]# make&&make install
make -s all-recursive
Making all in src
extundelete.cc:571: warning: unused parameter 鈥榝lags鈥
Making install in src
  /usr/bin/install -c extundelete '/usr/local/bin'
[root@localhost extundelete-0.2.4]# extundelete -version
extundelete version 0.2.4
libext2fs version 1.41.12
Processor is little endian.

d、创建测试文件test1
[root@localhost extundelete-0.2.4]# cd /data
[root@localhost data]# ls
lost+found
[root@localhost data]# mkdir test
[root@localhost data]# cat /etc/issue > test
-bash: test: Is a directory
[root@localhost data]# cat /etc/issue > test1
[root@localhost data]# more /proc/meminfo >>test1
[root@localhost data]# ls -rtl
total 24
drwx------. 2 root root 16384 Nov 19 21:07 lost+found
drwxr-xr-x. 2 root root  4096 Nov 19 21:12 test
-rw-r--r--. 1 root root  1245 Nov 19 21:13 test1

md5校验
[root@localhost data]# md5sum test1
e58c6499cb23c55316ebbcedb4da2741  test1
[root@localhost data]# md5sum test
md5sum: test: Is a directory
[root@localhost data]#

删除test1
[root@localhost data]# rm test1
rm: remove regular file `test1'? y
[root@localhost data]# ls -rtl
total 20
drwx------. 2 root root 16384 Nov 19 21:07 lost+found
drwxr-xr-x. 2 root root  4096 Nov 19 21:12 test

umount /data防止数据被覆盖
[root@localhost ~]# umount /data
[root@localhost ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-LogVol01
                      6.3G  1.9G  4.1G  32% /
tmpfs                 372M     0  372M   0% /dev/shm
/dev/sda1             194M   28M  156M  16% /boot
/dev/sr0              3.5G  3.5G     0 100% /mnt/dvd

检查一下inode
[root@localhost ~]# extundelete --inode 2 /dev/sdb1
NOTICE: Extended attributes are not restored.
Loading filesystem metadata ... 32 groups loaded.
Group: 0
Contents of inode 2:
0000 | ed 41 00 00 00 10 00 00 09 82 4e 56 07 82 4e 56 | .A........NV..NV
0010 | 07 82 4e 56 00 00 00 00 00 00 04 00 08 00 00 00 | ..NV............
0020 | 00 00 00 00 03 00 00 00 21 21 00 00 00 00 00 00 | ........!!......
0030 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
0040 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
0050 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
0060 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
0070 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
0080 | 1c 00 00 00 34 f6 9d 69 34 f6 9d 69 c8 38 26 6e | ....4..i4..i.8&n
0090 | 5e 80 4e 56 00 00 00 00 00 00 00 00 00 00 00 00 | ^.NV............
00a0 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
00b0 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
00c0 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
00d0 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
00e0 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
00f0 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................

Inode is Allocated
File mode: 16877
Low 16 bits of Owner Uid: 0
Size in bytes: 4096
Access time: 1447985673
Creation time: 1447985671
Modification time: 1447985671
Deletion Time: 0
Low 16 bits of Group Id: 0
Links count: 4
Blocks count: 8
File flags: 0
File version (for NFS): 0
File ACL: 0
Directory ACL: 0
Fragment address: 0
Direct blocks: 8481, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
Indirect block: 0
Double indirect block: 0
Triple indirect block: 0

File name                                       | Inode number | Deleted status
.                                                 2
..                                                2
lost+found                                        11
test                                              131073
test1                                             12             Deleted
[root@localhost ~]#

恢复文件
[root@localhost ~]# extundelete /dev/sdb1  --restore-file test1
NOTICE: Extended attributes are not restored.
Loading filesystem metadata ... 32 groups loaded.
Loading journal descriptors ... 29 descriptors loaded.
Successfully restored file test1
[root@localhost ~]# ls -rtl
total 160
-rw-r--r--. 1 root root 108472 Nov 19 00:54 extundelete-0.2.4.tar.bz2
-rw-r--r--. 1 root root   7572 Nov 19 20:48 install.log.syslog
-rw-r--r--. 1 root root  26876 Nov 19 20:50 install.log
-rw-------. 1 root root   1325 Nov 19 20:50 anaconda-ks.cfg
drwxr-xr-x. 3 1000 1000   4096 Nov 19 21:12 extundelete-0.2.4
drwxr-xr-x. 2 root root   4096 Nov 19 21:15 RECOVERED_FILES
[root@localhost ~]# cd RECOVERED_FILES/
[root@localhost RECOVERED_FILES]# ls
test1

校验md5是否和删除前相同
[root@localhost RECOVERED_FILES]# md5sum test1
e58c6499cb23c55316ebbcedb4da2741  test1
[root@localhost RECOVERED_FILES]#


附:
extundelete下载官网

 
阅读(2206) | 评论(0) | 转发(0) |
0

上一篇:rac 11204 卸载

下一篇:ORA-27125

给主人留下些什么吧!~~