源文档地址:https://www.2daygeek.com/create-lvm-storage-logical-volume-manager-in-linux/
?
1. 创建PV
创建前/dev/sdb不能分区,如果已经分区,使用fdisk /dev/sdb 删除分区
[root@O-Friday ~]# pvcreate /dev/sdb /dev/sdc
WARNING: dos signature detected on /dev/sdb at offset 510. Wipe it? [y/n]: y
Wiping dos signature on /dev/sdb.
WARNING: dos signature detected on /dev/sdc at offset 510. Wipe it? [y/n]: y
Wiping dos signature on /dev/sdc.
Physical volume "/dev/sdb" successfully created.
Physical volume "/dev/sdc" successfully created.
[root@O-Friday ~]# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name openeuler
PV Size <98.00 GiB / not usable 3.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 25087
Free PE 0
Allocated PE 25087
PV UUID Yv3d0c-OjcH-8s93-MsfZ-1JUu-XwU3-NYyPYD
"/dev/sdb" is a new physical volume of "10.00 GiB"
--- NEW Physical volume ---
PV Name /dev/sdb
VG Name
PV Size 10.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID AxdYk0-Giiv-kF4Z-QOIj-yA6j-Rsf0-BI7S2o
"/dev/sdc" is a new physical volume of "10.00 GiB"
--- NEW Physical volume ---
PV Name /dev/sdc
VG Name
PV Size 10.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID Nz06rK-h4FH-Jy2v-hXuE-hiws-6SRW-PSMQez
2. 创建VG
vgname = openeuler是系统安装时自动创建
[root@O-Friday ~]# vgcreate vg01 /dev/sdb /dev/sdc
Volume group "vg01" successfully created
[root@O-Friday ~]# vgdisplay
--- Volume group ---
VG Name vg01
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 2
Act PV 2
VG Size 19.99 GiB
PE Size 4.00 MiB
Total PE 5118
Alloc PE / Size 0 / 0
Free PE / Size 5118 / 19.99 GiB
VG UUID oAbeGg-j8U2-kCuO-tcmW-HQWv-MqbT-kQdipr
--- Volume group ---
VG Name openeuler
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size <98.00 GiB
PE Size 4.00 MiB
Total PE 25087
Alloc PE / Size 25087 / <98.00 GiB
Free PE / Size 0 / 0
VG UUID I7kRIn-4XeX-0agf-OxRq-ehSi-hqJf-nvkmtU
3. 查看vg
[root@O-Friday ~]# vgs vg01
VG #PV #LV #SN Attr VSize VFree
vg01 2 0 0 wz--n- 19.99g 19.99g
4. 扩展VG
[root@O-Friday ~]# vgextend vg01 /dev/sdd
WARNING: dos signature detected on /dev/sdd at offset 510. Wipe it? [y/n]: y
Wiping dos signature on /dev/sdd.
Physical volume "/dev/sdd" successfully created.
Volume group "vg01" successfully extended
5. 创建LV
/swap 与 /root为安装系统时自动创建
[root@O-Friday ~]# lvcreate -n lv001 -L 15G vg01
Logical volume "lv001" created.
[root@O-Friday ~]# lvdisplay
--- Logical volume ---
LV Path /dev/vg01/lv001
LV Name lv001
VG Name vg01
LV UUID 0TdOKB-PDI3-LWDv-X2nb-lBVV-kfLJ-jVOVBy
LV Write Access read/write
LV Creation host, time O-Friday, 2023-03-15 14:24:07 +0800
LV Status available
# open 0
LV Size 15.00 GiB
Current LE 3840
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:2
--- Logical volume ---
LV Path /dev/openeuler/swap
LV Name swap
VG Name openeuler
LV UUID xNBLth-zrQf-HY8L-fSrA-jrrU-qERF-xfDafa
LV Write Access read/write
LV Creation host, time O-Friday, 2023-03-05 10:52:53 +0800
LV Status available
# open 2
LV Size 6.00 GiB
Current LE 1536
Segments 1
Allocation inherit
Read ahead