分区表概述

            分区表概述

                              作者:尹正杰 

版权声明:原创作品,谢绝转载!否则将追究法律责任。

 

 

 

一.磁盘分区概述

1>.为什么要使用分区

  我们知道硬盘(磁盘)在不分区的情况下是可以使用的,那为什么要引入分区这个概念呢?

  使用分区带来的好处如下所示:
    (1)优化I/O性能
    (2)实现磁盘空间配额限制
    (3)提高修复速度
    (4)隔离系统和程序
    (5)安装多个操作系统(OS)
    (6)采用不同文件系统  

2>.分区方式

  目前有两种主流的分区方式:Master Boot Record(简称MBR)和GUID(Globals Unique Identifiers)partition table(简称GPT)

  MBR:(Master Boot Record):
    1982年,使用32位(4字节)表示扇区数,分区不超过2T(2的32次方 x 扇区数大小(512字节) = 2199023255552 Bytes/1024/1024/1024 = 2048GB/1024=2T)
    如何分区:
      按柱面(cylinder:)进行分区。需要注意的是0磁道0扇区有512bytes大小,其组成部分如下:
        446bytes: 
          boot loader
        64bytes:
          分区表,其中每16bytes标识一个分区
        2bytes: 
          55AA
    4个主分区;
      3主分区+1扩展(N个逻辑分区)

  GPT:GUID(Globals Unique Identifiers)partition table:
    支持128个分区,使用64位,支持8Z(512Byte/block)64Z(4096Byte/block)
    使用128位UUID(Universally Unique Identifier)表示磁盘和分区GPT分区表自动备份在头和尾两份,并有CRC校验位
    UEFI(统一扩展固件接口)硬件支持GPT,使操作系统启动

3>.使用分区空间

  使用分区空间大概分为以下几个步骤:
    (1)硬件设备识别
    (2)硬件设备分区
    (3)创建文件系统
    (4)标记文件系统
    (5)在/etc/fstab文件中创建条目
    (6)挂载到新的文件系统

4>.window默认使用的分区方式

  window 7默认使用的是MBR分区,window 10默认使用的是GPT分区。

  我们知道window 7官方已经停止维护啦,推荐大家使用window 10系统。

5>.Linux默认使用的分区方式

  如下图所示,CentOS 7.6及以上版本默认采用的就是GPT分区方式。 

 

二.Master Boot Record(简称MBR)分区方式概述

1>.MBR分区结构

  如下图所示 硬盘(磁盘)主引导记录MBR由4个部分组成:
    主引导程序(偏移地址0000H--0088H):
      它负责从活动分区中装载,并运行系统引导程序。
    出错信息数据区:       又称为数据区,偏移地址0089H
--00E1H为出错信息,00E2H--01BDH全为0字节。
    分区表(DPT,Disk Partition Table):       含4个分区项,偏移地址01BEH
--01FDH,每个分区表项长16个字节,共64字节,分别对应为分区项1、分区项2、分区项3、分区项4。     结束标志字:       偏移地址01FE--01FF的2个字节值为结束标志55AA。

  温馨提示:
    分区表不属于任何分区。因此生产环境中对分区表的备份尤为重要(温馨提示:继续往下翻可以看到分区表的备份恢复案例)。
    生产环境中如果你没有备份分区表这意味着数据丢失了你就再也找不回来了,但万一你真的没有备份也别着急,想一下有没有其它的服务器分区策略和你现在使用的分区策略是一致的,如果有你懂的接下来该咋操作了。

 

2>.MBR中DPT结构

3>.查看主分区表DPT的引导标志(80表示活动分区,00表示非活动分区)

[root@yinzhengjie.com ~]# lsblk 
NAME                   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                      8:0    0    2T  0 disk 
├─sda1                   8:1    0    2M  0 part 
├─sda2                   8:2    0    1G  0 part /boot
└─sda3                   8:3    0    2T  0 part 
  ├─centos-root        253:0    0  500G  0 lvm  /
  └─centos-yinzhengjie 253:1    0  1.5T  0 lvm  /yinzhengjie
