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