黑帽联盟

 找回密码
 会员注册
查看: 191|回复: 0

[资源教程] 解决virsh console不能操作虚机方法

[复制链接]

302

主题

18

听众

1018

积分

管理员

Rank: 9Rank: 9Rank: 9

  • TA的每日心情

    4 天前
  • 签到天数: 414 天

    [LV.9]以坛为家II

    步骤1、登录虚机

    步骤2、配置 GRUB 添加串口支持
    1. # 编辑 GRUB 配置文件
    2. vim /etc/default/grub
    复制代码

    找到 GRUB_CMDLINE_LINUX 这一行,在引号内添加:
    1. console=ttyS0,115200 console=tty0
    复制代码

    修改后示例:
    1. GRUB_CMDLINE_LINUX="crashkernel=auto rhgb quiet console=ttyS0,115200 console=tty0"
    复制代码

    保存退出后,重新生成 GRUB 配置:
    1. # CentOS 7/RHEL 7
    2. grub2-mkconfig -o /boot/grub2/grub.cfg

    3. # CentOS 6/RHEL 6
    4. grub-mkconfig -o /boot/grub/grub.cfg

    5. # Ubuntu/Debian
    6. update-grub
    复制代码

    步骤3:启用串口登录服务bash
    1. # 启动 serial-getty 服务(ttyS0)
    2. systemctl enable serial-getty@ttyS0
    3. systemctl start serial-getty@ttyS0

    4. # 查看服务状态
    5. systemctl status serial-getty@ttyS0
    复制代码

    步骤4:检查并确认配置bash
    1. # 查看是否有 ttyS0 设备
    2. ls -l /dev/ttyS0

    3. # 查看服务是否监听
    4. ps aux | grep ttyS0

    5. # 查看启动日志
    6. dmesg | grep ttyS0
    复制代码
    步骤5:在宿主机测试
    # 立即连接
    virsh console centos7.0
    # 按回车键


    应该能直接看到登录提示:
    1. CentOS Linux 7 (Core)
    2. Kernel 3.10.0-1160.el7.x86_64 on an x86_64

    3. localhost login:
    复制代码


    您需要登录后才可以回帖 登录 | 会员注册

    发布主题 !fastreply! 收藏帖子 返回列表 搜索
    回顶部