一.MBR分區與GPT分區的區別
二.MBR分區方式
1.主分區
主分區表記錄分區的信息並可以直接使用的分區
2.擴展分區
主分區表記錄的分區,不可直接使用,只是邏輯分區容器
3.邏輯分區
擴展分區之上劃分的分區叫做邏輯分區
4.分區方法
[root@rhel7 ~]# fdisk /dev/sdb
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.
Command (m for help): n ##新建
Partition type:
p primary (0 primary, 0 extended, 4 free) ##主分區
e extended ##擴展分區
Select (default p): p ##建立主分區
Partition number (1-4, default 1): 1 ##分區表位置
First sector (2048-20971519, default 2048): ##分區起始位置(推薦使用默認)
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519): +100M ##分區結束位置
Partition 1 of type Linux and of size 100 MiB is set
Command (m for help): p ##顯示分區表
Disk /dev/sdb: 10.7 GB, 10737418240 bytes, 20971520 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: dos
Disk identifier: 0x0002db10
Device Boot Start End Blocks Id System
/dev/sdb1 2048 206847 102400 83 Linux
Command (m for help): wq ##退出保存,如果直接q表示退出不保存
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@rhel7 ~]# partprobe ##同步分區表
Warning: Unable to open /dev/sr0 read-write (Read-only file system). /dev/sr0 has been opened read-only.
[root@rhel7 ~]# mkfs.xfs /dev/sdb1 ##格式化設備爲xfs文件系統(相當與在/dev/sdb1上安裝設備管理軟件)
mkfs.xfs: /dev/sdb1 appears to contain an existing filesystem (xfs).
mkfs.xfs: Use the -f option to force overwrite.
三.MBR分區方式轉換成GPT
[root@rhel7 ~]# parted /dev/sdb
GNU Parted 3.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel
New disk label type? 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? yes
(parted) quit
Information: You may need to update /etc/fstab.
四.GPT分區方式
[root@rhel7 ~]# fdisk /dev/sdb
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.
Command (m for help): n ##新建
Partition number (1-128, default 1): 1 ##分區表位置
First sector (34-20971486, default 2048): ##分區起始位置(推薦使用默認)
Last sector, +sectors or +size{K,M,G,T,P} (2048-20971486, default 20971486): +100M ##分區結束位置
Created partition 1
Command (m for help): p ##顯示分區
Disk /dev/sdb: 10.7 GB, 10737418240 bytes, 20971520 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 ##分區方式爲gpt
Disk identifier: 76E1957A-23A1-4FCB-8880-0DBAA9B5823A
# Start End Size Type Name
1 2048 206847 100M Linux filesyste
Command (m for help): wq ##退出保存
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
五.GPT分區方式轉換成MBR
[root@rhel7 ~]# parted /dev/sdb
GNU Parted 3.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel
New disk label type? msdos
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? yes
(parted) quit
Information: You may need to update /etc/fstab.