Welcome Guest ( Log In | Register )


 
Reply to this topicStart new topic
> Linux Stories: RHEL7: Access a virtual machine˘s console.
gpanagou
post 31 Jan 2015, 06:38 PM
Post #1


Member
Group Icon

Group: Members
Posts: 40
Joined: 5-September 14
Member No.: 76102
Gender: I'm a 0!



Standard procedure


With KVM, to access the virtual machine˘s console under X Window, type:

# virt-manager

If you aren˘t under X Window, there is another way to access a virtual machine˘s console: you can go through a serial console.
On the virtual machine, add ˇconsole=ttyS0ˇ at the end of the kernel lines in the /boot/grub2/grub.cfg file:

# grubby --update-kernel=ALL --args="console=ttyS0"

Now, reboot the virtual machine:
 
# reboot

With KVM, connect to the virtual machine˘s console (here vm.example.com):
 
# virsh console vm.example.com 
 
Connected to domain vm.example.com
Escape character is ^]

Red Hat Enterprise Linux Server 7.0 (Maipo)
Kernel 3.10.0-121.el7.x86_64 on an x86_64

vm login:

Emergency procedure


Sometimes you have lost all links to your virtual machine (error in the /etc/fstab file, ssh configuration, etc) and, as you didn˘t set up any virtual console, you are in real trouble. There is still a solution!
Connect to the physical host and shut down your virtual machine (here called vm.example.com):

# virsh destroy vm.example.com

Define where the virtual machine image file is located (by default in the /var/lib/libvirt/images directory with a name like vm.example.com.img):
 
# virsh dumpxml | grep "source file="


Map your virtual machine image file into the host environment (-a for add and -v for verbose):
 
# kpartx -av /var/lib/libvirt/images/vm.example.com.img 
add map loop0p1 (253:2): 0 1024000 linear /dev/loop0 2048
add map loop0p2 (253:3): 0 10240000 linear /dev/loop0 1026048

From the previous display, you know that you˘ve got two partitions (in fact /boot and /, distinguishable
by their respective size).
You need to mount the /boot partition to be able to change the grub configuration:
 
# mount /dev/mapper/loop0p1 /mnt

Then, edit the /mnt/grub2/grub.cfg file and add console=ttyS0 at the end of every line containing /vmlinuz (the linux kernel).
Unmount the partition:
 
# umount /mnt

Unmap the virtual machine image file (-d for delete and -v for verbose):
 
# kpartx -dv /var/lib/libvirt/images/vm.example.com.img
del devmap : loop0p2
del devmap : loop0p1
loop deleted : /dev/loop0

Restart your virtual machine:
 
# virsh start vm.example.com
Domain vm.example.com started

Connect to your virtual machine console:
 
# virsh console vm.example.com
Connected to domain vm.example.com
Escape character is ^]

CentOS Linux 7 (Core)
Kernel 3.10.0-123.el7.x86_64 on an x86_64

vm login:
This procedure works for RHEL 6/CentOS 6 and RHEL 7/CentOS 7.

View the full article
Go to the top of the page
 
Bookmark this: Post to Del.icio.usPost to DiggPost to FacebookPost to GooglePost to SlashdotPost to StumbleUponPost to TechnoratiPost to YahooMyWeb
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 24th June 2025 - 03:54 PM
Skin and Graphics by Dan Ellis and Anubis. Hosting by Forums & More © 2005-2011.
InvisionGames - Your #1 Arcade Games Repository | AllSigs - Signatures for all | Rock Band + Guitar Hero = RockHero ! | The Remoters - Remote Assistance | FileMiners - You ask, We find