1、查看计算节点上虚机挂载的卷

[root@xgto01n010243186070 ~]# virsh domblklist instance-
Target Source
------------------------------------------------
vda /os_instance/026deca9-64a9-4cb4-830d-6806356be1bb/disk

2、查看计算节点上的vg

[root@xgto01n010243186070 ~]# vgdisplay
--- Volume group ---
VG Name vg_os
System ID
Format lvm2
Metadata Areas
Metadata Sequence No
VG Access read/write
VG Status resizable
MAX LV
Cur LV
Open LV
Max PV
Cur PV
Act PV
VG Size 4.04 TiB
PE Size 4.00 MiB
Total PE
Alloc PE / Size / 3.24 TiB
Free PE / Size / 813.12 GiB
VG UUID Dgvra8-axy2-H6iR-KQKN-t1hL-L89y-6ONv6l

3、创建lvm卷

[root@xgto01n010243186070 ~]# lvcreate -n test36 -L 1.5 vg_os
Rounding up size to full physical extent 4.00 MiB
Logical volume "test36" created.

4、查看创建的lvm卷

[root@xgto01n010243186070 ~]# lvdisplay |grep test36
LV Path /dev/vg_os/test36
LV Name test36

5、virsh  attach-disk挂载卷

virsh attach-disk instance- /dev/vg_os/test36 vdb --driver qemu --mode shareable

6、查看虚机挂载的lvm卷

[root@xgto01n010243186070 ~]# virsh domblklist instance-
Target Source
------------------------------------------------
vda /os_instance/026deca9-64a9-4cb4-830d-6806356be1bb/disk
vdb /dev/vg_os/test36

7、卸载虚机额外挂载的lvm卷

virsh detach-disk <domain> <target> [--persistent] [--config] [--live] [--current]
virsh detach-disk instance- vdb
[root@xgto01n010243186070 ~]# virsh detach-disk instance- vdb
Disk detached successfully

8、检查lvm卷是否卸载成功

[root@xgto01n010243186070 ~]# virsh domblklist instance-
Target Source
------------------------------------------------
vda /os_instance/026deca9-64a9-4cb4-830d-6806356be1bb/disk

9、移除创建的lvm卷

[root@xgto01n010243186070 ~]# lvremove /dev/vg_os/test36
Do you really want to remove active logical volume vg_os/test36? [y/n]: y
Logical volume "test36" successfully removed
[root@xgto01n010243186070 ~]# lvdisplay |grep test36
05-25 14:17