KVM之virsh管理Storyage pool
Posted wshenjin
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了KVM之virsh管理Storyage pool相关的知识,希望对你有一定的参考价值。
创建基于文件夹的存储池
基于文件夹的存储池:
[[email protected] ~]# mkdir /data/vm_pool
[[email protected] ~]# virsh pool-create-as --name vmdir_pool --type dir --target /data/vm_pool
Pool vmdir_pool created
基于文件夹的存储池:
[[email protected] ~]# mkdir /data/vmfs_pool
[[email protected] ~]# virsh pool-create-as --name vmfs_pool --type fs --source-dev /dev/sdb1 --source-format ext4 --target /data/vmfs_pool
Pool vmfs_pool created
查看存储池状态
[[email protected] ~]# virsh pool-list --all
Name State Autostart
-------------------------------------------
vmdir_pool active no
vmfs_pool active no
[[email protected] ~]# virsh pool-info vmdir_pool
Name: vmdir_pool
UUID: 498b5826-f733-435c-ac73-b6fc33d04e58
State: running
Persistent: no
Autostart: no
Capacity: 98.30 GiB
Allocation: 14.95 GiB
Available: 83.36 GiB
[[email protected] ~]# virsh pool-info vmfs_pool
Name: vmfs_pool
UUID: df740ec9-362f-4dea-98a6-cbd62c6e2887
State: running
Persistent: no
Autostart: no
Capacity: 19.56 GiB
Allocation: 43.94 MiB
Available: 19.52 GiB
在存储池中创建卷
[[email protected] ~]# virsh vol-create-as --pool vmdir_pool --name vm_disk01.raw --capacity 10G --allocation 1G --format raw
Vol vm_disk01.raw created
- --capacity 10G #总容量
- --allocation 1G #初始大小
查看存储池的卷信息
[[email protected] ~]# virsh vol-list [--pool] vmdir_pool
Name Path
------------------------------------------------------------------------------
vm_disk01.raw /data/vm_pool/vm_disk01.raw
vm_disk02.raw /data/vm_pool/vm_disk02.raw
[[email protected] ~]# virsh vol-list [--pool] vmdir_pool --details
Name Path Type Capacity Allocation
-------------------------------------------------------------------------
vm_disk01.raw /data/vm_pool/vm_disk01.raw file 10.00 GiB 1.00 GiB
vm_disk02.raw /data/vm_pool/vm_disk02.raw file 10.00 GiB 1.00 GiB
[[email protected] ~]# ll /data/vm_pool/ -h
total 1.1G
-rw------- 1 root root 10G Jun 28 14:06 vm_disk01.raw
[[email protected] ~]# virsh vol-info /data/vm_pool/vm_disk01.raw
Name: vm_disk01.raw
Type: file
Capacity: 10.00 GiB
Allocation: 1.00 GiB
[[email protected] ~]# virsh vol-info [--vol] vm_disk01.raw --pool vmdir_pool
Name: vm_disk01.raw
Type: file
Capacity: 10.00 GiB
Allocation: 1.00 GiB
删除存储池
[[email protected] ~]# virsh pool-destroy vm_pool
Pool vm_pool destroyed
以上是关于KVM之virsh管理Storyage pool的主要内容,如果未能解决你的问题,请参考以下文章