Kvm virsh console on centos 7
wordpress meta
title: 'KVM virsh console on CentOS 7'
date: '2014-10-29T08:20:02-05:00'
status: publish
permalink: /kvm-virsh-console-on-centos-7
author: admin
excerpt: ''
type: post
id: 760
category:
- KVM
tag: []
post_format: []
title: 'KVM virsh console on CentOS 7'
date: '2014-10-29T08:20:02-05:00'
status: publish
permalink: /kvm-virsh-console-on-centos-7
author: admin
excerpt: ''
type: post
id: 760
category:
- KVM
tag: []
post_format: []
Several articles on using the console feature of KVM guests exists already. This is just a quick note on a test I did using specifically Centos 7 which is using systemd now.
Console allows you to A) see bootup messages and B) login on the console of the guest without SSH.
As far as I can tell you only need to do two things. Add console=ttyS0 to the kernel being booted and in the guest XML switch virtio to serial for the console. Keep in mind this is if you are using the RHEL 7 type when creating the VM. If you were using a RHEL 6 type when creating the guest the console probably still were configured to use serial.
This KVM hypervisor is on Fedora 20 and using libvirt version 1.1.3.6.
To send messages from the kernel to the serial console add console=ttyS0:
# grep console=ttyS0 /boot/grub2/grub.cfg
linux16 /vmlinuz-3.10.0-123.el7.x86_64 root=UUID=ba0f2424-e66e-4862-90ff-7dccb63339c2 ro rd.lvm.lv=centos/swap vconsole.font=latarcyrheb-sun16 rd.lvm.lv=centos/root crashkernel=auto vconsole.keymap=us LANG=en_US.UTF-8 console=ttyS0
# grep ttyS0 /etc/securetty
ttyS0
Change guest console type to serial:
<console type='pty' tty='/dev/pts/6'>
<source path='/dev/pts/6'/>
<target type='serial' port='0'/>
<alias name='serial0'/>
</console>
# virsh console centos7
Connected to domain centos7
CentOS Linux 7 (Core)
Kernel 3.10.0-123.el7.x86_64 on an x86_64
localhost login:
Above should do it but if you want to see even the grub2 menu options you can try the following:
# grep serial /etc/default/grub
GRUB_TERMINAL=serial
GRUB_SERIAL_COMMAND="serial --speed=38400 --unit=0 --word=8 --parity=no --stop=1"
# grep LINUX_DEFAULT /etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0"
# grub2-mkconfig -o /boot/grub2/grub.cfg
Of course if you are setting grub DEFAULT options you don't need to set anything for the kernel entries in /boot/grub2/grub.cfg like I did in step 1.
Note that when connecting to the console you might need to move your up or down arrows to see the actual menu entries. The terminal and curses might look a little flaky but it is there. I also set the grub TIMEOUT a little longer to wait at the menu entries.