zoukankan      html  css  js  c++  java
  • KVM宿主机上虚拟机动态添加新磁盘

     

    (1)KVM宿主机查看运行的虚拟机

           $ virsh list --all

     

     

    (2)将qcow2的磁盘移动到/var/lib/libvirt/images/,比如为centos.qcow2

     

     

    (3)进入/etc/libvirt/qemu/目录查看centos7.5虚拟机的xml文件

     

      查看disk配置信息

     

     

    (4)在/root目录下,编辑test.xml文件

      内容为要新添加的centos.qcow2磁盘的配置信息,如下:

    <disk type='file' device='disk'>
          <driver name='qemu' type='qcow2' cache='none'/>
          <source file='/var/lib/libvirt/images/centos.qcow2'/>
          <target dev='vdb' bus='virtio'/>
    </disk>
    

      

    (5)将该磁盘绑定到虚拟机

      $ virsh attach-device centos7.5 test.xml

     

     

    (6)登录到虚拟机查看磁盘是否绑定到虚拟机

           $ lsblk

     

     

    (7)将vdb1挂载在/mnt下查看磁盘数据并进行相应的操作

           $ moun /dev/vdb1 /mnt

     

     

    (8)数据修改完成进行umount,然后再宿主机上将该磁盘从虚拟机解绑

      $ virsh detach-device centos7.5 test.xml

     

     

     

     

  • 相关阅读:
    UVA 12307 Smallest Enclosing Rectangle
    UVALive 4728 Squares
    扩栈代码
    uva 10256 The Great Divide
    uva 11168 Airport
    uva 10625 Board Wrapping
    bzoj千题计划206:bzoj1076: [SCOI2008]奖励关
    NOIP2017 列队
    bzoj3529: [Sdoi2014]数表
    bzoj1966: [Ahoi2005]VIRUS 病毒检测
  • 原文地址:https://www.cnblogs.com/chenli90/p/10771190.html
Copyright © 2011-2022 走看看