fdisk /dev/sdb
Command (m for help): n ##新建磁盘分区
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p ##主分区
Partition number (1-4, default 1): 1 ##磁盘分区号
First sector (2048-41943039, default 2048): ##默认开始位置
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-41943039, default 41943039): ##默认结束位置
Created a new partition 1 of type 'Linux' and of size 20 GiB.
Command (m for help): p ##显示
Disk /dev/sdb: 20 GiB, 21474836480 bytes, 41943040 sectors
Disk model: VMware Virtual S
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xafbd4a1f
Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 41943039 41940992 20G 83 Linux
Command (m for help): w ##保存更改
格式化磁盘(跳过,LVM扩展不需要格式化)
root@master1:~# partprobe /dev/sdb1
root@master1:~# lsblk
sdb 8:16 0 20G 0 disk
└─sdb1 8:17 0 20G 0 part
root@master1:~# mkfs.ext4 /dev/sdb1
Allocating group tables: done
Writing inode tables: done