作者:吴业亮
博客:http://blog.csdn.net/wylfengyujiancheng
1、定义存储池
采用本地目录方式创建KVM存储池
# mkdir -p /wyl
定义存储池
# virsh pool-define-as wylpool --type dir --target /wyl
定义池 wylpool
# virsh pool-build wylpool
构建池 wylpool
# virsh pool-list --all
Name State Autostart
-------------------------------------------
wylpool inactive no
# virsh pool-info wylpool
Name: wylpool
UUID: c5f759a4-7c25-48dd-9e50-5323ca78deb4
State: inactive
Persistent: yes
Autostart: no
设置存储池自动启动
# virsh pool-autostart wylpool
Pool wylpool marked as autostarted
启动存储池
# virsh pool-start wylpool
Pool wylpool started
# virsh pool-list --all
Name State Autostart
-------------------------------------------
wylpool active yes
# virsh pool-info wylpool
Name: wylpool
UUID: c5f759a4-7c25-48dd-9e50-5323ca78deb4
State: running
Persistent: yes
Autostart: yes
Capacity: 77.47 GiB
Allocation: 3.02 GiB
Available: 74.45 GiB
2、存储池创建映像文件,安装vm
在存储池创建一个卷(映像文件)
# virsh vol-create-as wylpool test_qcow2.img 20G --format qcow2
创建卷 test_qcow2.img
# ll /wyl/
total 196
-rw------- 1 root root 197120 Oct 21 18:43 test_qcow2.img
#
# virsh vol-info --pool wylpool /wyl/test_qcow2.img
Name: test_qcow2.img
Type: file
Capacity: 20.00 GiB
Allocation: 196.00 KiB
3、存储池的删除
#virsh pool-destroy wylpool
#virsh pool-undefine wylpool
#virsh pool-delete wylpool
virsh pool与vol命令帮助
Storage Pool (help keyword 'pool')
find-storage-pool-sources-as 找到潜在存储池源
find-storage-pool-sources 发现潜在存储池源
pool-autostart 自动启动某个池
pool-build 建立池
pool-create-as 从一组变量中创建一个池
pool-create 从一个 XML 文件中创建一个池
pool-define-as 在一组变量中定义池
pool-define define an inactive persistent storage pool or modify an existing persistent one from an XML file
pool-delete 删除池
pool-destroy 销毁(删除)池
pool-dumpxml XML 中的池信息
pool-edit 为存储池编辑 XML 配置
pool-info 存储池信息
pool-list 列出池
pool-name 将池 UUID 转换为池名称
pool-refresh 刷新池
pool-start 启动一个(以前定义的)非活跃的池
pool-undefine 取消定义一个不活跃的池
pool-uuid 把一个池名称转换为池 UUID
Storage Volume (help keyword 'volume')
vol-clone 克隆卷。
vol-create-as 从一组变量中创建卷
vol-create 从一个 XML 文件创建一个卷
vol-create-from 生成卷,使用另一个卷作为输入。
vol-delete 删除卷
vol-download 将卷内容下载到文件中
vol-dumpxml XML 中的卷信息
vol-info 存储卷信息
vol-key 为给定密钥或者路径返回卷密钥
vol-list 列出卷
vol-name 为给定密钥或者路径返回卷名
vol-path 为给定密钥或者路径返回卷路径
vol-pool 为给定密钥或者路径返回存储池
vol-resize 创新定义卷大小
vol-upload 将文件内容上传到卷中
vol-wipe 擦除卷