For MBR partition table and the difference between GPT disk.
MBR: MBR partition table (master boot record) we are all familiar, when we use the past windows commonly used.
The maximum supported volume: 2T, but there are restrictions on partitions: up to four primary partitions, or three primary partitions plus an extended partition
GPT: GPT (GUID partition table that is). EFI is a standard derived from the newer standard disk partition table structure, is the main form of future disk partition. Compared with the MBR partition mode, it has the following advantages.
Breakthrough MBR 4 primary partitions limit, each supporting up to 128 disk partitions. Support more than 2T partition, the maximum volume of up to 18EB.
For GPT partition recommended partitioning tool parted, fdisk GPT in this not very good.
Parted Introduction
Parted commands are divided into two modes: command-line mode and interactive mode.
Command line mode
parted [option] device [command], the mode to partition the disk directly in the command line, more suitable for programming applications. Such as:
Displays disk / dev / sdb partition.
parted /dev/sdb print
Interactive mode
parted [option] device to enter the interactive mode. Especially in the case of parted command is not very familiar with the recommended interactive mode.
parted /dev/sdb
parted Command Common Options
Enter the interactive mode, enter help
the following dialog, based Parted 3.2 will be described herein.
test@test01:~$ sudo parted /dev/sdb
GNU Parted 3.2
使用 /dev/sdb
欢迎使用 GNU Parted! 输入 'help'可获得命令列表.
(parted) help
align-check TYPE N check partition N for TYPE(min|opt) alignment
help [COMMAND] print general help, or help on COMMAND
mklabel,mktable LABEL-TYPE create a new disklabel (partition table)
mkpart 分区类型 [文件系统类型] 起始点 终止点 创建一个分区
name NUMBER 名称 将编号为NUMBER 的分区命名为“名称”
print [devices|free|list,all|NUMBER] display the partition table, available devices, free space,
all found partitions, or a particular partition
quit 退出程序
rescue 起始点 终止点 挽救临近“起始点”、“终止点”的遗失的分区
resizepart NUMBER END resize partition NUMBER
rm MINOR 删除编号为 MINOR 的分区
选择设备 选择要编辑的设备
disk_set FLAG STATE change the FLAG on selected device
disk_toggle [FLAG] toggle the state of FLAG on selected device
set NUMBER FLAG STATE change the FLAG on partition NUMBER
toggle [NUMBER [FLAG]] 切换分区 NUMBER 的 FLAG 标记
unit UNIT set the default unit to UNIT
version display the version number and copyright information of GNU
Parted
(parted)
Several options are more common
- help print help information
- print output partition information
- mklabel create a partition table, that is, use msdos (MBR) or use gpt, or otherwise partitioned table
- mkpart create a new partition
format: the TYPE-the PART mkpart the START the END
. the PART-types are the TYPE Primary (primary partition), extended (extended partition), logical (logic region) extended and logical partitions only msdos. - rm delete a partition
- resizepart specified partition size adjustment
- quit quit the interactive interface
To partition the disk
First, for larger capacity disk using fdisk tool you will get the following message:
test@test01:~$ sudo fdisk /dev/sdb
欢迎使用 fdisk (util-linux 2.31.1)。
更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。
设备不包含可识别的分区表。
The size of this disk is 3.7 TiB (4000787030016 bytes). DOS partition table format cannot be used on drives for volumes larger than 2199023255040 bytes for 512-byte sectors. Use GUID partition table format (GPT).
创建了一个磁盘标识符为 0x9f682389 的新 DOS 磁盘标签。
命令(输入 m 获取帮助):
This time we need to update parted to partition the disk.
Change the partition table
As follows:
(parted) mklabel gpt
(parted) print
Model: ATA ST4000DM004-2CV1 (scsi)
磁盘 /dev/sdb: 4001GB
Sector size (logical/physical): 512B/4096B
分区表:gpt
Disk Flags:
数字 开始: End 大小 文件系统 Name 标志
(parted)
Create a partition
Use mkpart size you need to create a partition
(parted) mkpart primary 0 4TB
(parted) p
Model: ATA ST4000DM004-2CV1 (scsi)
磁盘 /dev/sdb: 4001GB
Sector size (logical/physical): 512B/4096B
分区表:gpt
Disk Flags:
数字 开始: End 大小 文件系统 Name 标志
1 1049kB 4001GB 4001GB primary
(parted)
Created after exit.
Each operation is parted with immediate effect, and different fdisk, fdisk only used at the end
w
to take effect after save.
Format the partition
You need to format the file system.
mkfs.ext4 /dev/sdb1
The entire partition creation process is over.
Partition aligned to give optimal performance
When the partition is not aligned, parted prompts as follows
警告: The resulting partition is not properly aligned for best performance.
忽略/Ignore/放弃/Cancel?
For this tip, just like partition alignment. If your design is aligned or else, you can ignore this prompt.
There are two alignment partitioning method,
A method, expressed as a percentage used to partition the space, then to 100% of the time is naturally aligned. Examples are as follows:
(parted) mkpart primary 0% 100%
(parted) p
Model: ATA ST4000DM004-2CV1 (scsi)
磁盘 /dev/sdb: 4001GB
Sector size (logical/physical): 512B/4096B
分区表:gpt
Disk Flags:
数字 开始: End 大小 文件系统 Name 标志
1 1049kB 4001GB 4001GB primary
(parted)
The second method is used if the capacity is to space, then -1
the value represents a final position. Examples are as follows:
(parted) mkpart primary 0TB -1
(parted) p
Model: ATA ST4000DM004-2CV1 (scsi)
磁盘 /dev/sdb: 4001GB
Sector size (logical/physical): 512B/4096B
分区表:gpt
Disk Flags:
数字 开始: End 大小 文件系统 Name 标志
1 1049kB 4001GB 4001GB primary
(parted)
Three methods manual calculation.
On the bottom of this blog describes how to calculate disk sectors to ensure the partition alignment.
https://rainbow.chard.org/2013/01/30/how-to-align-partitions-for-best-performance-using-parted/