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
Sector size(logical/physical): 512B/512B
Partition Table:gpt
Number Start End Size File system Name Flags
(parted) mkpart
Partition name? []? gpt2t ---指定分区名称
File system type? [ext2]ext3 ----指定分区类型
Start? 1 ---指定开始位置
End? 2190GB ---指定结束位置
(parted) P ----显示分区信息
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sde: 2190GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
1 17.4kB 2190GB 2190GB gpt2t
(parted) Q ---退出
Information: Don't forget to update /etc/fstab, if necessary. -----提示不要忘记更新/etc/fstab文件
2.3 通过parted工具来实现单磁盘多分区
[root@jetsen ~]#parted /dev/sdd
GNU Parted 1.8.1
Using /dev/sdd
Welcome to GNUParted! Type 'help' to view a list of commands.
(parted) p ---列出分区信息
Error:Unable to open /dev/sdd - unrecognised disk label. ----由于没有打上磁盘标签,所以表现信息无法列出
(parted)mklabel ----创建磁盘标签
New disk labeltype? gpt ---输入磁盘表情名
(parted) p ----再次列出磁盘分区
Model: VMware,VMware Virtual S (scsi) ---显示磁盘类型为SCSI磁盘
Disk /dev/sdd:1100GB ---磁盘大小为1100GB
Sector size(logical/physical): 512B/512B ---扇区大小为512B
Partition Table:gpt ----显示标签名为我刚才输入的标签名称
Number Start End Size File system Name Flags ----现在是一新硬盘还没有创建分区
(parted)mkpart ---创建分区
Partitionname? []? part1 ---指定分区名称
File systemtype? [ext2]? ext2 ---定义分区类型
Start? 1G ---指定起始位置
End? 10G ----指定终止位置
(parted)mkpart ---创建分区
Partitionname? []? part2 ---指定分区名称
File systemtype? [ext2]? ext2 ---定义分区类型
Start? 11G ---指定起始位置
End? 100G ---指定终止位置
(parted)mkpart
Partitionname? []? part3
File systemtype? [ext2]?
Start? 101G ----指定分区其实位置
End? -1 ----指定到分区最后
(parted) p ----显示分区信息
Model: VMware,VMware Virtual S (scsi)
Disk /dev/sdd:1100GB
Sector size (logical/physical):512B/512B
Partition Table:gpt
Number Start End Size File system Name Flags ---查看到下面共有三个分区
1 17.4kB 10.0GB 10000MB part1
2 10.0GB 100GB 90.0GB part2
3 100GB 1100GB 1000GB part3
(parted) rm 3 ------删除分区3
(parted) p ------再次查看分区状态
Model: VMware,VMware Virtual S (scsi)
Disk /dev/sdd:1100GB
Sector size(logical/physical): 512B/512B
Partition Table:gpt
Number Start End Size File system Name Flags ----显示分区删除成功,只剩下两个分区
1 17.4kB 10.0GB 10000MB part1
2 10.0GB 100GB 90.0GB part2
(parted) quit
Information: Don'tforget to update /etc/fstab, if necessary.
[root@jetsen ~]#ls -l /dev/sdd*
brw-r----- 1 rootdisk 8, 48 May 10 16:48 /dev/sdd
brw-r----- 1 rootdisk 8, 49 May 10 16:48 /dev/sdd1
brw-r----- 1 rootdisk 8, 50 May 10 16:48 /dev/sdd2
[root@jetsen ~]#
