KVM学习笔记(存储卷)
1、存储卷概述
存储池被分割为存储卷(Volume)
存储卷:
可以是一个文件(基于文件系统)
块设备(基于裸设备)
libvirt管理的其他设备
KVM为虚拟机屏蔽了底层存储卷的差异
2、存储卷命令
vol-clone 克隆一个卷。
vol-create-as 从一组参数创建一个卷
vol-create 从XML文件创建一个卷
vol-create-from 创建一个卷,使用另一个卷作为输入
vol-delete 删除一个卷
vol-download 将音量内容下载到文件
vol-dumpxml vol信息的XML
vol-info 存储卷信息
vol-key 返回给定卷名称或路径的音量键
vol-list 列表卷
vol-name 返回给定音量键或路径的音量名称
vol-path 返回给定卷名称或密钥的卷路径
vol-pool 返回给定音量键或路径的存储池
vol-resize 调整一个卷
vol-upload 将文件内容上传到卷
vol-wipe 擦除卷
3、创建基于文件系统存储池的卷
存储卷是一个文件
命令
vol-create-as <pool> <name> <capacity> [--allocation <string>] [--format <string>] [--backing-vol <string>] [--backing-vol-format <string>] [--prealloc-metadata] [--print-xml]
参数解释
pool 存储池名字
name 存储卷名字
capacity 存储卷大小
--format 存储卷类型
查询存储卷的信息
vol-info <vol> [--pool <string>] [--bytes] [--physical]
参数解释
vol 存储卷名字
--pool 存储池名字
4、创建基于LVM存储池的卷
卷是一个lv块设备
命令
vol-create-as <pool> <name> <capacity>
参数解释
pool 存储池名字
name 存储卷名字
capacity 存储卷大小
5、卷的克隆
命令
vol-clone <vol> <newname> [--pool <string>] [--prealloc-metadata] [--reflink]
参数解释
vol 源卷的名字
newname 克隆卷名字
--pool 存储池的名字
6、卷的删除
命令
vol-delete <vol> [--pool <string>] [--delete-snapshots]
参数解释
vol 卷的名字
--pool 存储池的名字
--delete-snapshots 同时删除快照
7、向虚拟机添加卷
通过XML文件添加,最常用
attach-device <domain> <file> [--persistent] [--config] [--live] [--current]
参数解释
domain 虚拟机的名字
--file xml文件
-- persistent 永久添加相当于--config --live
--config 下次重启生效
--live 在线添加
XML文件格式
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2' cache='none'/>
<source file='/vm/winvol1.qcow2'/>
<target dev='vdb'/>
</disk>
通过命令参数添加
attach-disk <domain> <source> <target> [--targetbus <string>] [--driver <string>] [--subdriver <string>] [--iothread <string>] [--cache <string>] [--io <string>] [--type <string>] [--mode <string>] [--sourcetype <string>] [--serial <string>] [--wwn <string>] [--rawio] [--address <string>] [--multifunction] [--print-xml] [--persistent] [--config] [--live] [--current]
参数解释
domain 虚拟机的名字
source 卷文件
target 虚拟机的目标磁盘
评论
发表评论