1. CentOS6系统

在KVM中安装了一个RHEL6.1,启动virsh命令想通过console命令连接至客户机的终端,结果输入命令后终端卡在这个状态:

virsh # console test
Connected to domain test
Escape character is ^]

原来想通过console连接客户机终端还要在客户机上做相应设置,大致如下: 添加ttyS0:

echo “ttyS0″ >> /etc/securetty

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

console=tty0 console=ttyS0,115200

在/etc/inittab中添加agetty:

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

重启客户机:

reboot

此时,再次尝试console命令可以正常使用:

#virsh  console test
Connected to domain test
Escape character is ^]
Red Hat Enterprise Linux Server release 6.1 (Santiago)
Kernel 2.6.32-131.0.15.el6.x86_64 on an x86_64

2. CentOS7

对于centos 7 系统的虚拟机,就比较简单了。 With KVM, to access the virtual machine’s console under X Window, type:


virt-manager

If you aren’t under X Window, there is another way to access a virtual machine’s console: you can go through a serial console.

On the virtual machine, add ‘console=ttyS0‘ at the end of the kernel lines in the /boot/grub2/grub.cfg file:

grubby --update-kernel=ALL --args="console=ttyS0"

Note: Alternatively, you can edit the /etc/default/grub file, add ‘console=ttyS0‘ to the GRUB_CMDLINE_LINUX variable


[root@localhost ~]# cat /etc/default/grub |grep tty

GRUB_CMDLINE_LINUX="crashkernel=auto rhgb quiet console=ttyS0"

then execute


grub2-mkconfig -o /boot/grub2/grub.cfg‘

Now, reboot the virtual machine:


reboot

3. 退出

退出时使用

Ctrl+]
Copyright © 温玉 2021 | 浙ICP备2020032454号 all right reserved,powered by Gitbook该文件修订时间: 2023-06-19 08:59:50

results matching ""

    No results matching ""