宝塔服务器面板,一键全能部署及管理,送你10850元礼包,点我领取

一、ESP分区介绍

EFI System Partition (ESP),中文名为EFI系统分区,是一种专门为UEFI固件设计的分区类型。ESP分区内包含了UEFI启动所必须的文件。ESP分区是一个标准的FAT32分区,文件名必须使用8.3格式。

ESP分区是非常重要的,因为操作系统的引导程序和UEFI固件文件都必须存在于此分区中。如果ESP分区被误删或者变成了非FAT32格式,那么硬盘将无法引导任何操作系统。

ESP分区一般大小为100MB,但有些操作系统(如Windows)可能会需要更多的空间。

ESP分区命令行管理示例

# 查看分区信息
sudo fdisk -l

# 创建一个100MB的FAT32分区
sudo fdisk /dev/sda
Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-2097151, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-2097151, default 2097151): +100M
Partition type
   p   primary (1 primary, 0 extended, 3 free)
   e   extended (container for logical partitions)
Select (default p):
Command (m for help): t
Partition number (1-4): 1
Partition type (type L to list all types): 1
Changed type of partition 'Linux' to 'EFI System'
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

二、MSR分区介绍

Microsoft Reserved Partition (MSR),中文名为Microsoft预留分区,是微软专门为Windows设计的分区类型。MSR分区的主要作用是为GPT分区表提供备用空间,以便在未来的操作中使用。

实际上,MSR分区不包含Windows的引导文件,也不存储用户数据。因此,MSR分区是一个只读的分区类型,并且不需要格式化。

MSR分区的大小为128MB,和ESP分区一样,也是GPT磁盘必须的分区类型。

MSR分区命令行管理示例

# 使用gdisk创建GPT分区表,并创建一个大小为128MB的MSR分区
sudo gdisk /dev/sda
Command (? for help): o
This option deletes all partitions and creates a new protective MBR.
Proceed? (Y/N): y

Command (? for help): n
Partition number (1-128, default 1):
First sector (34-104857566, default = 2048) or {+-}size{KMGTP}:
Last sector (2048-104857566, default = 104857566) or {+-}size{KMGTP}: 262144
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): ef02
Changed type of partition to 'BIOS boot partition'

Command (? for help): n
Partition number (2-128, default 2):
First sector (34-104857566, default = 264192) or {+-}size{KMGTP}:
Last sector (264192-104857566, default = 104857566) or {+-}size{KMGTP}: 133120
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300):
Changed type of partition to 'Microsoft reserved'

Command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/sda.
The operation has completed successfully.

三、ESP和MSR分区的关系

GPT磁盘必须有一个ESP分区和一个MSR分区,这是GPT分区表的规定。ESP分区必须位于磁盘的开头,而MSR分区必须位于ESP分区之后。

操作系统的引导程序和UEFI固件文件都必须存在于ESP分区中,而MSR分区则是为GPT分区表提供备用空间,以便在未来的操作中使用。

因此,ESP分区和MSR分区虽然看似不同,但是它们是密切关联的,并且都扮演着非常重要的角色。