大于2T的磁盘使用GPT分区方式

一台MD1000的ISCSI的存储,有15T的空间,在分空间时,超过2T就没法使用普通的法子分区.只能使用GPT的方法。查了一下GPT的介绍.介绍讲,只能在2TB内,普通pc的BIOS才能认到分区表.超过2TB就要使用GPT的磁盘分区表.

下面是它的一些介绍

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) mklable 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的主分区。