如何將硬盤分區成GPT格式
基于GPT格式的磁盤分區
MBR分區標準決定了MBR的硬盤,為了支持能使用大于2T硬盤空間,需使用GPT格式進行分區。創建大于2TB的分區,需使用parted工具。
MBR是Master Boot Record的簡稱,也就是主引導記錄,是位于磁盤最前邊的一段引 導(Loader)代碼,主要用來引導操作系統的加載與啟動
特點:
MBR支持最大2TB磁盤,它無法處理大于2TB容量的磁盤
只支持最多4個主分區。若想要更多分區,需要創建擴展分區,并在其中創建邏輯分區
GPT磁盤是指使用GUID分區表的磁盤,GUID磁盤分區表(GUID Partition Table,縮寫:GPT)其含義為“全局唯一標識磁盤分區表”,是一個實體硬盤的分區表的結構布局的標準
特點:
GPT對磁盤大小沒有限制
最多可以創建128個分區
在企業真實環境中,通常一臺服務器有多塊硬盤,整個硬盤容量為10T,需要基于GTP格式對10T硬盤進行分區,操作步驟如下:
確認是否有parted命令
[root@localhost ~]# which parted /usr/sbin/parted 這里安裝的有,我們直接使用 [root@localhost ~]# [root@localhost ~]# yum -y install parted 如果沒有,需要安裝parted 命令
1
2
3
4
Parted 命令分為兩種模式:命令行模式和交互模式。
命令模式:
parted -s /dev/sdb mklabel gpt 設置分區類型為gpt格式; mkfs.ext3 /dev/sdb 基于Ext3文件系統類型格式化; mount /dev/sdb /data/ 掛載/dev/sdb設備至/data/目錄。
1
2
3
4
交互模式:
parted 直接進入 select /dev/sdb 選擇/dev/sdb磁盤 mklabel gpt 格式類型為gpt mkpart primary 0 -1 將整塊磁盤分一個分區 print 打印剛分區的磁盤信息 quit 退出 mkfs.ext3 /dev/sdb1 格式化磁盤 moun /dev/sdb1 /data/ 掛在
1
2
3
4
5
6
7
8
9
10
詳細操作情況
[root@localhost ~]# parted GNU Parted 3.1 Using /dev/sda Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) p #打印磁盤信息 Model: VMware, VMware Virtual S (scsi) Disk /dev/sda: 32.2GB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags 1 1049kB 211MB 210MB primary xfs boot 2 211MB 751MB 540MB primary lvm 3 751MB 32.2GB 31.5GB primary xfs (parted) select /dev/sdb #選擇空的磁盤 Using /dev/sdb (parted) p Model: VMware, VMware Virtual S (scsi) Disk /dev/sdb: 21.5GB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags (parted) mklabel gpt #用GPT分區,支持2T以上的硬盤 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 輸入yes (parted) mkpart primary 0 -1 -1 #將整塊磁盤分為1個分區 1表示從最開始分區,也可以用百分比表示 Warning: The resulting partition is not properly aligned for best performance. Ignore/Cancel? Ignore/Cancel? ignore (parted) print #打印剛分好的分區 Model: VMware, VMware Virtual S (scsi) Disk /dev/sdb: 21.5GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 17.4kB 21.5GB 21.5GB primary (parted) quit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
將磁盤分成多個分區
(parted) mkpart primary File system type? [ext2]? ext4 #選擇文件系統類型 Start? 1024 #分區開始位置 End? 2048 #分區結束位置 Error: Partition(s) 1, 2, 3 on /dev/sda have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes. Ignore/Cancel? ignore (parted) p Model: VMware, VMware Virtual S (scsi) Disk /dev/sda: 32.2GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 1024MB 2048MB 1023MB primary (parted) mkpart primary File system type? [ext2]? ext3 Start? 0 End? 1023 Warning: The resulting partition is not properly aligned for best performance. Ignore/Cancel? ignore Error: Partition(s) 1, 2, 3 on /dev/sda have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes. Ignore/Cancel? ignore (parted) p Model: VMware, VMware Virtual S (scsi) Disk /dev/sda: 32.2GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 2 17.4kB 1023MB 1023MB primary 1 1024MB 2048MB 1023MB primary (parted) mkpart exclude File system type? [ext2]? ext3 Start? 2049 End? 4096 Error: Partition(s) 1, 2, 3 on /dev/sda have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes. Ignore/Cancel? ignore (parted) p Model: VMware, VMware Virtual S (scsi) Disk /dev/sda: 32.2GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 2 17.4kB 1023MB 1023MB primary 1 1024MB 2048MB 1023MB primary 3 2049MB 4096MB 2047MB exclude (parted)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
如果創建錯誤,需要刪除錯誤分區
(parted) select /dev/sdb Using /dev/sdb (parted) p Model: VMware, VMware Virtual S (scsi) Disk /dev/sdb: 21.5GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 17.4kB 21.5GB 21.5GB primary (parted) rm 1 (parted) p
1
2
3
4
5
6
7
8
9
10
11
12
13
14
總結
磁盤格式化、掛載 參考上期文章 linux 磁盤分區管理
linux磁盤分區管理
Linux
版權聲明:本文內容由網絡用戶投稿,版權歸原作者所有,本站不擁有其著作權,亦不承擔相應法律責任。如果您發現本站中有涉嫌抄襲或描述失實的內容,請聯系我們jiasou666@gmail.com 處理,核實后本網站將在24小時內刪除侵權內容。
版權聲明:本文內容由網絡用戶投稿,版權歸原作者所有,本站不擁有其著作權,亦不承擔相應法律責任。如果您發現本站中有涉嫌抄襲或描述失實的內容,請聯系我們jiasou666@gmail.com 處理,核實后本網站將在24小時內刪除侵權內容。