原文地址
操作步骤
查看需要被分区的硬盘设备号
lsblk
输出如下信息
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdb 8:16 0 893.8G 0 disk
sdc 8:32 0 14.6T 0 disk
sda 8:0 0 118.7G 0 disk
├─sda2 8:2 0 1G 0 part /boot
├─sda3 8:3 0 117.5G 0 part
│ ├─centos-swap 253:1 0 4G 0 lvm [SWAP]
│ ├─centos-home 253:2 0 63.5G 0 lvm /home
│ └─centos-root 253:0 0 50G 0 lvm /
└─sda1 8:1 0 200M 0 part /boot/efi
对sdb
进行分区
- 输出分区信息
[root@localhost noVNC]# parted /dev/sdb
GNU Parted 3.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
Error: /dev/sdb: unrecognised disk label
Model: AVAGO MR9361-8i (scsi)
Disk /dev/sdb: 960GB
Sector size (logical/physical): 512B/4096B
Partition Table: unknown
Disk Flags:
- 创建分区表
(parted) mklabel gpt
(parted) p
Model: AVAGO MR9361-8i (scsi)
Disk /dev/sdb: 960GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
- 创建分区
(parted) mkpart docker xfs 0 960GB
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? Ignore
(parted) p
Model: AVAGO MR9361-8i (scsi)
Disk /dev/sdb: 960GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 17.4kB 960GB 960GB docker
- 将分区打上lvm标签
(parted) toggle 1 lvm
(parted) p
Model: AVAGO MR9361-8i (scsi)
Disk /dev/sdb: 960GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 17.4kB 960GB 960GB docker lvm
- 退出
parted
(parted) quit
Information: You may need to update /etc/fstab.
- 不重启读取分区信息
[root@localhost ~]# partprobe
- 使用命令pvcreate创建物理卷
[root@localhost ~]# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created.
- 创建卷组名为docker,将物理卷加入卷组
[root@localhost ~]# vgcreate docker /dev/sdb1
Volume group "docker" successfully created
- 创建逻辑卷
[root@localhost ~]# lvcreate -n docker01 -L 600G docker
Logical volume "docker01" created.
- 格式化分区
[root@localhost ~]# mkfs.xfs /dev/docker/docker01
meta-data=/dev/docker/docker01 isize=512 agcount=32, agsize=4915200 blks
= sectsz=4096 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=157286400, imaxpct=25
= sunit=64 swidth=64 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=76800, version=2
= sectsz=4096 sunit=1 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
- 将分区挂载
[root@localhost ~]# mount /dev/docker/docker01 /docker
[root@localhost ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdb 8:16 0 893.8G 0 disk
└─sdb1 8:17 0 893.8G 0 part
└─docker-docker01 253:3 0 600G 0 lvm /docker
sdc 8:32 0 14.6T 0 disk
sda 8:0 0 118.7G 0 disk
├─sda2 8:2 0 1G 0 part /boot
├─sda3 8:3 0 117.5G 0 part
│ ├─centos-swap 253:1 0 4G 0 lvm [SWAP]
│ ├─centos-home 253:2 0 63.5G 0 lvm /home
│ └─centos-root 253:0 0 50G 0 lvm /
└─sda1 8:1 0 200M 0 part /boot/efi