Linux下關於大於2T磁盤的使用GPT磁盤

 Linux下關於大於2T磁盤的使用GPT磁盤 

我們來看一下兩種分區表
MBR分區表:(MBR含義:主引導記錄)
所支持的最大卷:2T (T; terabytes,1TB=1024GB)
對分區的設限:最多4個主分區或3個主分區加一個擴展分區(擴展分區中支持無限制的邏輯驅動器)

GPT分區表:(GPT含義:GUID分區表)
支持最大卷:18EB,(E:exabytes,1EB=1024TB)
每個磁盤最多支持128個分區

假設要用parted對/dev/sdb(大小爲6000G)進行分區操作:

1、進入系統執行:
#parted /dev/sdb

2、建立磁盤label:

mklabel GPT

3、按p鍵,查看磁盤可用空間,顯示單位爲M。6000G應該顯示大致

爲: /dev/sdb 的磁盤幾何結構:0.000-6000000.000 兆字節

4、創建分區:
在(parted)後輸入:
mkpart並按照提示操作

分區類型? primary/主分區/extended/擴展分區? p (如果要創建擴展分區 此處
輸入e)
文件系統類型? [ext2]? (這裏直接回車,分區創建完畢後通過mkfs.ext3
/dev/sdb*建立文件系統)
起始點?0
結束點?-1

5、按p鍵查看剛創建的分區是否已經成功。

6、如果成功,鍵入quit退出parted。

7、使用mkfs.ext3 /dev/sdb1 來創建文件系統


fdisk命令雖然很交互,操作也方便,但是對於大於2T的磁盤無法操作,如果我們想用大於2T的磁盤怎麼辦?可以把磁盤轉化爲GPT格式。


GPT格式的磁盤相當於原來MBR磁盤中原來保留4個partition table的4*16個字節只留第一個16個字節,類似於擴展分區,真正的partition table在512字節之後,GPT磁盤沒有四個主分區的限制。


但fdisk不支持GPT,我們可以使用parted來對GPT磁盤操作。

parted功能很強大,既可用命令行也可以用於交互式


在提示符下輸入parted就會進入交互式模式,如果有多個磁盤的話,我們需要運行select sdx x爲磁盤,來進行磁盤的選擇

parted>

parted>select sdb                假設磁盤爲sdb

parted>mklable gpt               將MBR磁盤格式化爲GPT

parted>mklable msdos             將GPT磁盤轉化爲MBR磁盤

parted>mkpart primary 0 100      劃分一個起始位置爲0大小爲100M的主分區

parted>mkpart primary 100 200    劃分一個起始位置爲100M大小爲100M的主分區

parted>print                     打印當前分區



在parted裏邊不支持ext3的文件系統,所以如果要使用的話,要退出parted進行格式話

mkfs.ext3 /dev/sdx1

因爲fdisk是不支持GPT磁盤,所以不要使用fdisk -l來查看X磁盤剛纔分好的區,看不到的。


命令行的模式:
將硬盤轉化爲GPT磁盤後,執行下列命令

parted /dev/sdx mkpart primary 0 100   劃分一個起始位置爲0大小爲100M的主分區

Acronym for GUID Partition Table

GPT was introduced for iA64 systems, to get around a fixed 32 bit issue (2 to the power of 32 is 4 billion times a 512 byte block equals 2 Terabytes) in the PC-BIOS Partition table. Partitions larger than 2 TB require using a GPT disklabel, which differs from the PC-BIOS Partition table in a number of ways:

    * Is easily extensible.
    * Can contain up to 128 primary partitions, as opposed to 4, so there's no need for extended partitions.
    * Allows Partitions larger than 2 TB.
    * Identifies Partitions with a GUID so you can reference that Partition even if disks are moved around.
    * Identifies Partition type with a GUID, thus avoiding the type conflicts that plague the PC-BIOS Partition table format.
    * Provides a 46(?) character UTF-16 partition label to identify Partitions.
    * Has a "fake" MBR for backwards compatibility.
    * Includes a CRC32 to detect corrupt Partition tables.
    * Stores a backup Partition table at the end of the disk.

Most partitioning tools under Linux will fail to do anything sensible with a > 2 TB Partition. As of this writing, parted(8) is the only one that understands them and will let you set the GPT label on the disk.

There is a lot of information stating that you cannot boot off a GPT enabled device. Most of the claims imply that the fault is with LILO or GRUB not understanding GPT devices. We've not tested this, but GPT and traditional MBRs will coexist.

See also:

    * Disk Sectors on GPT Disks from the MS Knowledge Base

所以在超過2TB時,我不能使用交互很好的Fdisk命令,只能磁盤轉化爲GPT格式。由於GPT格式的磁盤相當於原來MBR磁盤中原來保留4個 partition table的4*16個字節只留第一個16個字節,其它的類似於擴展分區,真正的partition table在512字節之後,所以對GPT磁盤表來講沒有四個主分區的限制。

對GPT磁盤分區表進行操作,我們要使用parted命令。其實parted功能很強大,它可以象fdisk一樣既可用命令行也可以用於交互式.
下面我們就來實際操作吧,在提示符下輸入parted就會進入交互式模式

#  parted  /dev/sdb
GNU  Parted  1.8.1
Using  /dev/sdb
Welcome  to  GNU  Parted!  Type  'help'  to  view  a  list  of  commands.

(parted) mklabel gpt
將MBR磁盤格式化爲GPT

(parted) mkpart primary 0 100
劃分一個起始位置爲0大小爲100M的主分區

(parted) mkpart primary 100 200
劃分一個起始位置爲100M大小爲100M的主分區

(parted)  mkpart  primary  0  -1

劃分所有空間到一個分區

(parted)  print
打印當前分區

(parted)  quit

可能還會用到的一些命令

(parted) mklable msdos
如果要反過來.將GPT磁盤轉化爲MBR磁盤

在這樣分完分區後,還要使用mkfs.ext3來進行格式化
#partprobe
#mkfs.ext3 -F /dev/sdb1

記的哦,因爲fdisk是不支持GPT磁盤,所以使用fdisk -l來查看磁盤剛纔的分區是沒有用的.

命令行的模式:

將硬盤轉化爲GPT磁盤後,執行下列命令

parted /dev/sdx mkpart primary 0 100 
##劃分一個起始位置爲0大小爲100M的主分區

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章