sdb                      8:16   0  600G  0 disk 
sdc                      8:32   0  400G  0 disk 
sdd                      8:48   0  800G  0 disk 
sde                      8:64   0 1000G  0 disk 
sr0                     11:0    1 1024M  0 rom  
[root@yinzhengjie.com ~]# 
[root@yinzhengjie.com ~]# lsblk
[root@yinzhengjie.com ~]# fdisk -l

Disk /dev/sdb: 644.2 GB, 644245094400 bytes, 1258291200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.

Disk /dev/sda: 2199.0 GB, 2199023255552 bytes, 4294967296 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: gpt
Disk identifier: 60B0BC61-D7A6-4522-972F-E8B13E38A9C1


#         Start          End    Size  Type            Name
 1         2048         6143      2M  BIOS boot       
 2         6144      2103295      1G  Microsoft basic 
 3      2103296   4294723583      2T  Linux LVM       

Disk /dev/sdc: 429.5 GB, 429496729600 bytes, 838860800 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/sde: 1073.7 GB, 1073741824000 bytes, 2097152000 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/sdd: 859.0 GB, 858993459200 bytes, 1677721600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mapper/centos-root: 536.9 GB, 536870912000 bytes, 1048576000 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mapper/centos-yinzhengjie: 1660.9 GB, 1660944384000 bytes, 3244032000 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

