parted创建GPT分区(fdisk不支持创建GPT分区,GPT支持大于2TB分区,MBR不支持)
介绍2种分区表:
MBR分区表:(MBR含义:主引导记录)
所支持的最大卷:2T (T; terabytes,1TB=1024GB)
对分区的设限:最多4个主分区或3个主分区加一个扩展分区。
GPT分区表:(GPT含义:GUID分区表)
支持最大卷:18EB,(E:exabytes,1EB=1024TB)
每个磁盘最多支持128个分区
所以如果要大于2TB的卷或分区就必须得用GPT分区表。
Linux下fdisk工具不支持GPT,得使用另一个GNU发布的强大分区工具parted。
fdisk工具用的话,会有下面的警告信息:
# fdisk /dev/nvme0n1
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
下面是用parted工具对/dev/sda做GPT分区的过程:
# parted /dev/nvme0n1
GNU Parted 3.1
Using /dev/nvme0n1
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel gpt
Warning: The existing disk label on /dev/nvme0n1 will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? Yes
(parted) p
Model: Unknown (unknown)
Disk /dev/nvme0n1: 4001GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
(parted) mkpart primary 0KB 4001GB
Warning: You requested a partition from 0.00B to 4001GB (sectors 0..7814037167).
The closest location we can manage is 17.4kB to 4001GB (sectors 34..7814037134).
Is this still acceptable to you?
Yes/No? Yes
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? Ignore
(parted) p
Model: Unknown (unknown)
Disk /dev/nvme0n1: 4001GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 17.4kB 4001GB 4001GB ext4 primary
(parted) q
Information: You may need to update /etc/fstab.
root@node01:/#fdisk -l
.....
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
Disk /dev/nvme0n1: 4000.8 GB, 4000787030016 bytes, 7814037168 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: 3C3360DC-B16D-4644-97F5-DE051D620D9E
# Start End Size Type Name
1 34 7814037134 3.7T Microsoft basic primary
# mkfs.xfs -f /dev/nvme0n1p1
meta-data=/dev/nvme0n1p1 isize=512 agcount=4, agsize=244188660 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=976754637, imaxpct=5
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=476930, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
# mkdir /data
# mount /dev/nvme0n1p1 /data
# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 2.2T 0 disk
├─sda1 8:1 0 2M 0 part
├─sda2 8:2 0 1000M 0 part /boot
├─sda3 8:3 0 2.1T 0 part
│ └─centos-root 253:0 0 2.1T 0 lvm /
└─sda4 8:4 0 62.5G 0 part [SWAP]
sr0 11:0 1 1024M 0 rom
nvme0n1 259:0 0 3.7T 0 disk
└─nvme0n1p1 259:1 0 3.7T 0 part /data
# vi /etc/fstab
...
/dev/nvme0n1p1 /data xfs defaults 1 2