1、查看计算节点上虚机挂载的卷
[root@xgto01n010243186070 ~]# virsh domblklist instance-00000349Target 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 1 Metadata Sequence No 5 VG Access read/write VG Status resizable MAX LV 0 Cur LV 4 Open LV 4 Max PV 0 Cur PV 1 Act PV 1 VG Size 4.04 TiB PE Size 4.00 MiB Total PE 1058079 Alloc PE / Size 849920 / 3.24 TiB Free PE / Size 208159 / 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-00000349 /dev/vg_os/test36 vdb --driver qemu --mode shareable
6、查看虚机挂载的lvm卷
[root@xgto01n010243186070 ~]# virsh domblklist instance-00000349Target Source------------------------------------------------vda /os_instance/026deca9-64a9-4cb4-830d-6806356be1bb/diskvdb /dev/vg_os/test36
7、卸载虚机额外挂载的lvm卷
virsh detach-disk[--persistent] [--config] [--live] [--current]virsh detach-disk instance-00000349 vdb[root@xgto01n010243186070 ~]# virsh detach-disk instance-00000349 vdbDisk detached successfully
8、检查lvm卷是否卸载成功
[root@xgto01n010243186070 ~]# virsh domblklist instance-00000349Target Source------------------------------------------------vda /os_instance/026deca9-64a9-4cb4-830d-6806356be1bb/disk
9、移除创建的lvm卷
[root@xgto01n010243186070 ~]# lvremove /dev/vg_os/test36Do you really want to remove active logical volume vg_os/test36? [y/n]: y Logical volume "test36" successfully removed[root@xgto01n010243186070 ~]# lvdisplay |grep test36