- 定义存储池目录
[[email protected] kvmimg]# virsh pool-define-as vmdisk --type dir --target /data/kvmimg/ Pool vmdisk defined 2.创建已定义的存储池 [[email protected] kvmimg]# virsh pool-build vmdisk Pool vmdisk built
3.查看已定义的存储池,存储池不激活无法使用
[[email protected] kvmimg]# virsh pool-list --all #查看所有存储池 Name State Autostart ----------------------------------------- default active yes vmdisk inactive no [[email protected] kvmimg]# [[email protected] kvmimg]# virsh pool-info vmdisk #查看vmdisk存储池信息 Name: vmdisk UUID: 6e80ce65-c13c-aac2-02fe-c370b6463109 State: inactive Persistent: yes Autostart: no
4.激活并自动启动已定义的存储池
[[email protected] kvmimg]# virsh pool-autostart vmdisk Pool vmdisk marked as autostarted [[email protected] kvmimg]# virsh pool-start vmdisk Pool vmdisk started [[email protected] kvmimg]# virsh pool-info vmdisk Name: vmdisk UUID: 6e80ce65-c13c-aac2-02fe-c370b6463109 State: running Persistent: yes Autostart: yes Capacity: 774.28 GiB Allocation: 55.51 GiB Available: 718.78 GiB [[email protected] kvmimg]# virsh pool-list --all Name State Autostart ----------------------------------------- default active yes vmdisk active yes
5.在存储池中创建qcow2虚拟机存储卷,之后就可以直接使用qcow2磁盘文件安装系统了
[[email protected] kvmimg]# virsh vol-create-as vmdisk test06.qcow2 20G --format qcow2 Vol test06.qcow2 created 6.删除存储池命令整理 [[email protected] kvmimg]# virsh vol-delete --pool vmdisk test06.qcow2 #删除刚刚创建的 Vol test06.qcow2 deleted [[email protected] kvmimg]# ll total 56836660 -rw-r--r-- 1 root root 17911579136 Jul 7 18:27 test01.qcow2 -rw-r--r-- 1 root root 37823512576 Jul 7 15:31 test02.qcow2 -rwxr-xr-x 1 root root 17911578624 Jul 7 17:16 test03.qcow2 -rwxr-xr-x 1 root root 17911513088 Jul 7 17:20 test04.qcow2 -rw-r--r-- 1 root root 17911578624 Jul 7 20:45 test05.qcow2 [[email protected] kvmimg]# [[email protected] kvmimg]# virsh pool-destroy vmdisk #取消激活存储池 [[email protected] kvmimg]# virsh pool-delete vmdisk #删除存储池定义的目录/data/kvmimg [[email protected] kvmimg]# virsh pool-undefine vmdisk #取消定义存储池
时间: 2024-10-03 14:17:16