Is there a way to get GRUB2 and the kernel to run a "serial" console under KVM? I'm running a Fedora 20 desktop, with libvirt-managed VMs. When I run a CentOS 6 VM, I can set both the boot loader and kernel up to use ttyS0 and get a console compatible with "virsh console". When I try the same with a CentOS 7 VM, it doesn't work. If I set it to ttyS0, I just don't get anything. I read that I should use hvc0 instead (no idea how to set the boot loader to use that); when I set that on the kernel command line, the kernel crashes during boot with: kernel tried to execute NX-protected page - exploit attempt? (uid: 0) BUG: unable to handle kernel paging request at ffffffff81a4cfec IP: [<ffffffff81a4cfec>] vty_init+0x174/0x174 PGD 18d3067 PUD 18d4063 PMD 3d9e1063 PTE 8000000001a4c163 If I don't do either, I can add a getty on hvc0 with "systemctl enable serial-getty at hvc0.service", but that doesn't get me the boot loader or kernel messages. -- Chris Adams <linux at cmadams.net>
For my templates I use: grubby --update-kernel=ALL --args="crashkernel=0 at 0 video=1024x768 console=ttyS0,115200n8 console=tty0 consoleblank=0" HTH -- Sent from the Delta quadrant using Borg technology! Nux! www.nux.ro ----- Original Message -----> From: "Chris Adams" <linux at cmadams.net> > To: centos at centos.org > Sent: Wednesday, 8 October, 2014 17:06:03 > Subject: [CentOS] CentOS 7 kernel console under KVM?> Is there a way to get GRUB2 and the kernel to run a "serial" console > under KVM? > > I'm running a Fedora 20 desktop, with libvirt-managed VMs. When I run a > CentOS 6 VM, I can set both the boot loader and kernel up to use ttyS0 > and get a console compatible with "virsh console". > > When I try the same with a CentOS 7 VM, it doesn't work. If I set it to > ttyS0, I just don't get anything. I read that I should use hvc0 > instead (no idea how to set the boot loader to use that); when I set > that on the kernel command line, the kernel crashes during boot with: > > kernel tried to execute NX-protected page - exploit attempt? (uid: 0) > BUG: unable to handle kernel paging request at ffffffff81a4cfec > IP: [<ffffffff81a4cfec>] vty_init+0x174/0x174 > PGD 18d3067 PUD 18d4063 PMD 3d9e1063 PTE 8000000001a4c163 > > If I don't do either, I can add a getty on hvc0 with "systemctl enable > serial-getty at hvc0.service", but that doesn't get me the boot loader or > kernel messages. > -- > Chris Adams <linux at cmadams.net> > _______________________________________________ > CentOS mailing list > CentOS at centos.org > http://lists.centos.org/mailman/listinfo/centos
On Wed, 8 Oct 2014, Chris Adams wrote:> Is there a way to get GRUB2 and the kernel to run a "serial" console > under KVM? ><snip> This worked for me. Add the following three lines to /etc/default/grub: GRUB_CMDLINE_LINUX='console=tty0 console=ttyS0,115200n8' GRUB_TERMINAL=serial GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1" Then re-generate grub.cfg: grub2-mkconfig -o /boot/grub2/grub.cfg Taken from: https://fedoraproject.org/wiki/GRUB_2?rd=Grub2 (near the bottom of the page)
Once upon a time, Chris Adams <linux at cmadams.net> said:> Is there a way to get GRUB2 and the kernel to run a "serial" console > under KVM?So, I guess the people who replied didn't read - I tried ttyS0, and that didn't work. I did figure out why that doesn't work: when setting up a new VM with libvirt in F20, if you choose RHEL7 as the guest OS, it gets set up differently than RHEL6. One difference is that it sets up a virtio console, instead of a serial console. First, it doesn't look like GRUB2 can talk to a virtio console. Second, I guess I'm hitting a kernel bug, because the kernel should be able to talk to a virtio console (i.e. hvc0). It certainly shouldn't crash because I tried to use that. The device works after boot (I can run a getty on it), it seems only the kernel can't talk to it directly as a console. -- Chris Adams <linux at cmadams.net>