一.问题描述:

KVM中宿主机通过console无法连接客户机,卡在这里不动了。

# virsh console vm01

Connected to domain vm01

Escape character is ^]

为KVM客户机添加virsh console支持  http://www.linuxidc.com/Linux/2013-02/79556.htm

二、解决办法:利用vnc或宿主机的桌面进入客户机vm01中添加参数

1、添加ttyS0的安全许可,允许root登录:

# echo "ttyS0" >> /etc/securetty

2、在/etc/grub.conf文件中为内核添加参数:

console=ttyS0

这步要注意:

console=ttyS0一定要放在kernel这行中(大约在第16行),不能单独一行,即console=ttyS0是kernel的一个参数,不是单独的,如下(往右拉进度条,在最后):

# cat -n /etc/grub.conf

  # grub.conf generated by anaconda

 #

 # Note that you do not have to rerun grub after making changes to this file

 # NOTICE:  You have a /boot partition.  This means that

 #          all kernel and initrd paths are relative to /boot/, eg.

 #          root (hd0,0)

 #          kernel /vmlinuz-version ro root=/dev/mapper/VolGroup-lv_root

 #          initrd /initrd-[generic-]version.img

 #boot=/dev/vda

  default=0

  timeout=5

  splashimage=(hd0,0)/grub/splash.xpm.gz

  hiddenmenu

  title Red Hat Enterprise Linux (2.6.32-431.el6.x86_64)

      root (hd0,0)

      kernel /vmlinuz-2.6.32-431.el6.x86_64 ro root=/dev/mapper/VolGroup-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD rd_LVM_LV=VolGroup/lv_swap SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_LVM_LV=VolGroup/lv_root  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet console=ttyS0

      initrd /initramfs-2.6.32-431.el6.x86_64.img


3、在/etc/inittab中添加agetty:

S0:12345:respawn:/sbin/agetty ttyS0 115200

4、重启客户机:

# reboot

三、问题解决

# virsh console vm01

Connected to domain vm01

Escape character is ^]

Red Hat Enterprise Linux Server release 6.5 (Santiago)

Kernel 2.6.32-431.el6.x86_64 on an x86_64

 

vm01 login: root

Password:

Last login: Sun Oct 12 00:11:47 on tty1

[root@vm01 ~