[root@yinzhengjie.com ~]# 
[root@yinzhengjie.com ~]# fdisk -l
[root@yinzhengjie.com ~]# hexdump -C /dev/sda -n 512
00000000  eb 63 90 00 00 00 00 00  00 00 00 00 00 00 00 00  |.c..............|
00000010  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000050  00 00 00 00 00 00 00 00  00 00 00 80 00 08 00 00  |................|
00000060  00 00 00 00 ff fa 90 90  f6 c2 80 74 05 f6 c2 70  |...........t...p|
00000070  74 02 b2 80 ea 79 7c 00  00 31 c0 8e d8 8e d0 bc  |t....y|..1......|
00000080  00 20 fb a0 64 7c 3c ff  74 02 88 c2 52 be 05 7c  |. ..d|<.t...R..||
00000090  b4 41 bb aa 55 cd 13 5a  52 72 3d 81 fb 55 aa 75  |.A..U..ZRr=..U.u|
000000a0  37 83 e1 01 74 32 31 c0  89 44 04 40 88 44 ff 89  |7...t21..D.@.D..|
000000b0  44 02 c7 04 10 00 66 8b  1e 5c 7c 66 89 5c 08 66  |D.....f..\|f.\.f|
000000c0  8b 1e 60 7c 66 89 5c 0c  c7 44 06 00 70 b4 42 cd  |..`|f.\..D..p.B.|
000000d0  13 72 05 bb 00 70 eb 76  b4 08 cd 13 73 0d 5a 84  |.r...p.v....s.Z.|
000000e0  d2 0f 83 de 00 be 85 7d  e9 82 00 66 0f b6 c6 88  |.......}...f....|
000000f0  64 ff 40 66 89 44 04 0f  b6 d1 c1 e2 02 88 e8 88  |d.@f.D..........|
00000100  f4 40 89 44 08 0f b6 c2  c0 e8 02 66 89 04 66 a1  |.@.D.......f..f.|
00000110  60 7c 66 09 c0 75 4e 66  a1 5c 7c 66 31 d2 66 f7  |`|f..uNf.\|f1.f.|
00000120  34 88 d1 31 d2 66 f7 74  04 3b 44 08 7d 37 fe c1  |4..1.f.t.;D.}7..|
00000130  88 c5 30 c0 c1 e8 02 08  c1 88 d0 5a 88 c6 bb 00  |..0........Z....|
00000140  70 8e c3 31 db b8 01 02  cd 13 72 1e 8c c3 60 1e  |p..1......r...`.|
00000150  b9 00 01 8e db 31 f6 bf  00 80 8e c6 fc f3 a5 1f  |.....1..........|
00000160  61 ff 26 5a 7c be 80 7d  eb 03 be 8f 7d e8 34 00  |a.&Z|..}....}.4.|
00000170  be 94 7d e8 2e 00 cd 18  eb fe 47 52 55 42 20 00  |..}.......GRUB .|
00000180  47 65 6f 6d 00 48 61 72  64 20 44 69 73 6b 00 52  |Geom.Hard Disk.R|
00000190  65 61 64 00 20 45 72 72  6f 72 0d 0a 00 bb 01 00  |ead. Error......|
000001a0  b4 0e cd 10 ac 3c 00 75  f4 c3 00 00 00 00 00 00  |.....<.u........|
000001b0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 80 00  |................|
000001c0  01 00 ee fe ff ff 01 00  00 00 ff ff ff ff 00 00  |................|
000001d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
00000200
[root@yinzhengjie.com ~]# 
[root@yinzhengjie.com ~]# hexdump -C /dev/sda -n 512
[root@yinzhengjie.com ~]# hexdump -C /dev/sdb -n  512 -v
00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000010  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000020  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000030  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000040  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000050  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000060  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000070  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000080  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000090  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000000a0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000000b0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000000c0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000000d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000000e0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000000f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000100  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000110  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000120  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000130  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000140  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000150  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000160  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000170  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000180  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000190  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001a0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001b0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001c0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001e0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000200
[root@yinzhengjie.com ~]# 
[root@yinzhengjie.com ~]# hexdump -C /dev/sdb -n 512 -v          #未分区的硬盘(磁盘)其第一个扇区数据均为空(即每个字节均为00)

[root@yinzhengjie.com ~]# dd if=/dev/sda of=dpt bs=1 count=64 skip=446
64+0 records in
64+0 records out
64 bytes (64 B) copied, 0.000236195 s, 271 kB/s
[root@yinzhengjie.com ~]# 
[root@yinzhengjie.com ~]# ll
total 4
-rw-r--r-- 1 root root 64 May  7 03:10 dpt
[root@yinzhengjie.com ~]# 
[root@yinzhengjie.com ~]# hexdump -C dpt 
00000000  80 00 01 00 ee fe ff ff  01 00 00 00 ff ff ff ff  |................|
00000010  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000040
[root@yinzhengjie.com ~]# 
[root@yinzhengjie.com ~]# 
[root@yinzhengjie.com ~]# dd if=/dev/sda of=dpt bs=1 count=64 skip=446        #备份分区表(备份的数据建议大家放在别的服务器上,因为一旦当前服务器的分区表被破坏就意味着备份的数据拿不出来啦!)
[root@yinzhengjie.com ~]# hexdump -C /dev/sda -n  512 
00000000  eb 63 90 00 00 00 00 00  00 00 00 00 00 00 00 00  |.c..............|
00000010  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000050  00 00 00 00 00 00 00 00  00 00 00 80 00 08 00 00  |................|
00000060  00 00 00 00 ff fa 90 90  f6 c2 80 74 05 f6 c2 70  |...........t...p|
00000070  74 02 b2 80 ea 79 7c 00  00 31 c0 8e d8 8e d0 bc  |t....y|..1......|
00000080  00 20 fb a0 64 7c 3c ff  74 02 88 c2 52 be 05 7c  |. ..d|<.t...R..||
00000090  b4 41 bb aa 55 cd 13 5a  52 72 3d 81 fb 55 aa 75  |.A..U..ZRr=..U.u|
000000a0  37 83 e1 01 74 32 31 c0  89 44 04 40 88 44 ff 89  |7...t21..D.@.D..|
000000b0  44 02 c7 04 10 00 66 8b  1e 5c 7c 66 89 5c 08 66  |D.....f..\|f.\.f|
000000c0  8b 1e 60 7c 66 89 5c 0c  c7 44 06 00 70 b4 42 cd  |..`|f.\..D..p.B.|
000000d0  13 72 05 bb 00 70 eb 76  b4 08 cd 13 73 0d 5a 84  |.r...p.v....s.Z.|
000000e0  d2 0f 83 de 00 be 85 7d  e9 82 00 66 0f b6 c6 88  |.......}...f....|
000000f0  64 ff 40 66 89 44 04 0f  b6 d1 c1 e2 02 88 e8 88  |d.@f.D..........|
00000100  f4 40 89 44 08 0f b6 c2  c0 e8 02 66 89 04 66 a1  |.@.D.......f..f.|
00000110  60 7c 66 09 c0 75 4e 66  a1 5c 7c 66 31 d2 66 f7  |`|f..uNf.\|f1.f.|
00000120  34 88 d1 31 d2 66 f7 74  04 3b 44 08 7d 37 fe c1  |4..1.f.t.;D.}7..|
00000130  88 c5 30 c0 c1 e8 02 08  c1 88 d0 5a 88 c6 bb 00  |..0........Z....|
00000140  70 8e c3 31 db b8 01 02  cd 13 72 1e 8c c3 60 1e  |p..1......r...`.|
00000150  b9 00 01 8e db 31 f6 bf  00 80 8e c6 fc f3 a5 1f  |.....1..........|
00000160  61 ff 26 5a 7c be 80 7d  eb 03 be 8f 7d e8 34 00  |a.&Z|..}....}.4.|
00000170  be 94 7d e8 2e 00 cd 18  eb fe 47 52 55 42 20 00  |..}.......GRUB .|
00000180  47 65 6f 6d 00 48 61 72  64 20 44 69 73 6b 00 52  |Geom.Hard Disk.R|
00000190  65 61 64 00 20 45 72 72  6f 72 0d 0a 00 bb 01 00  |ead. Error......|
000001a0  b4 0e cd 10 ac 3c 00 75  f4 c3 00 00 00 00 00 00  |.....<.u........|
000001b0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 80 00  |................|
000001c0  01 00 ee fe ff ff 01 00  00 00 ff ff ff ff 00 00  |................|
000001d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
00000200
[root@yinzhengjie.com ~]# 
[root@yinzhengjie.com ~]# dd if=/dev/zero of=/dev/sda bs=1 count=64 seek=446
64+0 records in
64+0 records out
64 bytes (64 B) copied, 0.000681731 s, 93.9 kB/s
[root@yinzhengjie.com ~]# 
[root@yinzhengjie.com ~]# hexdump -C /dev/sda -n  512 -v
00000000  eb 63 90 00 00 00 00 00  00 00 00 00 00 00 00 00  |.c..............|
00000010  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000020  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000030  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000040  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000050  00 00 00 00 00 00 00 00  00 00 00 80 00 08 00 00  |................|
00000060  00 00 00 00 ff fa 90 90  f6 c2 80 74 05 f6 c2 70  |...........t...p|
00000070  74 02 b2 80 ea 79 7c 00  00 31 c0 8e d8 8e d0 bc  |t....y|..1......|
00000080  00 20 fb a0 64 7c 3c ff  74 02 88 c2 52 be 05 7c  |. ..d|<.t...R..||
00000090  b4 41 bb aa 55 cd 13 5a  52 72 3d 81 fb 55 aa 75  |.A..U..ZRr=..U.u|
000000a0  37 83 e1 01 74 32 31 c0  89 44 04 40 88 44 ff 89  |7...t21..D.@.D..|
000000b0  44 02 c7 04 10 00 66 8b  1e 5c 7c 66 89 5c 08 66  |D.....f..\|f.\.f|
000000c0  8b 1e 60 7c 66 89 5c 0c  c7 44 06 00 70 b4 42 cd  |..`|f.\..D..p.B.|
000000d0  13 72 05 bb 00 70 eb 76  b4 08 cd 13 73 0d 5a 84  |.r...p.v....s.Z.|
000000e0  d2 0f 83 de 00 be 85 7d  e9 82 00 66 0f b6 c6 88  |.......}...f....|
000000f0  64 ff 40 66 89 44 04 0f  b6 d1 c1 e2 02 88 e8 88  |d.@f.D..........|
00000100  f4 40 89 44 08 0f b6 c2  c0 e8 02 66 89 04 66 a1  |.@.D.......f..f.|
00000110  60 7c 66 09 c0 75 4e 66  a1 5c 7c 66 31 d2 66 f7  |`|f..uNf.\|f1.f.|
00000120  34 88 d1 31 d2 66 f7 74  04 3b 44 08 7d 37 fe c1  |4..1.f.t.;D.}7..|
00000130  88 c5 30 c0 c1 e8 02 08  c1 88 d0 5a 88 c6 bb 00  |..0........Z....|
00000140  70 8e c3 31 db b8 01 02  cd 13 72 1e 8c c3 60 1e  |p..1......r...`.|
00000150  b9 00 01 8e db 31 f6 bf  00 80 8e c6 fc f3 a5 1f  |.....1..........|
00000160  61 ff 26 5a 7c be 80 7d  eb 03 be 8f 7d e8 34 00  |a.&Z|..}....}.4.|
00000170  be 94 7d e8 2e 00 cd 18  eb fe 47 52 55 42 20 00  |..}.......GRUB .|
00000180  47 65 6f 6d 00 48 61 72  64 20 44 69 73 6b 00 52  |Geom.Hard Disk.R|
00000190  65 61 64 00 20 45 72 72  6f 72 0d 0a 00 bb 01 00  |ead. Error......|
000001a0  b4 0e cd 10 ac 3c 00 75  f4 c3 00 00 00 00 00 00  |.....<.u........|
000001b0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001c0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001e0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
00000200
[root@yinzhengjie.com ~]# 
[root@yinzhengjie.com ~]# dd if=/dev/zero of=/dev/sda bs=1 count=64 seek=446     #破坏分区表信息(请谨慎操作,该步骤操作后将意味着下次重启后你的分区信息全没了)
[root@yinzhengjie.com ~]# hexdump -C /dev/sda -n  512 -v
00000000  eb 63 90 00 00 00 00 00  00 00 00 00 00 00 00 00  |.c..............|
00000010  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000020  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000030  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000040  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000050  00 00 00 00 00 00 00 00  00 00 00 80 00 08 00 00  |................|
00000060  00 00 00 00 ff fa 90 90  f6 c2 80 74 05 f6 c2 70  |...........t...p|
00000070  74 02 b2 80 ea 79 7c 00  00 31 c0 8e d8 8e d0 bc  |t....y|..1......|
00000080  00 20 fb a0 64 7c 3c ff  74 02 88 c2 52 be 05 7c  |. ..d|<.t...R..||
00000090  b4 41 bb aa 55 cd 13 5a  52 72 3d 81 fb 55 aa 75  |.A..U..ZRr=..U.u|
000000a0  37 83 e1 01 74 32 31 c0  89 44 04 40 88 44 ff 89  |7...t21..D.@.D..|
000000b0  44 02 c7 04 10 00 66 8b  1e 5c 7c 66 89 5c 08 66  |D.....f..\|f.\.f|
000000c0  8b 1e 60 7c 66 89 5c 0c  c7 44 06 00 70 b4 42 cd  |..`|f.\..D..p.B.|
000000d0  13 72 05 bb 00 70 eb 76  b4 08 cd 13 73 0d 5a 84  |.r...p.v....s.Z.|
000000e0  d2 0f 83 de 00 be 85 7d  e9 82 00 66 0f b6 c6 88  |.......}...f....|
000000f0  64 ff 40 66 89 44 04 0f  b6 d1 c1 e2 02 88 e8 88  |d.@f.D..........|
00000100  f4 40 89 44 08 0f b6 c2  c0 e8 02 66 89 04 66 a1  |.@.D.......f..f.|
00000110  60 7c 66 09 c0 75 4e 66  a1 5c 7c 66 31 d2 66 f7  |`|f..uNf.\|f1.f.|
00000120  34 88 d1 31 d2 66 f7 74  04 3b 44 08 7d 37 fe c1  |4..1.f.t.;D.}7..|
00000130  88 c5 30 c0 c1 e8 02 08  c1 88 d0 5a 88 c6 bb 00  |..0........Z....|
00000140  70 8e c3 31 db b8 01 02  cd 13 72 1e 8c c3 60 1e  |p..1......r...`.|
00000150  b9 00 01 8e db 31 f6 bf  00 80 8e c6 fc f3 a5 1f  |.....1..........|
00000160  61 ff 26 5a 7c be 80 7d  eb 03 be 8f 7d e8 34 00  |a.&Z|..}....}.4.|
00000170  be 94 7d e8 2e 00 cd 18  eb fe 47 52 55 42 20 00  |..}.......GRUB .|
00000180  47 65 6f 6d 00 48 61 72  64 20 44 69 73 6b 00 52  |Geom.Hard Disk.R|
00000190  65 61 64 00 20 45 72 72  6f 72 0d 0a 00 bb 01 00  |ead. Error......|
000001a0  b4 0e cd 10 ac 3c 00 75  f4 c3 00 00 00 00 00 00  |.....<.u........|
000001b0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001c0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001e0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
00000200
[root@yinzhengjie.com ~]# 
[root@yinzhengjie.com ~]# ll            #在救援模式中,该文件备份在其它机器上,需要手动给救援服务器配置好IP地址。然后将远程备份的文件通过scp命令拷贝到当前被破坏的分区中。
total 4
-rw-r--r-- 1 root root 64 May  7 03:10 dpt
[root@yinzhengjie.com ~]# 
[root@yinzhengjie.com ~]# hexdump -C dpt 
00000000  80 00 01 00 ee fe ff ff  01 00 00 00 ff ff ff ff  |................|
00000010  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000040
[root@yinzhengjie.com ~]# 
[root@yinzhengjie.com ~]# dd if=dpt of=/dev/sda bs=1 count=64 seek=446
64+0 records in
64+0 records out
64 bytes (64 B) copied, 0.000251401 s, 255 kB/s
[root@yinzhengjie.com ~]# 
[root@yinzhengjie.com ~]# hexdump -C /dev/sda -n  512 -v
00000000  eb 63 90 00 00 00 00 00  00 00 00 00 00 00 00 00  |.c..............|
00000010  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000020  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000030  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000040  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000050  00 00 00 00 00 00 00 00  00 00 00 80 00 08 00 00  |................|
00000060  00 00 00 00 ff fa 90 90  f6 c2 80 74 05 f6 c2 70  |...........t...p|
00000070  74 02 b2 80 ea 79 7c 00  00 31 c0 8e d8 8e d0 bc  |t....y|..1......|
00000080  00 20 fb a0 64 7c 3c ff  74 02 88 c2 52 be 05 7c  |. ..d|<.t...R..||
00000090  b4 41 bb aa 55 cd 13 5a  52 72 3d 81 fb 55 aa 75  |.A..U..ZRr=..U.u|
000000a0  37 83 e1 01 74 32 31 c0  89 44 04 40 88 44 ff 89  |7...t21..D.@.D..|
000000b0  44 02 c7 04 10 00 66 8b  1e 5c 7c 66 89 5c 08 66  |D.....f..\|f.\.f|
000000c0  8b 1e 60 7c 66 89 5c 0c  c7 44 06 00 70 b4 42 cd  |..`|f.\..D..p.B.|
000000d0  13 72 05 bb 00 70 eb 76  b4 08 cd 13 73 0d 5a 84  |.r...p.v....s.Z.|
000000e0  d2 0f 83 de 00 be 85 7d  e9 82 00 66 0f b6 c6 88  |.......}...f....|
000000f0  64 ff 40 66 89 44 04 0f  b6 d1 c1 e2 02 88 e8 88  |d.@f.D..........|
00000100  f4 40 89 44 08 0f b6 c2  c0 e8 02 66 89 04 66 a1  |.@.D.......f..f.|
00000110  60 7c 66 09 c0 75 4e 66  a1 5c 7c 66 31 d2 66 f7  |`|f..uNf.\|f1.f.|
00000120  34 88 d1 31 d2 66 f7 74  04 3b 44 08 7d 37 fe c1  |4..1.f.t.;D.}7..|
00000130  88 c5 30 c0 c1 e8 02 08  c1 88 d0 5a 88 c6 bb 00  |..0........Z....|
00000140  70 8e c3 31 db b8 01 02  cd 13 72 1e 8c c3 60 1e  |p..1......r...`.|
00000150  b9 00 01 8e db 31 f6 bf  00 80 8e c6 fc f3 a5 1f  |.....1..........|
00000160  61 ff 26 5a 7c be 80 7d  eb 03 be 8f 7d e8 34 00  |a.&Z|..}....}.4.|
00000170  be 94 7d e8 2e 00 cd 18  eb fe 47 52 55 42 20 00  |..}.......GRUB .|
00000180  47 65 6f 6d 00 48 61 72  64 20 44 69 73 6b 00 52  |Geom.Hard Disk.R|
00000190  65 61 64 00 20 45 72 72  6f 72 0d 0a 00 bb 01 00  |ead. Error......|
000001a0  b4 0e cd 10 ac 3c 00 75  f4 c3 00 00 00 00 00 00  |.....<.u........|
000001b0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 80 00  |................|
000001c0  01 00 ee fe ff ff 01 00  00 00 ff ff ff ff 00 00  |................|
000001d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001e0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
00000200
[root@yinzhengjie.com ~]# 
[root@yinzhengjie.com ~]# sync                  #在救援模式时一定要手动执行该命令,将内存中的数据强行刷新到磁盘上
[root@yinzhengjie.com ~]# 
[root@yinzhengjie.com ~]# dd if=dpt of=/dev/sda bs=1 count=64 seek=446         #恢复分区表(实际生产环境中可能需要你通过光盘或者U盘引导进入到救援模式操作哟~)

 

三.GUID(Globals Unique Identifiers)partition table(简称GPT)分区方式概述

1>.GPT分区结构

  如下所示,使用128位Universally Unique Identifier(简称UUID)表示磁盘和分区GPT分区表,GTP自动分区自动备份在头和尾两份。并有CRC校验位。  

  EFI部分又可以分为4个区域:EFI信息区(GPT头)、分区表、GPT分区、备份区域。

  Protective MBR(512bytes):
    主要作用是保护GPT分区,因为一些老的机器可能不支持GPT分区,老机器一般只能识别MBR分区,因此其功能就是让老机器将GPT分区识别为MBR分区。但对于GPT分区来讲并没有实际意义,其作用就是为了兼容老的MBR。
    如果没有Proctive MBR,老的机器就识别不了GPT分区策略,老机器会一贯认为磁盘是没有分区信息的,可能会导致数据被破坏。因此GPT为了兼容老机器伪造了一个MBR的分区的身份,以防止后面的数据被破坏。

  Primary GUID Partition Header:
    GPT的头部信息。

  GUID Parition entries 1-128:
    对应的是分区表信息。

  Partition 1-128:
    分区表对应的存储空间。

  GUID Partition entries 1 - 128:
    备份的分区表信息。

  BackupGUID Partition Header:
    对应的GPT头部信息的备份。    

 

2>.BIOS+MBR与UEFI+GPT

  UEFI(统一扩展固件接口)硬件支持GPT,使得操作系统启动。因此采用传统的BIOS方式仅支持MBR分区方式。我们现在新购买的机器基本上都是基于UEFI方式启动的。

  我们基于BIOS启动的操作系统它通常是MBR分区的系统,虽然BIOS无法识别GPT的分区,但我们基于BIOS启动的操作系统是可以识别你新接入的GPT分区的磁盘。   BIOS只是字符界面,它只能使用键盘操作,而UEFI是支持鼠标操作的哟。

  BIOS和UEFI运行流程如下所示。     传统BIOS运行流程:       (
1)开机       (2)BIOS初始化       (3)BIOS自建       (4)引导操作系统       (5)进入系统     UEFI运行流程:       (1)开机       (2)UEFI初始化       (3)引导操作系统       (4)进入系统

3>.管理分区

  列出块设备
    lsblk

  创建分区使用:
    创建MBR分区:
      fdisk
    创建GPT分区:
      gdisk

  高级分区操作:
    parted

  重新设置内存中的内核分区表版本
    partprobe

  博主推荐阅读:
    https://www.cnblogs.com/yinzhengjie/p/12355151.html
    https://www.cnblogs.com/yinzhengjie/p/12359248.html
    https://www.cnblogs.com/yinzhengjie/p/12359770.html
[root@yinzhengjie.com ~]# uuidgen 
e96f282d-4834-4e58-bb45-317ae7e1a6c0
[root@yinzhengjie.com ~]# 
[root@yinzhengjie.com ~]# 
[root@yinzhengjie.com ~]# uuidgen 
ba3f2289-4628-43e8-97fd-a7860f589042
[root@yinzhengjie.com ~]# 
[root@yinzhengjie.com ~]# uuidgen 
58acafac-92a1-40ac-b946-8783ab9390c1
[root@yinzhengjie.com ~]# 
[root@yinzhengjie.com ~]# 
[root@yinzhengjie.com ~]# uuidgen            #随机生成UUID序列

 

posted @ 2020-02-22 22:48  尹正杰  阅读(1119)  评论(0编辑  收藏  举报