通常我们用的比较多的一般都是fdisk工具来进行分区,但是现在由于磁盘越来越廉价,而且磁盘空间越来越大;而fdisk工具他对分区是有大小限制的,它只能划分小于2T的磁盘。但是现在的磁盘空间很多都已经是远远大于2T了,甚至达到2.5T和3T,那要怎么办能,有两个方法,其一是通过卷管理来实现,其二就是通过我们今天谈到的Parted工具来实现对GPT磁盘进行分区操作。
GPT格式的磁盘相当于原来MBR磁盘中原来保留4个partition table的4*16个字节,只留第一个16个字节,类似于扩展分区,真正的partitiontable在512字节之后,GPT磁盘没有四个主分区的限制。
1、 Parted工具详解:
1.1 进入Parted的方法(在命令行输入Parted命令即可)
[root@jetsen ~]# partet
Warning: Unable to open/dev/hdc read-write (Read-only file system)。 /dev/hdc has been
opened read-only.
GNU Parted 1.8.1
Using /dev/hdc
Welcome to GNU Parted! Type'help' to view a list of commands.
(parted)
1.2 获取parted工具帮助的方法:(只需输入help即可)
(parted) help
check NUMBER do a simple checkon the file system
cp [FROM-DEVICE] FROM-NUMBER TO-NUMBER copy file system to another partition
help [COMMAND] prints general help,or help on COMMAND
mklabel,mktable LABEL-TYPE create a new disklabel(partition table)
mkfs NUMBER FS-TYPE make a FS-TYPE filesystem on partititon
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 NUMBERas NAME
print [free|NUMBER|all] display the partition table,a partition, or
all devices
quit exit program
rescue START END rescue a lostpartition near START and END
resize NUMBER START END resize partition NUMBER andits file system
rm NUMBER deletepartition NUMBER
select DEVICE choose the deviceto edit
set NUMBER FLAG STATE change the FLAG onpartition NUMBER
toggle [NUMBER [FLAG]] toggle the state of FLAG onpartition NUMBER
unit UNIT set the defaultunit to UNIT
version displays thecurrent version of GNU Parted
and copyright information
(parted)
或
[root@jetsen ~]# parted--help
Usage: parted [OPTION]…[DEVICE [COMMAND [PARAMETERS]…]…]
Apply COMMANDs withPARAMETERS to DEVICE. If no COMMAND(s)are given, run in
interactive mode.
OPTIONs:
-h, --help displays this help message
-i, --interactive where necessary, prompts for userintervention
-l, --list lists partition tables ofall detected devices
-s, --script never prompts for userintervention
-v, --version displays the version
COMMANDs:
check NUMBER do a simple checkon the file system
cp [FROM-DEVICE] FROM-NUMBER TO-NUMBER copy file system to another partition
help [COMMAND] prints general help,or help on COMMAND
mklabel,mktable LABEL-TYPE create a new disklabel(partition table)
mkfs NUMBER FS-TYPE make a FS-TYPE filesystem on partititon 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 NUMBERas NAME
print [free|NUMBER|all] display the partition table, apartition, or all devices
quit exitprogram
rescue START END rescue a lostpartition near START and END
resize NUMBER START END resize partition NUMBER andits file system
rm NUMBER deletepartition NUMBER
select DEVICE choose the deviceto edit
set NUMBER FLAG STATE change the FLAG onpartition NUMBER
toggle [NUMBER [FLAG]] toggle the state of FLAG onpartition NUMBER
unit UNIT set the defaultunit to UNIT
version displays thecurrent version of GNU Parted and copyright information
[root@jetsen ~]#
1.3 退出parted工具(只需输入quit即可)
(parted) quit
Information: Don't forget toupdate /etc/fstab, if necessary.
并且同时会提示及时更新/etc/fstab文件
2、 开始通过parted工具来对磁盘进行操作
2.1 查看单个磁盘状态
[root@jetsen ~]#parted /dev/sdb
GNU Parted 1.8.1
Using /dev/sdb
Welcome to GNUParted! Type 'help' to view a list of commands.
(parted) p
Model: VMware,VMware Virtual S (scsi)
Disk /dev/sdb:16.1GB
Sector size(logical/physical): 512B/512B
Partition Table:msdos
Number Start End Size Type File system Flags
1 32.3kB 16.1GB 16.1GB primary ext3
(parted)
2.2 查看所有磁盘状态
[root@jetsen ~]#parted -l
Warning: Unable toopen /dev/hdc read-write (Read-only file system)。 /dev/hdc has been
opened read-only.
Error: Unable toopen /dev/hdc - unrecognised disk label.
Model: VMware,VMware Virtual S (scsi)
Disk /dev/sda:21.5GB
Sector size(logical/physical): 512B/512B
Partition Table:msdos
Number Start End Size Type File system Flags
1 32.3kB 107MB 107MB primary ext3 boot
2 107MB 21.5GB 21.4GB primary lvm
Model: VMware,VMware Virtual S (scsi)
Disk /dev/sdb:16.1GB
Sector size(logical/physical): 512B/512B
Partition Table:msdos
Number Start End Size Type File system Flags
1 32.3kB 16.1GB 16.1GB primary ext3
Model: VMware,VMware Virtual S (scsi)
Disk /dev/sdc:16.1GB
Sector size(logical/physical): 512B/512B
Partition Table:loop
Number Start End Size File system Flags
1 0.00kB 16.1GB 16.1GB ext3
Error: Unable toopen /dev/sdd - unrecognised disk label.
Error: Unable toopen /dev/sde - unrecognised disk label.
Error: Unable toopen /dev/md0 - unrecognised disk label.
2.2 通过parted工具来创建大于2T的分区
[root@jetsen ~]#parted /dev/sde
GNU Parted 1.8.1 ---Parted的软件版本号
Using /dev/sde ---将执行下面操作盘
Welcome to GNUParted! Type 'help' to view a list of commands. –欢迎信息
(parted) mklabel ----创建创建磁盘标签
New disk labeltype? gpt
(parted) p ----查看分区状态
Model: VMware,VMware Virtual S (scsi)
Disk /dev/sde:2190GB
Sect