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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM