1、再加块硬盘,格式化挂载至新建目录/kvm2下
2、CentOS 6.8镜像地址 http://mirrors.163.com/centos/6.8/os/x86_64/
3、配置安装参数,执行安装命令:
[[email protected] ~ 16:38:47]#virt-install --name snale2 --disk path=/kvm2/snale2,size=18 --ram 1024 --vcpus 1 --os-type linux --os-variant rhel6 --network bridge=br0 --location http://mirrors.163.com/centos/6.8/os/x86_64/ --graphics none --console pty,target_type=serial --extra-args ‘console=ttyS0,115200n8 serial‘
4、退出当前虚拟机。退出虚拟控制台使用键盘上的Ctrl + ]键。
5、查看当前所有虚拟机的状态:
6、再次使用virsh 连接snale2 :
[[email protected] ~ 17:01:57]#virsh console snale2
连接到域 snale2
Escape character is^] //按回车键
7、说明:为什么使用virsh console 能连snale2 ,而不能连snale? 这是因为,网络安装的时候使用了这些参数:--console pty,target_type=serial --extra-args ‘console=ttyS0,115200n8 serial‘ ,而这些参数不支持本地镜像安装。当然,如果你硬是想要用virsh console 去连接snale ,那也是可以的。只不过,要登录snale 做以下配置:
1、在 /etc/securetty 文件中添加登录控制台ttyS0:
1 [[email protected] ~]# echo "ttyS0" >> /etc/securetty
2、在grub 配置文件中加入 console=ttyS0 (注:该配置必须与kernel 在同一行,不允许在新行)
1 [[email protected] ~]# egrep -v ‘^$|#‘ /etc/grub.conf2 default=0
3 timeout=5
4 splashimage=(hd0,0)/grub/splash.xpm.gz5 hiddenmenu6 title CentOS 6 (2.6.32-573.el6.x86_64)7 root (hd0,0)8 kernel /vmlinuz-2.6.32-573.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 console=ttyS09 initrd /initramfs-2.6.32-573.el6.x86_64.img
3、在初始化启动模式文件中加入 S0:12345:respawn:/sbin/agetty ttyS0 115200
1 [[email protected] ~]# echo "S0:12345:respawn:/sbin/agetty ttyS0 115200" >> /etc/inittab
4、重启虚拟机
5、再次在物理机上使用virsh console 连接snale ,如下:
1 [[email protected] ~ 17:40:15]#virsh console snale2 连接到域 snale3 Escape character is ^]4
5 CentOS release 6.7(Final)6 Kernel 2.6.32-573.el6.x86_64 on an x86_647
8 localhost.localdomain login: root9 Password:10 Last login: Wed Sep 28 05:22:36 from 192.168.0.236
11 [[email protected] ~]#
原文:http://www.cnblogs.com/chenjiahe/p/5917028.html