日期:2014-05-16  浏览次数:20606 次

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 en