功能 | PV管理命令 | VG管理命令 | LV管理命令 |
---|---|---|---|
scan 扫描 | pvscan | vgscan | lvscan |
create 创建 | pvcreate | vgcreate | lvcreate |
display 显示 | pvdisplay | vgdisplay | lvdisplay |
remove 移除 | pvremove | vgremove | lvremove |
extend 扩展 | vgextend | lvextend | |
reduce 减少 | vgreduce | lvreduce |
查看磁盘
lsblk -f
- 创建PV
[root@192-168-4-254 ~]# pvcreate /dev/sda
Physical volume "/dev/sda" successfully created.
[root@192-168-4-254 ~]# pvcreate /dev/sdb
Physical volume "/dev/sdb" successfully created.
- 查看PV
[root@192-168-4-254 ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda lvm2 --- 100.00g 100.00g
/dev/sdb lvm2 --- 100.00g 100.00g
- 创建VG
[root@192-168-4-254 ~]# vgcreate data /dev/sda
Volume group "data" successfully created
- 扩展VG
[root@192-168-4-254 ~]# vgextend data /dev/sdb
Volume group "data" successfully extended
- 查看VG
[root@192-168-4-254 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
centos 1 2 0 wz--n- <199.00g 4.00m
data 2 0 0 wz--n- 199.99g 199.99g
- 创建LV
使用lvcreate创建LV。lvcreate -n lvname -L lvsize(M,G)|-l LEnumber vgname
[root@192-168-4-254 ~]# lvcreate -n lvname -L 199.99g data
Rounding up size to full physical extent 199.99 GiB
WARNING: ext4 signature detected on /dev/data/lvname at offset 1080. Wipe it? [y/n]: y
Wiping ext4 signature on /dev/data/lvname.
Logical volume "lvname" created.
- 查看LV
[root@192-168-4-254 ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root centos -wi-ao---- <191.12g
swap centos -wi-ao---- <7.88g
lvname data -wi-a----- 199.99g
- 扩展LV
[root@192-168-4-254 ~]# lvextend -l +100%FREE /dev/mapper/data-data
Size of logical volume apsvg/apspool changed from <500.00 GiB (127999 extents) to 799.99 GiB (204798 extents).
Logical volume apsvg/apspool successfully resized.
- 文件系统扩容
# ext2 ext3 ext4
resize2fs /dev/mapper/apsvg-apspool
# xfs
xfs_growfs /