virsh console进入CentOS 7虚拟机卡住不动

一、查看目前kvm虚拟机情况
[root@localhost ~]# virsh list
Id 名称 状态
----------------------------------------------------
2 centos7 running
 
 
二、尝试用console登陆
 
[root@localhost ~]# virsh list
Id 名称 状态
----------------------------------------------------
2 centos7 running
 
[root@localhost ~]# virsh console centos7
连接到域 centos7
换码符为 ^]
 
三、在以上的符号停住了,在百度查下资料,得知以下操作:
1 cat /etc/securetty
[root@localhost ~]# cat /etc/securetty
console
vc/1
vc/2
vc/3
vc/4
vc/5
vc/6
vc/7
vc/8
vc/9
vc/10
vc/11
tty1
tty2
tty3
tty4
tty5
tty6
tty7
tty8
tty9
tty10
tty11
ttyS0
ttysclp0
sclp_line0
3270/tty1
hvc0
hvc1
hvc2
hvc3
hvc4
hvc5
hvc6
hvc7
hvsi0
hvsi1
hvsi2
xvc0
2 进入虚机中,编辑 /etc/default/grub 文件,找到下面行:
 
GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=cl/root rd.lvm.lv=cl/swap rhgb quiet”
 
改为:(尾部增加 console=ttyS0,115200)
 
GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet net.ifnames=0 console=ttyS0,115200"
 
3 运行grub2-mkconfig -o /boot/grub2/grub.cfg 来重新生成GRUB配置并更新内核参数
 
[root@localhost ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-862.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-862.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-f9c7d514f50a42eb8a941b70609346ed
Found initrd image: /boot/initramfs-0-rescue-f9c7d514f50a42eb8a941b70609346ed.img
done
 
4 使用以下命令激活 服务 (这个是centos7才有的服务,但默认没有启动)
 
sudo systemctl start serial-getty@ttyS0.service
sudo systemctl enable serial-getty@ttyS0.service
原文地址:https://www.cnblogs.com/cloud-datacenter/p/13326223.html