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
相關文章
相關標籤/搜索