在生产环境中,我们会遇到分区大于2T的磁盘(比如:添加一个3TB的存储),由于MBR分区表只支持2T磁盘,所以大于2T的磁盘必须使用GPT分区表
而fdisk是不支持GPT分区的,我们可以使用parted来对GPT磁盘操作。parted功能很强大,既可用命令行也可以用于交互式,在提示符下输入parted就会进入交互式模式,如果有多个磁盘的话,我们需要运行select sdX(X为磁盘)来进行磁盘的选择,也可直接用parted /dev/sdX指定相应的硬盘
查看磁盘信息:
[[email protected] ~]# fdisk -l
Disk /dev/sdm: 299.4 GB, 299439751168 bytes
255 heads, 63 sectors/track, 36404 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x2ebc66f6
Device Boot Start End Blocks Id System
/dev/sdm1 1 2089 16777216 82 Linux swap / Solaris
/dev/sdm2 * 2089 36405 275643392 83 Linux
Disk /dev/sdn: 3200.0 GB, 3199999672320 bytes
255 heads, 63 sectors/track, 389044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
[[email protected] ~]# parted
GNU Parted 2.1
浣跨敤 /dev/sda
Welcome to GNU Parted! Type ‘help‘ to view a list of commands.
(parted)
(parted) select /dev/sdn //选择磁盘sdn
浣跨敤 /dev/sdn
(parted) mklabel gpt //将MBR磁盘格式化为GPT
(parted) mkpart primary 0 -1 //将整块磁盘分成一个分区
(parted) quit //退出
[[email protected] ~]# mkfs.ext4 /dev/sdn1 //格式化
mke2fs 1.41.12 (17-May-2010)
Discarding device blocks: 20447232/454545159
[[email protected] ~]# mkdir /io
[[email protected] ~]# mount /dev/sdn1 /io //挂载
[[email protected] ~]# blkid /dev/sdn1
/dev/sdn1: UUID="5abd6300-8375-4310-b1b5-5daf8576d6ff" TYPE="ext4"
[[email protected] ~]# vi /etc/fstab
UUID=5abd6300-8375-4310-b1b5-5daf8576d6ff /io ext4 defaults 1 2
[[email protected] ~]# df -h
/dev/sdn1 2.9T 200M 2.8T 1% /io