{"id":95,"date":"2011-05-16T19:17:57","date_gmt":"2011-05-16T18:17:57","guid":{"rendered":"http:\/\/frosteyes.dk\/?p=95"},"modified":"2013-05-06T06:54:45","modified_gmt":"2013-05-06T05:54:45","slug":"using-kvm-from-commandline-without-vlc","status":"publish","type":"post","link":"http:\/\/www.frosteyes.dk\/index.php\/linux\/using-kvm-from-commandline-without-vlc","title":{"rendered":"Using KVM from commandline without vnc"},"content":{"rendered":"<p>As part of a major server upgrade, I have changed my old Compaq DL360G1, with a single pentium III  to a Dell 2U 2950 with 2 Xeon E5420.<\/p>\n<p>As part of the upgrade I have changed my setup from 32 bit to 64 bit, from ext3 to ext4 and from XEN virtualization to KVM.<\/p>\n<p>Usually when working with KVM you use vnc. This have its pros and cons. Though, as the host server itself of cause is headless and the clients I use for administration not all have a vnc client, I was looking for a cleaner solution. The result was a way with uses screen and ncurses, so I just need a ssh access to the server for controlling everything.<\/p>\n<pre lang=\"bash\">#!\/bin\/bash\r\n\r\n# Script for using kvm virtualization from a console\r\n\r\nNAME=\"MACHINENAME\"\r\nMEMORY=\"512\"\r\nCPUS=\"1\"\r\nVM_GROUP=\"\/dev\/KvmGroup\/\"\r\nBRIDGE_SCRIPT=\"\/root\/Scripts\/qemu-ifup-brKvm.sh\"\r\n# Using the easyMAC script for a xen mac\r\nMAC_ADDRESS=\"00:50:56:27:XX:XX\"\r\n\r\n\/usr\/bin\/screen -A -m -d -S \"kvm_${NAME}\" -t \"${NAME}\" \\\r\n\/usr\/bin\/qemu-system-x86_64 \\\r\n--enable-kvm \\\r\n-m ${MEMORY} \\\r\n-name ${NAME} \\\r\n-smp ${CPUS} \\\r\n-drive file=${VM_GROUP}${NAME}_root,if=scsi,boot=on \\\r\n-drive file=${VM_GROUP}${NAME}_swap,if=scsi \\\r\n-net nic,macaddr=${MAC_ADDRESS} \\\r\n-net tap,script=${BRIDGE_SCRIPT} \\\r\n-k da \\\r\n-monitor unix:\/var\/run\/kvm\/monitors\/${NAME},server,nowait \\\r\n-pidfile \/var\/run\/kvm\/pids\/${NAME} \\\r\n-nographic \\\r\n-curses #\\\r\n#\u00a0\u00a0\u00a0 -cdrom \/root\/ISO\/install-amd64-minimal-20110421.iso \\\r\n#\u00a0\u00a0\u00a0 -boot d<\/pre>\n<p>This is a crude example for how it is used. But should give some ideas for how it is used. Notice the two commented lines. This is for booting from a iso image.<br \/>\nThe result is shown in the following figure:<\/p>\n<p><a rel=\"attachment wp-att-97\" href=\"http:\/\/frosteyes.dk\/index.php\/linux\/using-kvm-from-commandline-without-vlc\/attachment\/kvmfromconsole\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-97\" title=\"kvmFromConsole\" src=\"http:\/\/frosteyes.dk\/wp-content\/uploads\/2011\/05\/kvmFromConsole-300x209.png\" alt=\"\" width=\"300\" height=\"209\" srcset=\"http:\/\/www.frosteyes.dk\/wp-content\/uploads\/2011\/05\/kvmFromConsole-300x209.png 300w, http:\/\/www.frosteyes.dk\/wp-content\/uploads\/2011\/05\/kvmFromConsole.png 665w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>As part of a major server upgrade, I have changed my old Compaq DL360G1, with a single pentium III to a Dell 2U 2950 with 2 Xeon E5420. As part of the upgrade I have changed my setup from 32 bit to 64 bit, from ext3 to ext4 and from XEN virtualization to KVM. Usually &hellip; <a href=\"http:\/\/www.frosteyes.dk\/index.php\/linux\/using-kvm-from-commandline-without-vlc\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Using KVM from commandline without vnc<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-95","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"http:\/\/www.frosteyes.dk\/index.php\/wp-json\/wp\/v2\/posts\/95","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.frosteyes.dk\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.frosteyes.dk\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.frosteyes.dk\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.frosteyes.dk\/index.php\/wp-json\/wp\/v2\/comments?post=95"}],"version-history":[{"count":18,"href":"http:\/\/www.frosteyes.dk\/index.php\/wp-json\/wp\/v2\/posts\/95\/revisions"}],"predecessor-version":[{"id":228,"href":"http:\/\/www.frosteyes.dk\/index.php\/wp-json\/wp\/v2\/posts\/95\/revisions\/228"}],"wp:attachment":[{"href":"http:\/\/www.frosteyes.dk\/index.php\/wp-json\/wp\/v2\/media?parent=95"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.frosteyes.dk\/index.php\/wp-json\/wp\/v2\/categories?post=95"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.frosteyes.dk\/index.php\/wp-json\/wp\/v2\/tags?post=95"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}