Linux磁盤分區--GPT分區

  MBR分區表有必定的侷限性,最大支持2.1tb硬盤,單塊硬盤最多4個主分區。html

  這裏就要引入GPT分區表,能夠支持最大18EB的卷,最多支持128個主分區,因此若是使用大於2tb的卷,就必須使用GTP分區。 node

  對/dev/sdb進行分區linux

         parted /dev/sdbide

  進入交互模式:oop

         (parted)學習

  交互模式下經常使用命令:this

print  [free|all | NUMBER]spa

 查看分區狀態信息code

mkpart PART-TYPE START ENDorm

 建立新分區,

PART-TYPE: primary  extended   logical 

START, END  開始,結束爲止

set NUMBER  FLAG  STATE

 對編號爲NUMBER的進行標記。

FLAG: boot  引導, hidden 隱藏, raid  軟raid, lvm  邏輯卷, 

STATE:  on| off

mkfs NUMBER FS-TYPE

 對NUMBER指定文件系統。FS-Type有:ext二、fat1六、fat3二、linuxswap、NTFS、reiserfs、ufs 等

 cp  [FROM-DEV] FROM-NUMBER  TO-NUMBER

 將分區 FROM-NUMBER 上的文件系統完整地複製到分區TO-NUMBER 中,做爲可選項還能夠指定一個來源硬盤的設備名稱FROM-DEVICE,若省略則在當前設備上進行復制。

 move NUMBER START END

 將指定編號 NUMBER 的分區移動到從 START 開始 END 結束的位置上。注意:(1)只能將分區移動到空閒空間中。(2)雖然分區被移動了,但它的分區編號是不會改變的

resize NUMBER START END  

對指定編號 NUMBER 的分區調整大小。分區的開始位置和結束位置由 START 和 END 決定

check NUMBER

檢查指定編號 NUMBER 分區中的文件系統是否有什麼錯誤

rescue START END 

rescue START END 

mklabel,mktable LABELTYPE

建立一個新的 LABEL-TYPE 類型的空磁盤分區表,對於PC而言 msdos 是經常使用的 LABELTYPE。 如果用 GUID 分區表,LABEL-TYPE 應該爲 gpt. 還有其餘的aix, amiga, bsd, dvh, gpt, mac, msdos, pc98, sun, loop

 

實例:

[root@linux-node2 ~]# parted /dev/sdb    #對sdb分區 GNU Parted 3.1 Using /dev/sdb Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) p    #print 打印 Model: VMware, VMware Virtual S (scsi) Disk /dev/sdb: 3221MB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags (parted) mklabel    #定義分區表類型,msdos是MBR分區表,能夠用這個方法將硬盤轉換成MBR New disk label type? gpt #分區表定義爲gpt,以前是mbr分區,因此會有下面的提醒 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    #警告sdb以前的內容將會丟失 (parted) mkpart    #建立分區 Partition name?  []? sdb1  #分區表名稱 File system type?  [ext2]? ext4    #文件系統類型  Start? 0    #起始扇區 End? 1g    #結束扇區 Warning: The resulting partition is not properly aligned for best performance. Ignore/Cancel? i    #警告內容將刪除,選擇忽略 (parted) p   #print打印分區信息 Model: VMware, VMware Virtual S (scsi) Disk /dev/sdb: 3221MB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1      17.4kB 1000MB 1000MB ext4 sdb1 (parted) rm 1    #刪除分區1 (parted) mkpart primary 0 1g  #建立主分區1gb Warning: The resulting partition is not properly aligned for best performance. Ignore/Cancel? i    #警告內容會被刪除,選擇忽略 (parted) mkpart primary 1g 3g     #建立主分區2gb (parted) p     #打印 Model: VMware, VMware Virtual S (scsi) Disk /dev/sdb: 3221MB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1      17.4kB 1000MB 1000MB ext4 primary 2 1000MB 3220MB 2220MB ext4 primary (parted) q    #退出  Information: You may need to update /etc/fstab.

[root@linux-node2 ~]# fdisk -l /dev/sdb    #查看/dev/sdb分區
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.

 
 

Disk /dev/sdb: 3221 MB, 3221225472 bytes, 6291456 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

 
 


# Start End Size Type Name
1 34 1953125 953.7M Microsoft basic primary
2 1953792 6289407 2.1G Microsoft basic primary

[root@linux-node2 ~]# mkfs.ext4 /dev/sdb1    #格式化sdb1
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
61056 inodes, 244136 blocks
12206 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=251658240
8 block groups
32768 blocks per group, 32768 fragments per group
7632 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376

Allocating group tables: done
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done

[root@linux-node2 ~]# blkid /dev/sdb1    #查看sdb1的UUID
/dev/sdb1: UUID="612067e2-12ca-4410-9ab8-682b22c0da87" TYPE="ext4" PARTLABEL="primary" PARTUUID="ae6af195-c535-4380-8a8f-e96c73730d96"
[root@linux-node2 ~]# echo 'UUID=612067e2-12ca-4410-9ab8-682b22c0da87 /data ext4 defaults 0 0' >> /etc/fstab    #實現開機自動掛載

 

 學習參考來自:http://www.cnblogs.com/onlybobby/p/7018788.html

相關文章
相關標籤/搜索