fdisk引发的困惑

来源:互联网 发布:51单片机汇编指令表 编辑:程序博客网 时间:2024/05/21 05:57
验证一份备份数据的有效性,将备份数据组织成卷的格式,通过iSCSI协议挂载到本地,用fdisk工具查看,发现挂载上来的卷与原卷存在很大的差异:
/dev/sdb1是原卷
/dev/sdc1是挂载过来的

[root@Redhat5-32-real ~]# fdisk -l

Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14      121601   976655610   8e  Linux LVM

WARNING: GPT (GUID Partition Table) detected on '/dev/sdb'! The util fdisk doesn't support GPT. Use GNU Parted.


WARNING: The size of this disk is 6.0 TB (5999532441600 bytes).
DOS partition table format can not be used on drives for volumes
larger than 2.2 TB (2199023255040 bytes). Use parted(1) and GUID 
partition table format (GPT).


Disk /dev/sdb: 5999.5 GB, 5999532441600 bytes
255 heads, 63 sectors/track, 729401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1      267350  2147483647+  ee  EFI GPT

WARNING: GPT (GUID Partition Table) detected on '/dev/sdc'! The util fdisk doesn't support GPT. Use GNU Parted.


WARNING: The size of this disk is 6.0 TB (5999533474304 bytes).
DOS partition table format can not be used on drives for volumes
larger than 2.2 TB (2199023255040 bytes). Use parted(1) and GUID 
partition table format (GPT).


Disk /dev/sdc: 5999.5 GB, 5999533474304 bytes
255 heads, 63 sectors/track, 729401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1      194704  1563952112   ee  EFI GPT

/dev/sdc1柱面数(cylinders )比原卷/dev/sdb1少了很多,
而且输出的/dev/sdb1的信息貌似也不对,柱面数=End-Start+1=267350,按照这个值
/dev/sdb1的大小应该为 柱面大小*柱面数= 8225280byte * 267350 = 2199028608000byte,约为2TB
/dev/sdc1的大小应该为 柱面大小*柱面数= 8225280byte * 194704  1601494917120byte,约为1.5TB

用df工具查看,发现mount上后没有任何差异
[root@Redhat5-32-real ~]# df -h
文件系统              容量  已用 可用 已用% 挂载点
/dev/mapper/VolGroup00-LogVol00
                      898G   14G  838G   2% /
/dev/sda1              99M   13M   81M  14% /boot
tmpfs                 8.0G     0  8.0G   0% /dev/shm
/dev/sdb1             5.4T  4.2T 1005G  81% /data
/dev/sdc1             5.4T  4.2T 1005G  81% /test

用diff工具比较,里面的文件似乎也没有差异
[root@Redhat5-32-real ~]# diff -rq /data /test

