Linux创建2TB以上分区,以及正确的对齐磁盘

一般来说,Linux创建分区使用fdisk命令,可以自动对齐磁盘。然而,fdisk无法处理大于2TB的磁盘文件。这种情况下,需要使用parted命令去创建分区。

parted创建分区需要手动指定分区开始与结束位置,可能会面临磁盘不对齐的问题(提示:Warning: The resulting partition is not properly aligned for best performance.)
所以需要手动去计算分区起点来对齐磁盘。

Parted

[root@ARKITDBDR2 ~]# parted /dev/mapper/ORAu01
GNU Parted 2.1
Using /dev/mapper/ORAu01
Welcome to GNU Parted! Type 'help' to view a list of commands.

(parted) mklabel GPT
(parted) print
Model: Linux device-mapper (multipath) (dm)
Disk /dev/mapper/ORAu01: 6.05TB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number Start End Size File system Name Flags

(parted) mkpart primary 0.00T 100%
(parted) print
Model: Linux device-mapper (multipath) (dm)
Disk /dev/mapper/ORAu01: 6.05TB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number Start End Size File system Name Flags
1 0.00TB 6.05TB 6.05TB primary

(parted) 
(parted) quit

计算分区起点

输入0.00T有时候可以免于计算起点

mkpart primary 0.00T 100%
# cat /sys/block/sdb/queue/optimal_io_size
1048576
# cat /sys/block/sdb/queue/minimum_io_size
262144
# cat /sys/block/sdb/alignment_offset
0
# cat /sys/block/sdb/queue/physical_block_size
512
起点=(optimal_io_size + alignment_offset) / physical_block_size =  (1048576 + 0) / 512 = 2048s

所以分区命令是

mkpart primary 2048s 100%

检查是否正确对齐

(parted) align-check optimal 1                                            
1 aligned

如果还有问题,则需要进一步修正,可以参考
https://bdoga.com/how-to-fix-warning-device-is-not-properly-aligned-with-parted/

格式化

mkfs.ext4 /dev/sdb1

你可能感兴趣的:(Linux创建2TB以上分区,以及正确的对齐磁盘)