KVM console FreeBSD/CentOS/Ubuntu

KVM console FreeBSD/CentOS/Ubuntu


*******************
FreeBSD
*******************

https://docs.openstack.org/image-guide/freebsd-image.html
以FreeBSD10.0为例:

登录FreeBSD Guest后
1.添加或编辑/boot/loader.conf
root@FreeBSD# echo 'console="comconsole,vidconsole"' >> /boot/loader.conf

2.在/etc/ttys文件末尾追加一行ttyu0
root@FreeBSD# echo 'ttyu0   "/usr/libexec/getty std.9600"   vt100   on secure' >>/etc/ttys

3.重启FreeBSD
root@FreeBSD# reboot



*******************
CentOS/RHEL
*******************

https://docs.openstack.org/image-guide/centos-image.html#configure-console
以CentOS6.5为例:

登录CentOS Guest后
1.在/etc/securetty文件末尾追加一行ttyS0
root@CentOS# echo “ttyS0″ >> /etc/securetty

2.在/boot/grub/grub.conf文件里的kernel一行增加console=tty0 console=ttyS0,115200n8
root@CentOS# vim /boot/grub/grub.conf
...
title CentOS (2.6.32-431.el6.x86_64)
        root (hd0,0)
        kernel /vmlinuz-2.6.32-431.el6.x86_64 ro root=/dev/mapper/vg0-root rd_NO_LUKS LANG=en_US.UTF-8 rd_LVM_LV=vg0/swap crashkernel=auto rd_NO_MD SYSFONT=latarcyrheb-sun16 rd_NO_DM  KEYBOARDTYPE=pc KEYTABLE=us rd_LVM_LV=vg0/root  console=tty0 console=ttyS0
        initrd /initramfs-2.6.32-431.el6.x86_64.img

...

3.在/etc/inittab中增加一行ttyS0(可选)
root@CentOS# vim /etc/inittab
...
S0:12345:respawn:/sbin/agetty ttyS0 115200

4.重启CentOS
root@CentOS# reboot


*******************
Ubuntu/Debian
*******************

https://docs.openstack.org/image-guide/ubuntu-image.html
说明:
Debian和Ubuntu配置方法一致,本人实测Ubuntu14.04和Debian8虚拟机都能通过KVM console正常访问。
以Ubuntu14.04为例:

登录Ubuntu Guest后
1.增加/etc/init/ttyS0.conf文件及内容
root@Ubuntu# vim /etc/init/ttyS0.conf
# ttyS0 - getty
#
# This service maintains a getty on ttyS0 from the point the system is
# started until it is shut down again.
start on stopped rc RUNLEVEL=[2345]
stop on runlevel [!2345]
respawn
exec /sbin/getty -L 38400 ttyS0 vt102

注意:这样只能看到Ubuntu login后的终端,不能看到启动过程,希望看到Ubuntu的启动过程,还得如下操作

2.在/etc/default/grub加入或修改GRUB_CMDLINE_LINUX
说明:Ubuntu很早就开始启用grub2了,所以修改方式和grub有所不同
/etc/default/grub ---> /boot/grub/grub.cfg
如果功力够高也可以直接修改/boot/grub/grub.cfg噢!
root@Ubuntu# vim /etc/default/grub
...
GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0"
...
root@Ubuntu# mv /boot/grub/grub.cfg{,.bak}
root@Ubuntu# grub-mkconfig >/boot/grub/grub.cfg

3.重启Ubuntu
root@Ubuntu# reboot
原文地址:https://www.cnblogs.com/lixuebin/p/10814434.html