{"id":1785,"date":"2018-10-27T03:47:23","date_gmt":"2018-10-27T03:47:23","guid":{"rendered":"https:\/\/www.appservgrid.com\/paw92\/?p=1785"},"modified":"2018-10-27T03:59:40","modified_gmt":"2018-10-27T03:59:40","slug":"virsh-console-kvm-access-on-centos-7","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2018\/10\/27\/virsh-console-kvm-access-on-centos-7\/","title":{"rendered":"Virsh Console KVM Access On CentOS 7"},"content":{"rendered":"<p>By default Kernel-Based Virtual Machines(<a href=\"https:\/\/linuxadmin.io\/install-configure-kvm-on-centos\/\">KVM<\/a>) are not set up to access a serial console on the host using virsh. To enable a serial virsh console, so you can view text-based output on the host machine from the virtual machine you will need to make modifications to both the virtual machine and the physical machine. Enabling serial console access can be beneficial when troubleshooting boot issues or accessing the virtual machine if networking is not working correctly at that time. You can read more about virsh commands on redhat\u2019s <a href=\"https:\/\/access.redhat.com\/documentation\/en-us\/red_hat_enterprise_linux\/5\/html\/virtualization\/chap-virtualization-managing_guests_with_virsh\">website<\/a>.<\/p>\n<h2>Enable VIRSH Console on the Virtual Machine<\/h2>\n<p>First, log in to the virtual machine and edit \/etc\/default\/grub and change this line from:<\/p>\n<p>GRUB_CMDLINE_LINUX=&#8221;crashkernel=auto rd.lvm.lv=centos\/root rd.lvm.lv=centos\/swap rhgb quiet&#8221;<\/p>\n<p>To<\/p>\n<p>GRUB_CMDLINE_LINUX=&#8221;crashkernel=auto rd.lvm.lv=centos\/root rd.lvm.lv=centos\/swap rhgb quiet console=ttyS0&#8243;<\/p>\n<p>If you want to see the output of boot messages you can also remove \u201c<em>rhgb quiet<\/em>\u201d from the console line as well. Save the file then remake the grub config<\/p>\n<p>grub2-mkconfig -o \/boot\/grub2\/grub.cfg<\/p>\n<h2>Enable Serial Console Access on the KVM host<\/h2>\n<p>Now you will need to login to the host machine to edit the xml file relating to that virtual machine<br \/>\nvirsh edit<br \/>\nReplacing vm-name with the correct virtual machine name.<\/p>\n<p>Once you are in the configuration you will need to change<\/p>\n<p>&lt;console type=&#8217;pty&#8217;&gt;<br \/>\n&lt;target type=&#8217;serial&#8217; port=&#8217;0&#8217;\/&gt;<br \/>\n&lt;\/console&gt;<\/p>\n<p>To<\/p>\n<p>&lt;console type=&#8217;pty&#8217; tty=&#8217;\/dev\/pts\/6&#8242;&gt;<br \/>\n&lt;source path=&#8217;\/dev\/pts\/6&#8217;\/&gt;<br \/>\n&lt;target type=&#8217;serial&#8217; port=&#8217;0&#8217;\/&gt;<br \/>\n&lt;alias name=&#8217;serial0&#8217;\/&gt;<br \/>\n&lt;\/console&gt;<\/p>\n<p>Then you can go ahead and save that file, by default it uses vi, so to save type<\/p>\n<p>:wq<\/p>\n<p>Then go ahead shut down the VM<\/p>\n<p>virsh shutdown &lt;vm-name&gt;<\/p>\n<p>Then recreate it<\/p>\n<p>virsh start &lt;vm-name&gt;<\/p>\n<h2>Access The KVM Through the Console<\/h2>\n<p>You should now be able to attach a console to the virtual machine by typing<\/p>\n<p>virsh console &lt;vm-name&gt;<\/p>\n<p>To exit out of a virsh console you will need to press ctrl + ] at the same time and that will break out of the console session.<\/p>\n<p><a href=\"https:\/\/linuxadmin.io\/enable-virsh-console-kvm\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>By default Kernel-Based Virtual Machines(KVM) are not set up to access a serial console on the host using virsh. To enable a serial virsh console, so you can view text-based output on the host machine from the virtual machine you will need to make modifications to both the virtual machine and the physical machine. Enabling &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2018\/10\/27\/virsh-console-kvm-access-on-centos-7\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Virsh Console KVM Access On CentOS 7&#8221;<\/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":[1],"tags":[],"class_list":["post-1785","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/1785","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=1785"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/1785\/revisions"}],"predecessor-version":[{"id":1803,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/1785\/revisions\/1803"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=1785"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=1785"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=1785"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}