感觉有些纳闷,对比两个卷GPT头(由于/dev/sdc的GPT信息是自己构造的,所以部分字段与/dev/sdb不同是正常的)
[root@Redhat5-32-real ~]# hexdump -C /dev/sdb -s 0x200 -n 512
00000200  45 46 49 20 50 41 52 54  00 00 01 00 5c 00 00 00  |EFI PART....\...|
00000210  a5 86 af fe 00 00 00 00  01 00 00 00 00 00 00 00  |................|
00000220  ff ff 6f ba 02 00 00 00  22 00 00 00 00 00 00 00  |..o.....".......|
00000230  de ff 6f ba 02 00 00 00  c3 7c 50 8e 67 c7 6e 4f  |..o......|P.g.nO|
00000240  bd ff 7b 38 15 c9 61 df  02 00 00 00 00 00 00 00  |..{8..a.........|
00000250  80 00 00 00 80 00 00 00  de f1 38 58 00 00 00 00  |..........8X....|
00000260  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000400

解析:0x220~0x227,GPT头备份位置的扇区号:0x2ba6fffff,即LBA 11717836799
           0x228~0x22f,GPT分区区域的起始扇区号:0x22,即LBA 34
           0x230~0x237,GPT分区区域的结束扇区号:0x2ba6fffde,即LBA 11717836766

[root@Redhat5-32-real ~]# hexdump -C /dev/sdc -s 0x200 -n 512
00000200  45 46 49 20 50 41 52 54  00 00 01 00 5c 00 00 00  |EFI PART....\...|
00000210  e7 bc 31 47 00 00 00 00  01 00 00 00 00 00 00 00  |..1G............|
00000220  e0 07 70 ba 02 00 00 00  22 00 00 00 00 00 00 00  |..p.....".......|
00000230  bf 07 70 ba 02 00 00 00  b0 5b 40 b6 39 ce 4a 7f  |..p......[@.9.J.|
00000240  92 fe be 69 96 ff c9 00  02 00 00 00 00 00 00 00  |...i............|
00000250  80 00 00 00 80 00 00 00  21 17 22 3f 00 00 00 00  |........!."?....|
00000260  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000400

解析:0x220~0x227,GPT头备份位置的扇区号:0x2ba7007e0,即LBA 11717838816
           0x228~0x22f,GPT分区区域的起始扇区号:0x22,即LBA 34
           0x230~0x237,GPT分区区域的结束扇区号:0x2ba7007bf,即LBA 11717838783

继续对比两个卷GPT分区表
[root@Redhat5-32-real ~]# hexdump -C /dev/sdb -s 0x400 -n 512
00000400  a2 a0 d0 eb e5 b9 33 44  87 c0 68 b6 b7 26 99 c7  |......3D..h..&..|
00000410  41 fa 18 f2 8b d4 49 43  92 43 f4 6e b3 fb 62 1b  |A.....IC.C.n..b.|
00000420  22 00 00 00 00 00 00 00  de ff 6f ba 02 00 00 00  |".........o.....|
00000430  00 00 00 00 00 00 00 00  70 00 72 00 69 00 6d 00  |........p.r.i.m.|
00000440  61 00 72 00 79 00 00 00  00 00 00 00 00 00 00 00  |a.r.y...........|
00000450  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000600

0x420~0x427: 分区起始扇区,0x22,即LBA 34
0x428~0x42f: 分区结束扇区,0x2ba6fffde,即LBA 11717836766
磁盘/dev/sdb 分区表记录的分区结束扇区为LBA 11717836766,与GPT头记录的结束扇区号保持一致

[root@Redhat5-32-real ~]# hexdump -C /dev/sdc -s 0x400 -n 512
00000400  a2 a0 d0 eb e5 b9 33 44  87 c0 68 b6 b7 26 99 c7  |......3D..h..&..|
00000410  75 5a 99 2f 71 c3 46 60  a2 15 e1 91 94 e0 a8 96  |uZ./q.F`........|
00000420  00 08 00 00 00 00 00 00  b8 07 70 ba 02 00 00 00  |..........p.....|
00000430  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000600

0x420~0x427: 分区起始扇区,0x800,即LBA 2048
0x428~0x42f: 分区结束扇区:0x2ba7007b8,即LBA 11717838776
为什么磁盘/dev/sdc GPT头记录的结束扇区号为LBA 11717838783,而分区表记录的分区结束扇区为LBA 11717838776呢?

继续对比超级块的关键信息
[root@Redhat5-32-real ~]# dumpe2fs -h /dev/sdb1
Inode count:              732364800
Block count:              1464729591
Reserved block count:     73236479
Free blocks:              336557471
Free inodes:              731955325
First block:              0
Block size:               4096
Fragment size:            4096
Reserved GDT blocks:      674
Blocks per group:         32768
Fragments per group:      32768
Inodes per group:         16384
Inode blocks per group:   512
First inode:              11
Inode size:   128
Journal inode:            8
Default directory hash:   tea
Directory Hash Seed:      a70e527a-a4c7-4276-9460-9288f9f85b56
Journal backup:           inode blocks
Journal size:             128M

[root@Redhat5-32-real ~]# dumpe2fs -h /dev/sdc1
Inode count:              732364800
Block count:              1464729591
Reserved block count:     73236479
Free blocks:              336610606
Free inodes:              731955965
First block:              0
Block size:               4096
Fragment size:            4096
Reserved GDT blocks:      674
Blocks per group:         32768
Fragments per group:      32768
Inodes per group:         16384
Inode blocks per group:   512
First inode:              11
Inode size:   128
Journal inode:            8
Default directory hash:   tea
Directory Hash Seed:      a70e527a-a4c7-4276-9460-9288f9f85b56
Journal backup:           inode blocks
Journal size:             128M

iNode计数,Block计数,Reserved block计数都是一致的

难道是文件系统有问题?
umount,用fsck检测文件系统
[root@Redhat5-32-real ~]# umount /test
[root@Redhat5-32-real ~]# fsck -n /dev/sdc1
fsck 1.39 (29-May-2006)
e2fsck 1.39 (29-May-2006)
Warning: skipping journal recovery because doing a read-only filesystem check.
/dev/sdc1 contains a file system with errors, check forced.
Pass 1: Checking inodes, blocks, and sizes
Inode 255115775, i_size is 212992, should be 225280.  Fix? no


Inode 255115775, i_blocks is 432, should be 456.  Fix? no


Inode 255115776, i_size is 212992, should be 225280.  Fix? no


Inode 255115776, i_blocks is 432, should be 456.  Fix? no


Inode 255115777, i_size is 212992, should be 225280.  Fix? no


Inode 255115777, i_blocks is 432, should be 456.  Fix? no


Inode 255115778, i_size is 212992, should be 225280.  Fix? no


Inode 255115778, i_blocks is 432, should be 456.  Fix? no


Inode 255115779, i_size is 212992, should be 225280.  Fix? no


Inode 255115779, i_blocks is 432, should be 456.  Fix? no

额,构造的卷文件系统有问题,不过,fdisk获取的信息从哪里来的呢?困惑...
不知道能否找到fdisk的源码瞅瞅,或许能从中找到答案。

0 0
原创粉丝点击