KVM virtualization learning notes Series
----------------------------------------
Kvm virtualization learning notes (1) Installation of kvm virtualization environment
Http://koumm.blog.51cto.com/703525/1288795
Kvm virtualization learning notes (2) linux kvm Virtual Machine Installation
Http://koumm.blog.51cto.com/703525/1289627
Kvm virtualization Study Notes (iii) windows kvm Virtual Machine Installation
Http://koumm.blog.51cto.com/703525/1290191
Kvm virtualization learning notes (4) daily management and configuration of kvm virtual machines
Http://koumm.blog.51cto.com/703525/1290269
Kvm virtualization learning notes (5) Performance adjustment for windows virtual machines
Http://koumm.blog.51cto.com/703525/1290682
Kvm virtualization learning notes (6) kvm VM Console Logon Configuration
Http://koumm.blog.51cto.com/703525/1290996
Kvm virtualization learning notes (7) cloning of kvm virtual machines
Http://koumm.blog.51cto.com/703525/1291793
Kvm virtualization learning notes (8)-kvm Virtual Machine vnc Configuration
Http://koumm.blog.51cto.com/703525/1291803
Kvm virtualization learning notes (9)-kvm Virtual Machine Time Configuration
Http://koumm.blog.51cto.com/703525/1291862
Kvm virtualization learning notes (10) backup of kvm Virtual Machine snapshots
Http://koumm.blog.51cto.com/703525/1291893
Kvm virtualization learning notes (11): Expanding disk space using kvm virtual machines
Http://koumm.blog.51cto.com/703525/1292146
Kvm virtualization learning notes (12) Online disk expansion for kvm linux virtual machines
Http://koumm.blog.51cto.com/703525/1295296
The disk space expansion of kvm virtual machines is consistent with that of xen virtual machines. The reason is that the default Virtual Machine disk format of xen/kvm is raw, so this method can be used universally.
The raw disk format is extended as follows:
(1) Add a new raw-format disk to the KVM virtual machine, and manage the disk space through the lvm logical volume management of the Virtual Machine System.
(2) directly use the dd command to expand the existing virtual machine disk size. After expansion, the original disk size increases. after entering the virtual machine system, the new space is directly added through the fdisk partition, then, the partition is merged into the lvm logical volume to expand the disk space.
Xen virtualization practice series (4) xen Virtual Machine expansion disk space method http://koumm.blog.51cto.com/703525/1285460
Xen virtualization practice series (5) xen Virtual Machine disk space expansion method http://koumm.blog.51cto.com/703525/1285489
The following describes how to expand the qcow2 disk format:
(1) The raw disk format can be used to expand disks in the same way.
(2) qcow2 disks are directly extended through qemu-img, a raw disk is added to the KVM virtual machine, and then managed through the lvm logical volume management of the Virtual Machine System, expand disk space.
The following describes how to add a disk in qcow2 format.
Method 1: Add a qcow2 disk to a VM
1. view the current Virtual Machine disk Information
(1) disk size and format information
View the Virtual Machine disk format.
650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" image "border =" 0 "alt =" image "src =" http://www.bkjia.com/uploads/allimg/131227/163S61Z6-0.png "height =" 410 "/>
View disk format information
650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" image "border =" 0 "alt =" image "src =" http://www.bkjia.com/uploads/allimg/131227/163S64Z5-1.png "height =" 136 "/>
Go to the virtual machine to view the disk capacity.
[Root @ test01 ~] # Df-h
Filesystem Size Used Avail Use % Mounted on
/Dev/mapper/vg-root 5.7G 3.1G 2.4G 57%/
/Dev/hda1 99 M 24 M 71 M 25%/boot
Tmpfs 249 M 0 249 M 0%/dev/shm
(2) Add a qcow2 Disk
# Qemu-img create-f qcow2 test01_add.qcow2 2G
650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" image "border =" 0 "alt =" image "src =" http://www.bkjia.com/uploads/allimg/131227/163SC150-2.png "height =" 176 "/>
(3) Add a qcow2 disk to the configuration file.
[Root @ node1 data] # virsh shutdown oeltest01
The domain oeltest01 is disabled.
[Root @ node1 data] #
[Root @ node1 data] # virsh list -- all
Id name status
----------------------------------------------------
-Disable oeltest01
-Disable oeltest02
-Disable oeltest03
-Disable wintest01
Add the following content to the configuration file:
# Virsh edit oeltest01
<Disk type = 'file' device = 'disk'>
<Driver name = 'qemu' type = 'qcow2 'cache = 'none'/>
<Source file = '/data/test01_add.qcow2'/>
<Target dev = 'hdb' bus = 'ide '/>
</Disk>
(4) Start the VM and configure the disk
# Virsh start oeltest01
# Virsh console oeltest01
650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" image "border =" 0 "alt =" image "src =" http://www.bkjia.com/uploads/allimg/131227/163S64X1-3.png "height =" 376 "/>
2. Configure LVM disk Extension
(1) Partition
650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" image "border =" 0 "alt =" image "src =" http://www.bkjia.com/uploads/allimg/131227/163SA231-4.png "height =" 358 "/>
(2) Extend the logical volume of lvm.
650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" image "border =" 0 "alt =" image "src =" http://www.bkjia.com/uploads/allimg/131227/163SB042-5.png "height =" 461 "/>
Method 2: directly expand the qcow2 Disk
Connect to the test environment.
(1) shut down the virtual machine.
(2) Delete the second disk in the configuration file
(3) use the snapshot created in the kvm Virtual Machine Snapshot Backup in kvm virtualization learning notes (10) to restore the virtual machine.
1. directly expand the qcow2 Disk
(1) view Disks
# Virsh edit oeltest01
<Disk type = 'file' device = 'disk'>
<Driver name = 'qemu' type = 'qcow2 'cache = 'none'/>
<Source file = '/data/test01.qcow2'/>
<Target dev = 'hda' bus = 'ide '/>
<Address type = 'Drive 'controller = '0' bus = '0' target = '0' unit = '0'/>
</Disk>
(2) directly expand the qcow2 Disk
# Qemu-img resize test01.qcow2 + 2G
650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" image "border =" 0 "alt =" image "src =" http://www.bkjia.com/uploads/allimg/131227/163S63534-6.png "height =" 285 "/>
After comparison, the disk size has been expanded from 7 GB to 9 GB. The qcow2 disk format must be extended in this way. Do not use the dd format. The dd format is applicable to the raw format.
2. Enter the system to start expanding the disk
(1) view partition size
[Root @ test01 ~] # Fdisk-l
Disk/dev/hda: 9663 MB, 9663676416 bytes
255 heads, 63 sectors/track, 1174 cylinders
Units = cylinders of 16065*512 = 8225280 bytes
Device Boot Start End Blocks Id System
/Dev/hda1*1 13 104391 83 Linux
/Dev/hda2 14 913 7229250 8e Linux LVM
Disk/dev/dm-0: 6308 MB, 6308233216 bytes
255 heads, 63 sectors/track, 766 cylinders
Units = cylinders of 16065*512 = 8225280 bytes
Disk/dev/dm-0 doesn't contain a valid partition table
Disk/dev/dm-1: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065*512 = 8225280 bytes
Disk/dev/dm-1 doesn't contain a valid partition table
[Root @ test01 ~] #
(2) Start partitioning
[Root @ test01 ~] # Fdisk/dev/hda
The process is as follows: divide the extended space into a zone.
650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" image "border =" 0 "alt =" image "src =" http://www.bkjia.com/uploads/allimg/131227/163S620L-7.png "height =" 590 "/>
View Current disk space
650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" image "border =" 0 "alt =" image "src =" http://www.bkjia.com/uploads/allimg/131227/163S62K2-8.png "height =" 81 "/>
(3) create a physical volume, add it to the volume group, and expand the logical volume.
650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" image "border =" 0 "alt =" image "src =" http://www.bkjia.com/uploads/allimg/131227/163S64096-9.png "height =" 513 "/>
By now, the disk space of the kvm virtual machine has been expanded successfully. After the disk format of the virtual machine is changed to qcow2, there are many things to note: The qcow2 format supports dynamic expansion and snapshot functions, although the performance is slightly worse than raw, but it is very practical.
This article is from the "koumm linux technology blog" blog, please be sure to keep this source http://koumm.blog.51cto.com/703525/1292146