=====================================================================================
下面我们再看一个较为复杂的例子
这是一个用到多个 block 的文件,不像上面只用到1个 block 而已。
[root@mail tmp]# filefrag -v xinetd.conf-manual
Checking xinetd.conf-manual
Filesystem type is: ef53
Filesystem cylinder groups is approximately 7440
Blocksize of file xinetd.conf-manual is 4096
File size of xinetd.conf-manual is 36736 (9 blocks)
First block: 2769171
Last block: 2769199
Discontinuity: Block 1 is at 2769184 (was 2769171)
Discontinuity: Block 5 is at 2769189 (was 2769187)
Discontinuity: Block 7 is at 2769198 (was 2769190)
xinetd.conf-manual: 4 extents found, perfection would be 1 extent
[root@mail tmp]#
可以看到它其实可以分成四组 block group
2769171 ~ 2769171 (1 block)
2769184 ~ 2769187 ( 4 blocks)
2769189 ~ 2769190 (2 blocks )
2769198 ~ 2769199 (2 blocks )
合计 : 1 + 4 + 2 + 2 = 9 blocks ,刚好等于上面 filefrag 的输出
有一点要特别注意的,block 的编号是从 #0 开始,而不是从 1# 开始
下面我们就分四次分部分恢复
第一部分
root@mail tmp]# dd if=/dev/hdb2 of=part1 bs=4096 count=1 skip=2769171
1+0 records in
1+0 records out
第二部分
[root@mail tmp]# dd if=/dev/hdb2 of=part2 bs=4096 count=4 bs=4096 skip=2769184
4+0 records in
4+0 records out
[root@mail tmp]#
第三部分
[root@mail tmp]# dd if=/dev/hdb2 of=part3 bs=4096 count=2 skip=2769189
2+0 records in
2+0 records out
第4部分
[root@mail tmp]# dd if=/dev/hdb2 of=par4 bs=4096 count=2 skip=2769198
2+0 records in
2+0 records out
[root@mail tmp]#
最后把它们合并在一起
[root@mail tmp]# cat part1 part2 part3 par4 > recover
[root@mail tmp]#
当前需要比较一下是否有差异了
[root@mail tmp]# diff recover xinetd.conf-manual
922d921
<
/ No newline at end of file
[root@mail tmp]#
为什么会出现上面的东西呢?看下面的图就知道了
这是原文件的结尾部分
这是合并后的 recover 文件的结尾部分
看到那些 '^@' 字符了吗?这是 NULL 字符。
用 vi 打开把最后的 '^@' 行删除,再报存退出
[root@mail tmp]# diff recover xinetd.conf-manual
[root@mail tmp]#
hoho,现在两个文件一致了,说明恢复工作成功了 !!
=====================================================================================
[
本帖最后由 ailms 于 2007-9-5 00:23 编辑 ]