添加并识别硬件设备:fdisk -l
创建分区并识别分区:fdisk /dev/sdb
fdisk分区详细操作:
[root@v6px ~]# fdisk /dev/sdb
新建分区:(n)
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select(default p):
Using default response p
默认为分区1,回车即可
Partition number (1-4, default 1):
配置分区起始点,回车即可
First sector (2048-629145599, default 2048):
配置分区结束点,回车即可(规划为多个分区时候,可以输入+10G,表示为分区1分配10G空间)
Last sector,+sectors or +size{K,M,G}(2048-629145599, default 629145599):
打印分区情况(p)
Command (m for help): p
保存分区配置(w)
Command (m for help): w
大于等于2T
添加并识别硬件设备:fdisk -l
创建分区并识别分区:parted /dev/sdb
(parted) 输入值详解:
print 打印已有分区情况
mkpart 创建分区
rm 删除分区
quit 退出
命令详解:
-- 新建分区
(parted) mkpart
Partition type? primary/extended? primary
File system type? [ext2]? xfs
Start? 1MB
End? 1T
(parted) print
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 2174GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number StartEnd Size Type File system Flags
1 1049kB 1000GB 1000GB primary
(parted) mkpart
Partition type? primary/extended? primary
File system type? [ext2]? xfs
Start? 1T
End? -1
(parted) print
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 2174GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number StartEnd Size Type File system Flags
1 1049kB 1000GB 1000GB primary
2 1000GB 2174GB 1174GB primary
-- 删除分区
(parted)rm Partition number? 2 (parted) print Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 2174GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number StartEnd Size Type File system Flags
1 1049kB 1000GB 1000GB primary
-- 修改分区格式
(parted) mklabel gpt
(parted) print
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 2174GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number StartEnd Size Type File system Flags
(parted) mklabel gpt Warning: 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 (parted) print Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 2174GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number StartEnd Size File system Name Flags
-- 修改分区大小
(parted) resizepart
-- 打印分区情况
(parted) print Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 2174GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number StartEnd Size Type File system Flags
1 1049kB 1000GB 1000GB primary
常见问题:
(parted) print
Error: /dev/sdb: unrecognised disk label
解决方法:
(parted) mklabel gpt