• Home
  • About Us
  • Contact
  • Privacy Policy

LinuxAdmin.io

  • Home
  • Tutorials
    • System Administration
    • Linux Tutorials
    • Web Hosting
    • WordPress
    • Virtualization
    • Troubleshooting
    • OpenStack

KVM Virsh Console Access on CentOS 7

Virsh Console Access

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 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’s website.

Enable VIRSH Console on the Virtual Machine

First, log in to the virtual machine and edit /etc/default/grub and change this line from:

GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet"

To

GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet console=ttyS0"

If you want to see the output of boot messages you can also remove “rhgb quiet” from the console line as well. Save the file then remake the grub config

grub2-mkconfig -o /boot/grub2/grub.cfg

Enable Serial Console Access on the KVM host

Now you will need to login to the host machine to edit the xml file relating to that virtual machine
virsh edit
Replacing vm-name with the correct virtual machine name.

Once you are in the configuration you will need to change

 <console type='pty'> 
<target type='serial' port='0'/> 
</console>

To

<console type='pty' tty='/dev/pts/6'> 
<source path='/dev/pts/6'/> 
<target type='serial' port='0'/> 
<alias name='serial0'/> 
</console>

Then you can go ahead and save that file, by default it uses vi, so to save type

:wq

Then go ahead shut down the VM

virsh shutdown <vm-name>

Then recreate it

virsh start <vm-name>

Access The KVM Through the Console

You should now be able to attach a console to the virtual machine by typing

virsh console <vm-name>

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.

May 14, 2017LinuxAdmin.io
3 2 votes
Article Rating
Using Parted To Create A New Swap DiskHow To Use LVM To Create A New Logical Volume
You Might Also Like
 
How To Setup SSH Key Authentication
 
mod_auth_token Installation In Apache
Subscribe
Notify of
guest
guest
1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
John
John
5 years ago

Thanks for sharing your info. I really appreciate your efforts and I will be waiting for your next write ups thanks once again.

0
Reply
5 years ago 1 Comment Linux System Administration, Linux Tutorials, Virtualization centos, kvm, linux, sysadmin12,494
Recent Posts
  • Laravel Installation Guide For CentOS
  • Openstack Services Explanation And Overview
  • OSSEC Intrusion Detection Installation On Centos 7
  • Configure ProFTPd for SFTP on CentOS
  • How To Check And Repair MyISAM Tables In MySQL
Most Commented
Hot Clone Linux Server with Rsync
Hot Clone A CentOS Server With Rsync
14 Comments
ngx_cache_purge module
Install The ngx_cache_purge Module In Nginx
8 Comments
piwik-nginx
Piwik Analytics on Nginx
8 Comments
Tags
linuxcentosLinux Performance Tuningsysadminkvmnetworkingmemcachedanalyticssystemd
About

We love Linux and are dedicated to creating Linux administration tutorials for System Administrators since 2016.

Most Viewed
Default Gateway
How To Configure A Default Gateway on CentOS
63,000 views
Zend Opcache
Setup and Optimize Zend OpCache
46,714 views
Install ffmpeg
FFMpeg Install On CentOS 7
20,912 views
Archives
Email subscription

Sign up for our newsletter to receive the latest news and event postings.

2018 © LinuxAdmin.io
wpDiscuz