The KVM virtual machine disk space extension is consistent with the Xen virtual machine disk space expansion approach. The reason is that the XEN/KVM default virtual machine disk format is raw, so the method can be generalized.
The raw disk format extension is as follows
(1) Add a new piece of raw disk to the KVM virtual machine, then manage the virtual machine system LVM Logical Volume management, expand the disk space.
(2) Expansion of the existing virtual machine disk size directly through the DD command, after expansion, the original disk size increases, after entering the virtual machine system, directly through the Fdisk partition newly added space, and then merge the partition into the LVM logical volume, expand disk space.
Xen Virtualization Combat Series (iv) Xen virtual machine Extended disk space One method http://koumm.blog.51cto.com/703525/1285460
Xen Virtualization Combat Series (v) Xen virtual machine Extended disk space another method http://koumm.blog.51cto.com/703525/1285489
Qcow2 disk format expansion ideas are as follows
(1) The raw disk format disk can be extended in a consistent manner.
(2) Qcow2 format disk, directly through the qemu-img directly extend the QCOW2 disk, new add a piece of raw format of the disk to the KVM virtual machine, and then through the virtual machine system LVM Logical Volume management mode for management, expand disk space.
The following will begin adding disks through the QCOW2 format.
Method One: Add a piece of qcow2 disk to the virtual machine
1. View virtual machine disk information now
(1) disk size and format information
View the virtual machine disk format.
View Disk format information
Enter the virtual machine to view the disk capacity.
[Email protected] ~]# df-h
Filesystem Size used Avail use% mounted on
/dev/mapper/vg-root 5.7G 3.1G 2.4G 57%/
/DEV/HDA1 99M 24M 71M 25%/boot
Tmpfs 249M 0 249M 0%/dev/shm
(2) Adding a piece of qcow2 disk
# qemu-img create-f qcow2 test01_add.qcow2 2G
(3) Adding a piece of qcow2 disk information to the configuration file
[Email protected] data]# Virsh shutdown oeltest01
Domain oeltest01 is closed
[Email protected] data]#
[Email protected] data]# Virsh list--all
Id Name Status
----------------------------------------------------
-Oeltest01 off
-Oeltest02 off
-oeltest03 off
-Wintest01 off
Include the following in 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 virtual machine and configure the disk
# Virsh Start oeltest01
# Virsh Console oeltest01
2. Configuring the LVM expansion disk
(1) Partitioning
(2) Extend the LVM logical volume.
Mode two: Direct expansion qcow2 disk
Restore the test environment.
(1) Shut down the virtual machine.
(2) Delete the second disk information in the configuration file
(3) Recovering a virtual machine from a snapshot created in a KVM virtual machine snapshot backup of the KVM Virtualization Learning Note (10).
1. Direct expansion of the QCOW2 disk
(1) View disk
# 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) Direct expansion QCOW2 disk
# qemu-img Resize Test01.qcow2 +2g
After comparison, the disk size has been extended from 7G to 9G, the QCOW2 disk format must be extended in this way, do not use DD mode, DD method for RAW format.
2. Enter the system to start expanding the disk
(1) View partition size
[Email protected] ~]# fdisk-l
disk/dev/hda:9663 MB, 9663676416 bytes
255 heads, Sectors/track, 1174 cylinders
Units = Cylinders of 16065 * 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, Sectors/track, 766 cylinders
Units = Cylinders of 16065 * 8225280 bytes
disk/dev/dm-0 doesn ' t contain a valid partition table
Disk/dev/dm-1:1073 MB, 1073741824 bytes
255 heads, Sectors/track, cylinders
Units = Cylinders of 16065 * 8225280 bytes
Disk/dev/dm-1 doesn ' t contain a valid partition table
[Email protected] ~]#
(2) Start partition
[Email protected] ~]# Fdisk/dev/hda
The process is as follows, dividing the expanded space into a single area.
View disk space now
(3) Start creating physical volumes, adding volume groups, and extending logical volumes.
To this KVM virtual machine expansion disk space is successful, when the virtual machine disk format replaced with Qcow2, there are a lot of things to note, the QCOW2 format supports dynamic scaling and snapshot functionality, although the sex is slightly worse than raw, but it is really practical.
kvm--Virtual machine disk space expansion