[理] virsh 命令

整理的部分命令

1. 往虚拟机添加 iso 文件

1 # virsh attach-disk virsh-VM /home/yb/visio.iso hda --type cdrom --mode readonly

  批注:

  1. 'virsh-VM' 为创建的,并且已经运行的虚拟机名称

  2. '/home/yb/visio.iso' 为要添加的 ISO 文件

  3. 'hda' 为创建虚拟机(virsh define)时定义的镜像文件 iso 时定义的 <target dev='hda' />

  4. 指定 type 类型为 cdrom

  5. 指定读写权限为 readonly

  6. cdrom 不能进行 detach-disk 的操作,会提示:

Operation not supported: disk device type 'cdrom' cannot be detached

  可以进入虚拟机进行手动弹出,暂未找到其他合适的方法。

  7. 创建 'hdX' 的 XML 参考模板

 1 <disk type='file' device='cdrom'>
 2   <driver name='qemu' type='raw'/>
 3   <source file='/home/yb/visio.iso'/>
 4   <target dev='hda' bus='ide'/>
 5   <readonly/>
 6   <address type='drive' controller='0' bus='0' target='0' unit='0'/>
 7 </disk>
 8 <disk type='file' device='cdrom'>
 9   <driver name='qemu' type='raw'/>
10   <target dev='hdb' bus='ide'/>
11   <readonly/>
12   <address type='drive' controller='0' bus='1' target='0' unit='0'/>
13 </disk>

  8. 创建镜像文件参考 Linux mkisofs

  

原文地址:https://www.cnblogs.com/YBhello/p/5505885.html