{"id":1847,"date":"2015-05-24T19:03:15","date_gmt":"2015-05-24T13:03:15","guid":{"rendered":"http:\/\/notes.norfolks.org\/?p=1847"},"modified":"2016-09-16T20:10:16","modified_gmt":"2016-09-16T14:10:16","slug":"kvm-help","status":"publish","type":"post","link":"https:\/\/notes.norfolks.fun\/?p=1847","title":{"rendered":"KVM help"},"content":{"rendered":"<p><strong>\u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 (\u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u044f) \u043e\u0431\u0440\u0430\u0437\u0430 \u0436\u0435\u0441\u0442\u043a\u043e\u0433\u043e \u0434\u0438\u0441\u043a\u0430 \u0438\u0437 RAW \u0432 QCOW2<\/strong><\/p>\n<pre lang=\"sh\">qemu-img convert -f raw -O qcow2 \/home\/libvirt\/images\/rhel01.img \/home\/libvirt\/images\/rhel01.qcow2<\/pre>\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u043f\u0440\u0430\u0432 \u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f:<\/p>\n<pre lang=\"sh\">$ chmod 600 \/home\/libvirt\/images\/rhel01.qcow2\r\n$ chown qemu.qemu \/home\/libvirt\/images\/rhel01.qcow2<\/pre>\n<p>\u0413\u0440\u0443\u043f\u043f\u0443 \u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u0436\u0435 \u043a\u0430\u043a \u0443 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u043e\u0431\u0440\u0430\u0437\u043e\u0432.<br \/>\n\u0427\u0442\u043e\u0431\u044b \u0441\u0436\u0430\u0442\u044c \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e\u0435 \u043c\u0435\u0441\u0442\u043e \u0432\u043d\u0443\u0442\u0440\u044c \u043e\u0431\u0440\u0430\u0437\u0430 \u0434\u0438\u0441\u043a\u0430, \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <strong>qemu-img convert<\/strong> \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c -\u0441<\/p>\n<pre lang=\"sh\">qemu-img convert -c -O qcow2 source.qcow2 target.qcow2<\/pre>\n<p><a href=\"http:\/\/www.itdesignhouse.com\/convert-kvm-virtual-machine-raw-qcow2-format\/\">\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a<\/a><\/p>\n<p><strong>\u0410\u0432\u0442\u043e\u0437\u0430\u043f\u0443\u0441\u043a VM<\/strong><\/p>\n<pre lang=\"sh\">$ virsh autostart vmName<\/pre>\n<p><strong>\u0421\u043f\u0438\u0441\u043e\u043a VM<\/strong><\/p>\n<pre lang=\"sh\">$ virsh list --all<\/pre>\n<p>\u041f\u0435\u0440\u0435\u0447\u0438\u0442\u0430\u0442\u044c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e \u0412\u041c \u043f\u043e\u0441\u043b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f<\/p>\n<p>If you have made a change to the XML configuration file, you need to tell KVM to reload it before restarting the VM:<\/p>\n<pre lang=\"sh\">virsh # define \/etc\/libvirt\/qemu\/mirror.xml\r\nDomain mirror defined from \/etc\/libvirt\/qemu\/mirror.xml<\/pre>\n<p>-= <a href=\"http:\/\/linuxguru.ru\/virtualization\/kvm\/ustanovka-virtualizacii-kvm-v-debian-squeeze\/\">\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430<\/a> =-<\/p>\n<p><a href=\"http:\/\/furalol.blogspot.ru\/2012\/08\/kvm-kvm.html\">\u041e \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u0434\u0438\u0441\u043a\u0430\u0445 KVM<\/a><\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0434\u0438\u0441\u043a\u0430:<\/p>\n<pre lang=\"virtsh\"># qemu-img create -f qcow2 \/var\/lib\/libvirt\/images\/guest.qcow2 8192M<\/pre>\n<p>\u041a\u043e\u043c\u0430\u043d\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u043a\u0430\u0436\u0435\u0442 \u043d\u043e\u043c\u0435\u0440 VNC \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0434\u043b\u044f \u043d\u0443\u0436\u043d\u043e\u0439 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u044b:<\/p>\n<pre lang=\"virtsh\"># virsh vncdisplay srv2\r\n:0<\/pre>\n<p>\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0412\u041c \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u044b:<\/p>\n<pre lang=\"virtsh\"># virsh undefine vm1<\/pre>\n<p>\u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a VM:<\/p>\n<pre lang=\"virtsh\"># virsh edit vm-name<\/pre>\n<p>\u0412 \u043e\u0442\u043a\u0440\u044b\u0432\u0448\u0435\u043c\u0441\u044f \u0444\u0430\u0439\u043b\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c:<br \/>\n\u0412 \u0441\u0435\u043a\u0446\u0438\u0438 graphics<br \/>\n<code><br \/>\ntype='vnc' port='-1' autoport='yes' listen='0.0.0.0' passwd='12345'<br \/>\n<\/code><br \/>\n, \u0433\u0434\u0435 <em>listen <\/em>&#8212; ip-\u0430\u0434\u0440\u0435\u0441 \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a vm \u043f\u043e vnc (\u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u043e\u043c\u0435\u0440 \u043f\u043e\u0440\u0442\u0430 590x)<br \/>\n<em>passwd <\/em>&#8212; \u043f\u0430\u0440\u043e\u043b\u044c \u0434\u043b\u044f vnc<\/p>\n<p>\u0412\u044b\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0437\u0430\u0433\u0440\u0443\u0437\u043e\u0447\u043d\u043e\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e:<\/p>\n<pre lang=\"virtsh\"><\/pre>\n<p><a href=\"http:\/\/itman.in\/kvm-vnc-access\/\" title=\"\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a\">\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a<\/a><\/p>\n<p><strong>\u041f\u0440\u0438\u043d\u0443\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 VM<\/strong><\/p>\n<pre lang=\"virtsh\"># virsh destroy VM01<\/pre>\n<p><a href=\"http:\/\/linux-notes.org\/kak-zapustit-vy-klyuchit-perezagruzit-gostevy-e-operatsionny-e-sistemy-s-virsh-na-kvm\/\" title=\"\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a\">\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a<\/a><\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0442\u044c VM:<\/p>\n<pre lang=\"virtsh\">virt-install -n vm1 -r 512 -f \/kvm\/vm1.qcow2 -s 1 -c \/kvm\/debian-live-6.0.3-amd64-kde-desktop.iso --accelerate --os-type=linux --os-variant=generic26 -v --vnc -w bridge:kvmbr0<\/pre>\n<p><a href=\"http:\/\/thomasmullaly.com\/2014\/11\/16\/the-list-of-os-variants-in-kvm\/\">OS variant list<\/a><\/p>\n<p><strong>\u041c\u043e\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0438\u0441\u043a\u0430 \u0432 cdrom:<\/strong><\/p>\n<pre lang=\"virtsh\">virsh # attach-disk VM \/path\/to\/your.iso hdc --type cdrom --mode readonly<\/pre>\n<p>, \u0432\u043c\u0435\u0441\u0442\u043e <strong>hdc<\/strong> \u0441\u0442\u0430\u0432\u0438\u043c \u0438\u043c\u044f \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430, \u0432\u0437\u044f\u0442\u043e\u0433\u043e \u0438\u0437 \u043a\u043e\u043d\u0444\u0438\u0433\u0430 \u0412\u041c<br \/>\n<a href=\"http:\/\/opensysblog.directorioc.net\/2012\/06\/mounting-and-umounting-cd-rom-iso-in.html\">\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a<\/a><\/p>\n<p>\u0423\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440 \u0434\u0438\u0441\u043a\u0430:<\/p>\n<pre lang=\"virtsh\">qemu-img resize vm.qcow2 +5GB<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 (\u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u044f) \u043e\u0431\u0440\u0430\u0437\u0430 \u0436\u0435\u0441\u0442\u043a\u043e\u0433\u043e \u0434\u0438\u0441\u043a\u0430 \u0438\u0437 RAW \u0432 QCOW2 qemu-img convert -f raw -O qcow2 \/home\/libvirt\/images\/rhel01.img \/home\/libvirt\/images\/rhel01.qcow2 \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u043f\u0440\u0430\u0432 \u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f: $ chmod 600 \/home\/libvirt\/images\/rhel01.qcow2 $ chown qemu.qemu \/home\/libvirt\/images\/rhel01.qcow2 \u0413\u0440\u0443\u043f\u043f\u0443 \u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u0436\u0435 \u043a\u0430\u043a \u0443 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u043e\u0431\u0440\u0430\u0437\u043e\u0432. \u0427\u0442\u043e\u0431\u044b &hellip; <a href=\"https:\/\/notes.norfolks.fun\/?p=1847\">\u0427\u0438\u0442\u0430\u0442\u044c \u0434\u0430\u043b\u0435\u0435 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[44,14],"tags":[],"class_list":["post-1847","post","type-post","status-publish","format-standard","hentry","category-kvm","category-linux"],"_links":{"self":[{"href":"https:\/\/notes.norfolks.fun\/index.php?rest_route=\/wp\/v2\/posts\/1847","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/notes.norfolks.fun\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/notes.norfolks.fun\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/notes.norfolks.fun\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/notes.norfolks.fun\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1847"}],"version-history":[{"count":21,"href":"https:\/\/notes.norfolks.fun\/index.php?rest_route=\/wp\/v2\/posts\/1847\/revisions"}],"predecessor-version":[{"id":2034,"href":"https:\/\/notes.norfolks.fun\/index.php?rest_route=\/wp\/v2\/posts\/1847\/revisions\/2034"}],"wp:attachment":[{"href":"https:\/\/notes.norfolks.fun\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1847"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/notes.norfolks.fun\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1847"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/notes.norfolks.fun\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1847"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}