Система виртуализации KVM чаще всего используется на серверах, а в домашних условиях используют VirtualBoax. Но, это не всегда так, KVM проф
seen from Colombia
seen from United States

seen from Russia

seen from United States

seen from Kuwait
seen from United States
seen from Maldives
seen from China
seen from United States
seen from Saudi Arabia
seen from T1

seen from Australia

seen from Australia
seen from Italy
seen from Australia
seen from Australia
seen from Australia

seen from Australia

seen from Australia

seen from United States
Система виртуализации KVM чаще всего используется на серверах, а в домашних условиях используют VirtualBoax. Но, это не всегда так, KVM проф
How to: Backup of KVM guests when using qcow2 disk files #dev #it #development
How to: Backup of KVM guests when using qcow2 disk files #dev #it #development
Backup of KVM guests when using qcow2 disk files
I got a Ubuntu (hardy) system used for virtualization using KVM. Each guest got it’s own qcow2 file used as disk. Guests are running Ubuntu (hardy). What would a good backup strategy be for such a setup? I would prefer not to shutdown the guests during backup.
Answer [by Tim Post]: Backup of KVM guests when using qcow2 disk files
You’ll want to…
View On WordPress
Resolved: free up not used space on a qcow2-image-file on kvm/qemu #answer #programming #it
Resolved: free up not used space on a qcow2-image-file on kvm/qemu #answer #programming #it
free up not used space on a qcow2-image-file on kvm/qemu
we are using kvm/qemu with qcow2-images for our virtual machines.
qcow2 has this nice feature where the image file only allocates the actually needed space by the virtual-machine. but how do i shrink back the image file, if the virtual machine’s allocated space gets smaller?
example:
1.) i create a new image with qcow2 format, size 100GB
2…
View On WordPress
Fix: Incredibly slow KVM disk performance (qcow2 disk files + virtio) #it #dev #solution
Fix: Incredibly slow KVM disk performance (qcow2 disk files + virtio) #it #dev #solution
Incredibly slow KVM disk performance (qcow2 disk files + virtio)
I’m having some serious disk performance problems while setting up a KVM guest. Using a simple dd test, the partition on the host that the qcow2 images reside on (a mirrored RAID array) writes at over 120MB/s, while my guest gets writes ranging from 0.5 to 3MB/s.
The guest is configured with a couple of CPUs and 4G of RAM and isn’t…
View On WordPress
How to: Incredibly slow KVM disk performance (qcow2 disk files + virtio) #programming #dev #development
How to: Incredibly slow KVM disk performance (qcow2 disk files + virtio) #programming #dev #development
Incredibly slow KVM disk performance (qcow2 disk files + virtio)
I’m having some serious disk performance problems while setting up a KVM guest. Using a simple dd test, the partition on the host that the qcow2 images reside on (a mirrored RAID array) writes at over 120MB/s, while my guest gets writes ranging from 0.5 to 3MB/s.
The guest is configured with a couple of CPUs and 4G of RAM and isn’t…
View On WordPress
QCOW2 形式で作った KVM のディスクイメージファイルを圧縮する
KVM のディスクイメージファイルは QCOW2 形式で作っておくと qemu-img コマンドでファイルサイズを圧縮できるみたい。 まず、圧縮をかける前にディスクイメージを使っている仮想マシン (samplevm) をあらかじめシャットダウンする。 もし、仮想マシンが ACPI に対応していないときは直接コンソールにログインして落とす。
$ sudo virsh shutdown samplevm
シャットダウンできたら qemu-img convert コマンドに -c オプションを付けてディスクイメージファイルを圧縮する。
$ sudo qemu-img convert -c -f qcow2 -O qcow2 /var/lib/libvirt/images/samplevm{,.compressed}.qcow2
圧縮前と圧縮後のファイルサイズを見ると 1/3 近くまで圧縮できたようだ。
$ ls -alFh /var/lib/libvirt/images/ | grep samplevm -rw-r--r--. 1 root root 472M 1月 25 04:48 2014 samplevm.compressed.qcow2 -rw-r--r--. 1 root root 1.3G 1月 25 04:32 2014 samplevm.qcow2
次に圧縮後のディスクイメージファイルから仮想マシンを起動する。 圧縮後のファイルを圧縮前のファイルにリネームしちゃってもいいんだけど、今回は Libvirt のドメイン定義ファイルを編集する。 ドメイン定義ファイルの編集には virsh edit コマンドを使う。
$ sudo virsh edit samplevm
編集内容は、現在使用している圧縮前のファイルのパスを圧縮後のものに書き換えれば良い。
<source file='/var/lib/libvirt/images/samplevm.qcow2'/> ↓ <source file='/var/lib/libvirt/images/samplevm.compressed.qcow2'/>
編集が終わったら仮想マシンを立ち上げる。 無事起動してコンソールが取れれば成功だ。
$ sudo virsh start samplevm $ sudo virsh console samplevm ...(省略)... Starting sshd: [ OK ] Starting postfix: [ OK ] Starting crond: [ OK ] CentOS release 6.5 (Final) Kernel 2.6.32-431.el6.x86_64 on an x86_64
ばっちり。
Expanding (and resizing) QEMU Virtual Disks
Resizing a VM partition can be tricky, so if you've ever created a disk image and realised that you needed more space, this post explains how you can resize a QEMU virtual disk, and expand its partitions if you need.
I don't recommend trying to resize the partition in place with truncate, so in this example we will create a new disk image and copy over the contents from our existing VM's disk image, resizing the partitions in the process. Our VM domain name is herman, and it's a QEMU disk image - qcow2.
First, create a temp directory where you will be working in:
TMPDIR=`mktemp -d` cd $TMPDIR
Then create your new disk here with qemu-img, with the desired size. In my case, I've chosen 32GB:
$ qemu-img create -f qcow2 -o preallocation=metadata $TMPDIR/herman_vm.qcow2 32GB
Formatting '/tmp/tmp.NKT2q5rDVz/herman_vm.qcow2', fmt=qcow2 size=34359738368 encryption=off cluster_size=65536 preallocation='metadata'
Allegedly preallocation=metadata improves I/O performance, and for a little more performance you can try fallocate. Take the size in bytes from the feedback in the previous command use fallocate if you want to preallocate the disk space:
$ fallocate -l 34359738368 $TMPDIR/herman_vm.qcow2
Clone your existing disk into the new one
Now you have your new disk ready, it's time to copy over your existing disk's data.
To find out where your existing disk image is, use virsh dumpxml and query the xml path.
$ sudo virsh dumpxml herman | xpath -e /domain/devices/disk/source > Found 1 nodes in stdin: > -- NODE -- > <source file="/vms/herman/tmpkdYhWL.qcow2" /> $ OLD_DISK=/vms/herman/tmpkdYhWL.qcow2
It is usefull to know how your existing partitions are layed out. You can find that out with virt-filesystems:
$ sudo virt-filesystems --long --parts --blkdevs -h -a $OLD_DISK
Note down the partitions you want to expand, or resize: expand means take up the remaining free space (only one partition can be expanded), while resize means resize to a specific size. If you resize all your partitions, the remaining free space will be unallocated.
In our case, I've chosen to resize the swap /dev/sda2 partition to 2GB and expand the / partition (which will be aproximately 30GB).
$ sudo virt-resize --resize /dev/sda2=+1G --expand /dev/sda1 $OLD_DISK $TMPDIR/herman_vd.qcow2
After a long output copying over the data in your existing virtual disk, the partition will be resize. Move the file to the vm's folder, and remember to update permissions (yours may differ from mine):
$ sudo mv $TMPDIR/herman_vd.qcow2 /vms/herman/ $ sudo chown libvirt-qemu.kvm /vms/herman/herman_vd.qcow2
You're almost done now. You need to update the xml config for your VM:
$ sudo virsh edit herman
and change <source file="/vms/herman/tmpkdYhWL.qcow2" /> under devices/disk to <source file="/vms/herman/herman_vd.qcow2" />
Restart the VM
After you're done, you can delete the TMPDIR and restart the VM and test if it's working
$ rmdir $TMPDIR $ sudo virsh destroy herman $ sudo virsh start herman
If all has gone well and the restart was successful, you can also safely delete the old disk image.
qcow2 imajini mount etmek
imaj hakkında bilgi edinelim. $ qemu-img info image.qcow2 modülü ekleyelim. $ modprobe nbd max_part=16 imajı nbd sürücüsüne bağlayalım. $ qemu-nbd -c /dev/nbd0 image.qcow2 nbd sürücüsü üzerindeki partitionlara bakalım. $ fdisk /dev/nbd0 istediğimiz partitionu mount edelim. $ mount /dev/nbd0p1 /mnt/image Şimdi ise bağladığımız imajı bırakalım. $ umount /mnt/image $ qemu-nbd -d /dev/nbd0 Bu kadar :)