我刚刚为硬盘 ( /dev/sda
) 上的整个空间创建了一个 GPT 磁盘标签,如下所示:
# parted
(parted) select /dev/sda
(parted) mklabel gpt
Warning: The existing disk label on /dev/sda will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? Y
(parted) mkpart primary 0% 100%
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? I
(parted) quit
现在进一步阅读,我意识到“忽略”对于性能来说可能是一个坏主意。
但...
# parted
(parted) print
Model: ATA ST33000650NS (scsi)
Disk /dev/sda: 3001GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
5 1049kB 2097kB 1049kB bios_grub
1 2097kB 8592MB 8590MB raid
2 8592MB 9129MB 537MB raid
3 9129MB 43.5GB 34.4GB raid
4 43.5GB 3001GB 2957GB raid
(parted) align-check optimal 1
1 aligned
(parted) align-check optimal 2
2 aligned
(parted) align-check optimal 3
3 aligned
(parted) align-check optimal 4
4 aligned
(parted) align-check optimal 5
5 aligned
(parted)
那么parted
分区是自己对齐的吗?align-check optimal *
这么说。
如果不是这种情况,如何检查磁盘的分区是否需要重新对齐以提高性能?我该怎么做呢?
如果确实如此,
mkpart primary 0% 100%
实际上会在所有情况下自动执行对齐分区的过程吗?有什么边缘情况不会发生吗?
答案1
parted
从该选项开始--align optimal
告诉程序与设备物理块大小的倍数对齐以确保最佳性能。
该--align
选项还有其他类型可用。
请参阅man parted
获取更多信息。
答案2
我刚刚在centos 6.7的虚拟机上测试:
# parted /dev/sdb
GNU Parted 2.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
Error: /dev/sdb: unrecognised disk label
(parted) mklabel gpt
(parted) mkpart primary 1m 100%
(parted) quit
Information: You may need to update /etc/fstab.
[root@localhost ~]# parted /dev/sdb print
Model: VMware Virtual disk (scsi)
Disk /dev/sdb: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
1 1049kB 1073MB 1072MB primary
[root@localhost ~]# parted /dev/sdb "unit s print"
Model: VMware Virtual disk (scsi)
Disk /dev/sdb: 2097152s
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
1 2048s 2095103s 2093056s primary
这样,gpt 分区就正确对齐了。