【轉】Linux下關於大於2T磁碟的使用GPT磁碟

msdnchina發表於2011-07-28
http://blogold.chinaunix.net/u/31219/showart_1895925.html

我們來看一下兩種分割槽表
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的主分割槽

[@more@]

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/161195/viewspace-1053136/,如需轉載,請註明出處,否則將追究法律責任。

相關文章