命令(输入 m 获取帮助):m 命令操作 a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition g create a new empty GPT partition table G create an IRIX (SGI) partition table l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only) 命令(输入 m 获取帮助):
设备 Boot Start End Blocks Id System /dev/sdb1 2048 526335 262144 83 Linux /dev/sdb2 526336 41943039 20708352 5 Extended /dev/sdb5 528384 20060159 9765888 83 Linux
命令(输入 m 获取帮助):
继续创建逻辑分区
1 2 3 4 5 6 7 8 9 10 11 12 13
命令(输入 m 获取帮助):n Partition type: p primary (1 primary, 1 extended, 2 free) l logical (numbered from 5) Select (default p): l 添加逻辑分区 6 起始 扇区 (20062208-41943039,默认为 20062208): 将使用默认值 20062208 Last 扇区, +扇区 or +size{K,M,G} (20062208-41943039,默认为 41943039): 将使用默认值 41943039 分区 6 已设置为 Linux 类型,大小设为 10.4 GiB
命令(输入 m 获取帮助):
最后,正式写入
w
1 2 3 4 5
命令(输入 m 获取帮助):w The partition table has been altered!
Calling ioctl() to re-read partition table. 正在同步磁盘。
分区号 (1,2,5,6,默认 6): 分区 6 已删除 分区号 (1,2,5,默认 5): 分区 5 已删除 分区号 (1,2,默认 2): 分区 2 已删除 已选择分区 1 分区 1 已删除 命令(输入 m 获取帮助):d No partition is defined yet! 命令(输入 m 获取帮助):w The partition table has been altered!
Calling ioctl() to re-read partition table. 正在同步磁盘。
(parted) help align-check TYPE N check partition N for TYPE(min|opt) alignment help [COMMAND] print general help, or help on COMMAND mklabel,mktable LABEL-TYPE create a new disklabel (partition table) mkpart PART-TYPE [FS-TYPE] START END make a partition 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
resizepart NUMBER END resize partition NUMBER rm NUMBER delete partition NUMBER select DEVICE choose the device to edit disk_set FLAG STATE change the FLAG on selected device disk_toggle [FLAG] toggle the state of FLAG on selected device 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 (parted)
更改磁盘分区表类型
mkabel gpt
我们从上文知道,sdb硬盘是mbr分区类型的,这里我们就改为gbt分区类型。
这条命令很危险,只能对新的硬盘操作!!
1 2 3 4
(parted) mklabel gpt 警告: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you want to continue? 是/Yes/否/No? yes
查询分区表4
1 2 3 4 5 6 7 8 9 10
(parted) p Model: VMware, VMware Virtual S (scsi) Disk /dev/sdb: 21.5GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags:
Number Start End Size File system Name 标志
(parted)
我们看到,分区类型成功改为gpt
创建主分区
gpt分区类型是没有拓展分区的!
1 2 3 4 5 6 7 8 9 10 11 12 13 14
(parted) mkpart primary 0 500 警告: The resulting partition is not properly aligned for best performance. 忽略/Ignore/放弃/Cancel? Ignore (parted) p Model: VMware, VMware Virtual S (scsi) Disk /dev/sdb: 21.5GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags:
Number Start End Size File system Name 标志 1 17.4kB 500MB 500MB primary
(parted)
0 表示从0开始
500 表示500MB
创建逻辑分区
1 2 3 4 5 6 7 8 9 10 11 12 13
(parted) mkpart logical 501 10000 (parted) p Model: VMware, VMware Virtual S (scsi) Disk /dev/sdb: 21.5GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags:
Number Start End Size File system Name 标志 1 17.4kB 500MB 500MB primary 2 501MB 10.0GB 9499MB logical
(parted)
输入q退出,并查询分区情况
1 2 3 4 5
(parted) q 信息: You may need to update /etc/fstab.
[root@localhost ~]# ls /dev/sdb* /dev/sdb /dev/sdb1 /dev/sdb2
我们可以看见,以及成功分出两个分区
使用fdisk查询看看
fdisk -l
这里截取部分信息
1 2 3 4 5 6 7 8 9 10 11 12 13
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.