Chinaunix首页 | 论坛 | 博客
  • 博客访问: 266791
  • 博文数量: 56
  • 博客积分: 1190
  • 博客等级: 少尉
  • 技术积分: 640
  • 用 户 组: 普通用户
  • 注册时间: 2011-09-21 17:05
文章分类

全部博文(56)

文章存档

2014年(2)

2013年(4)

2012年(46)

2011年(4)

我的朋友

分类: LINUX

2012-02-23 12:06:47

During my KVM testing, I wanted to be able to use the virsh “console” command to access the console of my guests. This would make remote management a whole lot easier, since the default remote management interface (vnc) was a bit of overkill. To get virsh to allow me to console in, the first thing I did was update the menu.lst to get grub to write to the serial port:

serial –speed=115200 –unit=0 –word=8 –parity=no –stop=1
terminal –timeout=10 serial

In addition to the two items above, you also need to make sure you disable the splash screen. Next up, I had to adjust the kernel entries in the menu.lst to write to the serial port (ttyS0). Here is a sample entry that does just this:

title CentOS (2.6.18-128.1.10.el5) root (hd0,0) kernel /boot/vmlinuz-2.6.18-128.1.10.el5 ro root=LABEL=/ console=ttyS0 initrd /boot/initrd-2.6.18-128.1.10.el5.img



The items listed above will configure grub and the kernel to write to the serial port, but you will not be able to login since a getty process isn’t configured to monitor the serial port. To fix this, you can add the serial device name to /etc/inittab (the entry below assumes you want to use agetty instead of one of the other getty implementations):

S0:12345:respawn:/sbin/agetty ttyS0 115200

After I configured init to spawn a getty process, I had to tell init that it was ok for root to login through ttyS0. Privileged logins are managed through /etc/securetty, which contains a list of devices that root is approved to log in on. To allow root logins over ttyS0, I appended it to the file:

echo “ttyS0″ >> /etc/securetty

Once the items listed above were in place, I was able to fire up virsh and access the console through SSH:

$ virsh

virsh # console kvmnode1 Connected to domain kvmnode1 Escape character is ^] CentOS release 5.3 (Final) Kernel 2.6.18-128.1.10.el5 on an x86_64 kvmnode1 login:

This is amazingly cool, and makes remote management super easy.

阅读(1729) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~