KVM Virtualization Notes (11)------KVM Linux virtual machine online expansion disk

Source: Internet
Author: User

KVM Virtual machines also support the online expansion of the disk capabilities, online expansion has a specific use of the environment, mainly used in the production environment can not be stopped casually, this article takes Hadoop as an example of the following steps:

1. View existing disks

[[email protected] test]# virsh list --all id    name                             state----------------------------------------------------  1     win7                            running  17    hadoop1                         running 18     hadoop4                         running 20    hadoop2                         running -      hadoop3                         shut off[[email protected]  test]# virsh domblklist hadoop1Target      Source------------------------------------------------vda        / images/test/hadoop1.qcow2hdc        -

2, create a piece of qcow2 virtual disk

[Email protected] test]# qemu-img create-f qcow2 hadoop1_add01.qcow2 5GFormatting ' hadoop1_add01.qcow2 ', fmt=qcow2 size =5368709120 Encryption=off cluster_size=65536 [[email protected] test]#

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/7A/C5/wKioL1a0YSaS9zkQAADshmPf3WA450.png "title=" 1.png " alt= "Wkiol1a0ysas9zkqaadshmpf3wa450.png"/>3, add this qcow2 virtual disk online

[[email protected] test]# virsh attach-disk  hadoop1 /images/test/hadoop1_add01.qcow2 vdb --cache=none --subdriver=qcow2             Disk attached successfully[[email  protected] test]# virsh domblklist hadoop1                        Target      source------------------------------------------------vda         /images/test/hadoop1.qcow2vdb        /images/test/ hadoop1_add01.qcow2hdc        -

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/7A/C5/wKioL1a0YizibtGZAABeCpmwwdk206.png "title=" 1.png " alt= "Wkiol1a0yizibtgzaabecpmwwdk206.png"/>4, enter virtual machine view, such as:

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/7A/C5/wKioL1a0Yn2hSA2zAABSB9swk_Q757.png "title=" 1.png " alt= "Wkiol1a0yn2hsa2zaabsb9swk_q757.png"/>

5, then enter the system inside the partition area

Fdisk/dev/vdb

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/7A/C5/wKiom1a0Y4biAtfzAAAaEIuPcKI184.png "title=" 1.png " alt= "Wkiom1a0y4biatfzaaaaeiupcki184.png"/>

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/7A/C5/wKiom1a0Y06AqiANAABACXkO1jM598.png "style=" float: none; "title=" 1.png "alt=" Wkiom1a0y06aqianaabacxko1jm598.png "/>

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/7A/C5/wKioL1a0Y6HzlILkAAAo0LWA1Yw548.png "style=" float: none; "title=" 2.png "alt=" Wkiol1a0y6hzlilkaaao0lwa1yw548.png "/>

6, the Division of Logical Volume LVM omitted, the front can be referenced.


7. Modify the virtual machine configuration file to write the new disk configuration to the virtual machine disk configuration

(1) View the disk configuration of the current virtual machine HADOOP1

[[email protected] test]# virsh dumpxml hadoop1<domain type= ' Qemu '  id= ' ">  <name>hadoop1</name>  <uuid> 919f0921-0736-ad5b-780b-a440de2f35cb</uuid>  <memory unit= ' KiB ' >524288</memory >  <currentmemory unit= ' KiB ' >524288</currentMemory>  <vcpu  placement= ' static ' >1</vcpu>  <os>    <type arch= ' x86_64 '  machine= ' rhel6.6.0 ' >hvm</type>    <boot dev= ' HD '/>   </os>  <features>    <acpi/>    <apic/ >    <pae/>  </features>  <clock offset= ' UTC '/ >  <on_poweroff>destroy</on_poweroff>  <on_reboot>restart</on_ Reboot>  <on_crash>restart</on_crash&gT;  <devices>    <emulator>/usr/libexec/qemu-kvm</emulator>     <disk type= ' file '  device= ' disk ' >       <driver name= ' qemu '  type= ' qcow2 '  cache= ' None '/>      < Source file= '/images/test/hadoop1.qcow2 '/>      <target dev= ' VDA '  bus= ' virtio '/>      <alias name= ' Virtio-disk0 '/>       <address type= ' PCI '  domain= ' 0x0000 '  bus= ' 0x00 '  slot= ' 0x05 '  function= ' 0x0 '/>    </disk>    <disk type= ' File '  device= ' disk ' >      <driver name= ' qemu '  type= ' qcow2 '  cache= ' None '/>      <source file= '/images/test/hadoop1_ Add01.qcow2 '/>       <target dev= ' vdb '  bus= ' virtio '/>      < Alias name= ' Virtio-disk1 '/>      <address type= ' PCI '  domain = ' 0x0000 '  bus= ' 0x00 '  slot= ' 0x07 '  function= ' 0x0 '/>    </disk>     <disk type= ' block '  device= ' cdrom ' >      < Driver name= ' qemu '  type= ' raw '/>      <target dev= ' hdc '  bus= ' IDE '/>      <readonly/>       <alias name= ' ide0-1-0 '/>      <address type= ' drive '   Controller= ' 0 '  bus= ' 1 '  target= ' 0 '  unit= ' 0 '/>    </disk>     <controller type= ' USB '  index= ' 0 '  model= ' ich9-ehci1 ' >       <alias&nbsP;name= ' usb0 '/>      <address type= ' PCI '  domain= ' 0x0000 '   bus= ' 0x00 '  slot= ' 0x04 '  function= ' 0x7 '/>    </controller>     <controller type= ' USB '  index= ' 0 '  model= ' ich9-uhci1 ' >       <alias name= ' usb0 '/>      <master startport= ' 0 '/ >      <address type= ' PCI '  domain= ' 0x0000 '  bus= ' 0x00 '   slot= ' 0x04 '  function= ' 0x0 '  multifunction= ' on '/>    </controller>     <controller type= ' USB '  index= ' 0 '  model= ' ich9-uhci2 ' >       <alias name= ' usb0 '/>      <master startport = ' 2 '/>      <address type= ' PCI '  domain= ' 0x0000 '  bus= ' 0x00 '  slot= ' 0x04 ' &NBsp;function= ' 0x1 '/>    </controller>    <controller  Type= ' USB '  index= ' 0 '  model= ' ich9-uhci3 ' >      <alias name= ' Usb0 '/>      <master startport= ' 4 '/>       <address type= ' PCI '  domain= ' 0x0000 '  bus= ' 0x00 '  slot= ' 0x04 '  function= ' 0x2 '/ >    </controller>    <controller type= ' IDE '   index= ' 0 ' >      <alias name= ' ide0 '/>       <address type= ' PCI '  domain= ' 0x0000 '  bus= ' 0x00 '  slot= ' 0x01 '  function= ' 0x1 '/ >    </controller>    <interface type= ' Bridge ' >       <mac address= ' 52:54:00:b6:bf:1f '/>       <source&nbsP;bridge= ' br0 '/>      <target dev= ' Vnet1 '/>       <model type= ' virtio '/>      <alias name= ' Net0 '/>      <address type= ' PCI '  domain= ' 0x0000 '  bus= ' 0x00 '  slot= ' 0x03 '  function= ' 0x0 '/>    </interface>     <serial type= ' pty ' >      <source path= '/DEV/PTS/2 '/>       <target port= ' 0 '/>      <alias  Name= ' serial0 '/>    </serial>    <console type= ' Pty '  tty= '/dev/pts/2 ' >      <source path= '/DEV/PTS/2 '/>       <target type= ' serial '  port= ' 0 '/>       <alias name=' Serial0 '/>    </console>    <input type= ' mouse '  bus= ' ps2 '/>    <graphics type= ' vnc '  port= ' 5911 '  autoport= ' no '  listen= ' 0.0.0.0 ' >      <listen type= ' address '  address= ' 0.0.0.0 '/>    </graphics>    <video>       <model type= ' Cirrus '  vram= ' 9216 '  heads= ' 1 '/>       <alias name= ' Video0 '/>      <address type= ' PCI '  domain= ' 0x0000 '  bus= ' 0x00 '  slot= ' 0x02 '  function= ' 0x0 '/>    </ Video>    <memballoon model= ' Virtio ' >       <alias name= ' Balloon0 '/>      <address type= ' PCI '  domain = ' 0x0000 '  bus= ' 0x00 '  slot= ' 0x06 '  function= ' 0x0 '/>    </memballoon>  </devices> </domain>


(2) Add the following configuration to the/etc/libvirt/qemu/hadoop1.xml configuration file

<disk type= ' file ' device= ' disk ' > <driver name= ' qemu ' type= ' qcow2 ' cache= ' None '/> <source file= '/I      Mages/test/hadoop1_add01.qcow2 '/> <target dev= ' vdb ' bus= ' virtio '/> <alias name= ' Virtio-disk1 '/> <address type= ' PCI ' domain= ' 0x0000 ' bus= ' 0x00 ' slot= ' 0x07 ' function= ' 0x0 '/> </disk>


650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/7A/C5/wKiom1a0Z2aD00LdAAGB6Cp_t9A795.png "style=" float: none; "title=" 1.png "alt=" Wkiom1a0z2ad00ldaagb6cp_t9a795.png "/>650) this.width=650; src= http://s1.51cto.com/ Wyfs02/m00/7a/c5/wkiol1a0abjt1alqaafy6s32lmg936.png "title=" 2.png "alt=" Wkiol1a0abjt1alqaafy6s32lmg936.png "/>

When all the configuration files are written to the virtual machine configuration information, the prompt restart can also take effect.


This article is from the "Breght Moon" blog, make sure to keep this source http://liqingbiao.blog.51cto.com/3044896/1741252

KVM Virtualization Notes (11)------KVM Linux virtual machine online expansion disk

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.