Kvm之四:console连接vm

Centos7 Kvm console连接

1、console方式连接vm,默认不支持,需要调整配置
#需要修改vm的配置
[root@node71 vm]# virsh console oel1
连接到域 oel1
换码符为 ^]

#默认是连接不了oel1的console
[root@localhost ~]# echo "ttyS0" >> /etc/securetty
[root@localhost ~]# grep "ttyS0" /etc/securetty 
ttyS0
[root@localhost ~]# 
#在grub配置文件中添加传递内核参数console=ttyS0
#注意oel版本的linux存在两个不同版本的内核
[root@localhost ~]# vi /boot/grub/grub.conf 
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Oracle Linux Server Unbreakable Enterprise Kernel (3.8.13-44.1.1.el6uek.x86_64)
        root (hd0,0)
        kernel /vmlinuz-3.8.13-44.1.1.el6uek.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 console=ttyS0 rhgb quiet
        initrd /initramfs-3.8.13-44.1.1.el6uek.x86_64.img
title Oracle Linux Server Red Hat Compatible Kernel (2.6.32-504.el6.x86_64)
    root (hd0,0)
    kernel /vmlinuz-2.6.32-504.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
    initrd /initramfs-2.6.32-504.el6.x86_64.img
#修改/etc/inittab文件
[root@localhost ~]# echo "S0:12345:respawn:/sbin/agetty ttyS0 115200" >> /etc/inittab 
[root@localhost ~]#
#重新启动虚拟机系统,连接console终端,有信息输出
[root@node71 vm]# virsh console oel1
连接到域 oel1
换码符为 ^]

 done.
[  OK  ]
Starting auditd: [  OK  ]
Starting system logger: [  OK  ]
Starting kdump:[FAILED]
Mounting filesystems:  [  OK  ]
Starting acpi daemon: [  OK  ]
Retrigger failed udev events[  OK  ]
Starting sshd: [  OK  ]
Starting postfix: [  OK  ]
Starting crond: [  OK  ]

Oracle Linux Server release 6.6
Kernel 3.8.13-44.1.1.el6uek.x86_64 on an x86_64

localhost.localdomain login: 

#切回原来kvm的ssh连接
Ctrl + [ + ] ,这样就可以切回到KVM连接

你可能感兴趣的:(Kvm之四:console连接vm)