硬盘的分区包括mbr和gpt(gpt即是对于MBR分区的扩展)从而达到支持更大的磁盘分区。

大于2TB的磁盘分区的格式需要用到GPT分区格式。

windows系统下的diskpart 支持磁盘分区的转换,diskpart /s convert gpt 即可。

linux下一半使用fdisk 命令分区,只能针对磁盘小于2TB的磁盘。对于超过2TB的磁盘需要使用

parted分区。对于parted分区的使用

 align-check TYPE N                        check partition N for TYPE(min|opt) alignment

 check NUMBER                             do a simple check on the file system

 cp [FROM-DEVICE] FROM-NUMBER TO-NUMBER   copy file system to another partition

 help [COMMAND]                           print general help, or help on COMMAND

 mklabel,mktable LABEL-TYPE               create a new disklabel (partition table)

 mkfs NUMBER FS-TYPE                      make a FS-TYPE file system on partition NUMBER

 mkpart PART-TYPE [FS-TYPE] START END     make a partition

 mkpartfs PART-TYPE FS-TYPE START END     make a partition with a file system

 move NUMBER START END                    move partition NUMBER

 name NUMBER NAME                         name partition NUMBER as NAME

 print [devices|free|list,all|NUMBER]     display the partition table, available devices                             , free space, all found partitions, or a particular partition

 quit                                     exit program

 rescue START END                         rescue a lost partition near START and END

 resize NUMBER START END                  resize partition NUMBER and its file system

 rm NUMBER                                delete partition NUMBER

 select DEVICE                            choose the device to edit

 set NUMBER FLAG STATE                    change the FLAG on partition NUMBER

 toggle [NUMBER [FLAG]]                   toggle the state of FLAG on partition NUMBER

 unit UNIT                                set the default unit to UNIT

 version                                  display the version number and copyright information of GNU Parted

简单说明这些命令 select 是选择块设备。

mklabel 是设置磁盘的分区表类型(MBR或者GPT)

mkpart是创建

对于块设备一般小于16TB时可以直接mkpartfs创建分区的同时可以建立文件系统。但是对于大于16TB的块设备。就不能直接创建文件系统。

too big to be expressed in 32 bits using a blocksize of 4096.

解决方案:

在/etc/mke2fs.conf中添加

[fs_types] ext4 = {
features = has_journal,extent,huge_file,flex_bg,uninit_bg,dir_nlink,extra_isize
auto_64-bit_support = 1 # 在这里添加
inode_size = 256
}

然后下载e2fsprogs

git clone git://git.kernel.org/pub/scm/fs/ext2/e2fsprogs.git

编译安装后,执行下面的命令在块设备上建立文件系统。

./mke2fs -O 64bit,has_journal,extents,huge_file,flex_bg,uninit_bg,dir_nlink,extra_isize -i 4194304 块设备

fsck.ext4 -f /dev/sdx