首先,我通过在分区的开始和结束位置指定百分比来在新的GPT表中创建正确对齐的分区:
# parted -a optimal /dev/sdb
GNU Parted 2.3
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mktable gpt
Warning: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? Y
(parted) mkpart primary 0% 1%
(parted) p
Model: ATA WDC WD30EZRX-00M (scsi)
Disk /dev/sdb: 3001GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Number Start End Size File system Name Flags
1 1049kB 2097kB 1049kB primary
(parted) quit
请注意,该磁盘正在使用“高级格式”,但可以将物理扇区的大小正确报告4096B
为“已分区”。让我们再次以扇区为单位看一下:
# parted -a optimal /dev/sdb
GNU Parted 2.3
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) unit s
(parted) p
Model: ATA WDC WD30EZRX-00M (scsi)
Disk /dev/sdb: 5860533168s
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Number Start End Size File system Name Flags
1 2048s 4095s 2048s primary
(parted) quit
- 为什么它从分区开始
2048s
而不是34s
第一个可能的扇区? 34s
如果物理扇区大小为4096B
,逻辑(即您在Parted中指定的)扇区大小为,则不是正确对齐的起始扇区512B
。正确对齐的起始扇区可以除以一个8
(因为物理扇区大小/逻辑扇区大小=8
)。但这意味着40s
是第一个正确对齐的起始扇区,但尚未使用。为什么?
如果我们尝试从新的GPT分区表100MiB
开始创建正确对齐的容量40s
分区:
# parted -a optimal /dev/sdb
GNU Parted 2.3
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel gpt
Warning: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? Y
(parted) mkpart primary 40s 204839s
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? I
(parted) unit MiB
(parted) p
Model: ATA WDC WD30EZRX-00M (scsi)
Disk /dev/sdb: 2861588MiB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Number Start End Size File system Name Flags
1 0.02MiB 100MiB 100MiB fat32 primary
(parted)
(parted) unit s
(parted) p
Model: ATA WDC WD30EZRX-00M (scsi)
Disk /dev/sdb: 5860533168s
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Number Start End Size File system Name Flags
1 40s 204839s 204800s fat32 primary
(parted)
Warning: The resulting partition is not properly aligned for best performance.
即使40s
和204840s(204839s
+ 1)都可被除以,我们仍然会收到警告8
。为什么?