kvm-开启虚机console 链接
记录一个工作中的发现, 在通过kvm 起来虚机后无法通过virsh console 登录,会卡住进不了系统里面,然后在虚机里启动了serial-getty@ttyS0.service 服务后发现kvm 虚机可以被console 连接了,随后将此服务设置为开机自启。再次记录一下此文问题。
怎么登录这个kvm虚机里 去做启动设置? 我这边能想到有以下的方法:
1. 通过virt-manager 图形化管理界面进入kvm虚机做设置
2.如果此虚机网络是正常的,可以通过同一网段的kvm 虚机ssh 登录
3. 可以通过guestmount 命令动态编辑qcow2 镜像, 将启动命令写在开机启动项中。
[root@localhost ]# systemctl start serial-getty@ttyS0.service
[root@localhost ]# systemctl status serial-getty@ttyS0.service
● serial-getty@ttyS0.service - Serial Getty on ttyS0
Loaded: loaded (/usr/lib/systemd/system/serial-getty@.service; disabled; vendor preset: disabled)
Active: active (running) since Thu 2021-10-21 22:03:41 EDT; 6s ago
Docs: man:agetty(8)
man:systemd-getty-generator(8)
http://0pointer.de/blog/projects/serial-console.html
Main PID: 2130 (agetty)
CGroup: /system.slice/system-serial\x2dgetty.slice/serial-getty@ttyS0.service
└─2130 /sbin/agetty --keep-baud 115200 38400 9600 ttyS0 vt220
Oct 21 22:03:41 localhost.localdomain systemd[1]: Started Serial Getty on ttyS0.
Oct 21 22:03:41 localhost.localdomain systemd[1]: Starting Serial Getty on ttyS0...
[root@localhost ]# systemctl enable serial-getty@ttyS0.service
Created symlink from /etc/systemd/system/getty.target.wants/serial-getty@ttyS0.service to /usr/lib/systemd/system/serial-get