009. KVM Configuration Adjustment

Source: Internet
Author: User
One memory CPU is adjusted by 1.1 to increase the VM memory
1 [[email protected] ~] # Virsh shutdown vm01-centos6.8 2 [[email protected] ~] # Virsh edit vm01-centos6.8 3 ...... 4 <memory unit = 'kiib '> 4194304 </memory> 5 <currentmemory unit = 'kiib'> 4194304 </currentmemory> # modify the current memory 6 <vcpu placement = 'state'> 4 </vcpu> # modify the current number of CPUs by 7 ...... 8 [[email protected] ~] # Virsh create/etc/libvirt/qemu/vm01-centos6.8.xml 9 # load the boot VM from the configuration file. 10 [[email protected] ~] # Virsh dominfo vm01-centos6.8 # view Max memory
 
1 virsh setmaxmem vm01-centos6.8 4G # need to shut down this VM 2 VM memory adjustment 3 virsh setmem uakvm2 2g -- config # adjust 4 virsh setmem uakvm2 2G # adjust the status of boot
Qcow2 disk resizing-: method 1 2.1 view existing Disks
1 [[email protected] ~] # Virsh edit vm01-centos6.8 2 <disk type = 'file' device = 'disk'> 3 <driver name = 'qemu' type = 'qcow2 '/> 4 <source file = '/ data/images/vm01-centos6.8.img '/> # disk Path 5 <target Dev = 'vda' bus = 'virtio'/> 6 <address type = 'pci 'domain = '0x0000' Bus = '0x00' slot = '0x04 'function = '0x0'/> 7 </disk> 8 [email protected] ~] # Qemu-IMG info/data/images/vm01-centos6.8.img
2.2 Add a qcow2 Disk
1 [[email protected] ~] # Virsh edit vm01-centos6.8 2 <disk type = 'file' device = 'disk'> 3 <driver name = 'qemu' type = 'qcow2 '/> 4 <source file = '/ data/images/vm01-centos6.8.img '/> # disk Path 5 <target Dev = 'vda' bus = 'virtio'/> 6 <address type = 'pci 'domain = '0x0000' Bus = '0x00' slot = '0x04 'function = '0x0'/> 7 </disk> 8 [email protected] ~] # Qemu-IMG info/data/images/vm01-centos6.8.img
  Reminder: Make sure that the host has sufficient space.2.3 disk configuration
  1 [[email protected] ~]# virsh console 2
Use fdisk to create vdb1 partitions and adjust the disk partition mode to LVM. The method is omitted.
  1 [[email protected] ~]# vgcreate -s 16m vg01 /dev/vdb1  2 [[email protected] ~]# lvcreate -L 1g -n lv01 vg01  3 [[email protected] ~]# mkfs.ext4 /dev/vg01/lv01  4 [[email protected] ~]# mkdir /data  5 [[email protected] ~]# mount /dev/vg01/lv01 /data/
  Note: If the created partition is LVM, you can directly add it. For more information about LVM resizing, see other notes.Iii. qcow2 disk resizing-method 2 3.1 view existing Disks
1 [[email protected] ~] # Virsh edit vm01-centos6.8 2 <disk type = 'file' device = 'disk'> 3 <driver name = 'qemu' type = 'qcow2 '/> 4 <source file = '/ data/images/vm01-centos6.8.img '/> # disk Path 5 <target Dev = 'vda' bus = 'virtio'/> 6 <address type = 'pci 'domain = '0x0000' Bus = '0x00' slot = '0x04 'function = '0x0'/> 7 </disk> 8 [email protected] ~] # Qemu-IMG info/data/images/vm01-centos6.8.img
3.2 directly resize a disk in qcw2 format
  1 [[email protected] ~]# qemu-img resize /data/images/vm01-centos6.8.img +1G
3.3 Verify again
  1 [[email protected] ~]# qemu-img info /data/images/vm01-centos6.8.img
Note: The qcow2 disk format must be extended in this mode. Do not use the DD mode. The DD mode is applicable to raw format.3.3 disk configuration
  1 [[email protected] ~]# virsh start vm01-centos6.8  2 [[email protected] ~]# fdisk -l
 
  1 [[email protected] ~]# fdisk /dev/vda  2 ……  3 Command (m for help): p
 
  1 Command (m for help): d  2 Partition number (1-4): 3  3 Command (m for help): n  4 p  5 Partition number (1-4): 3
  1 Command (m for help): w
Reminder: After the end value is deleted from 41611, create a new partition with the partition code 3 and change the end value to 47851.
  1 [[email protected] ~]# resize2fs /dev/vda3  2 [[email protected] ~]# shutdown -r now
You can also use LVM to resize the new disk or mount the disk After partitioning. The specific method is omitted. Four raw disk format resizing: method 1 4.1 to view the existing disk refer to 2.1, omitted. 4.2 create a disk file
  1 [[email protected] ~]# dd if=/dev/zero bs=1024M count=2 > /data/images/vm01-centos6.8-02.img  2 [[email protected] ~]# qemu-img info /data/images/vm01-centos6.8-02.img
4.3 add raw disks to the configuration file. For more information, see 2.2. 4.4 For disk configuration, refer to 2.3, omitted. Five raw disk format resizing: method 2 5.1 for details about how to view the existing disk, refer to 2.1, omitted. 5.2 for direct resizing, refer to 3.2, omitted. 5.3 disk configuration refer to 2.3, omitted. Six online resizing disk 6.1 view existing disk refer to 2.1, omitted. 6.2 create a disk file and add
  1 [[email protected] ~]# qemu-img create -f qcow2 /data/images/vm01-centos6.8-02.img 1G  2 [[email protected] ~]# virsh attach-disk vm01-centos6.8 /data/images/vm01-centos6.8-02.img vdb --cache=none --subdriver=qcow2  3 [[email protected] ~]# virsh domblklist vm01-centos6.8
6.3 disk configuration refer to 2.3, omitted. Tip: After online resizing, we recommend that you modify the configuration file of the VM together, which will take effect after restart.

009. KVM Configuration Adjustment

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.