Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

virsh console hangs at the escape character "^]"

I am trying to kickstart a newly built VM. I am stuck with the following. Want to start with a console so that I can include username and other info for this VM:

   @vmhost02 ~]$ sudo virsh start --console testengine
   Domain testengine started
   Connected to domain testengine
   Escape character is ^]

It hangs up in there and doesn't listen to any keys except "^]"

Let me know if you need more information for any ideas...

Thanks very much.

like image 884
iamauser Avatar asked Aug 07 '12 11:08

iamauser


People also ask

How do I exit Virsh?

To exit a virsh console session, type CTRL + Shift followed by ] .

How does Virsh console work?

Virsh is a tool that enables us to manage virsh guest domains. It allows us to create pause and shutdown domains. The --devname parameter allows users to access an already configured alternative console. If we use the --safe option, then it allows a safe console handling.

What is Virsh in Linux?

The virsh command allows you to manage VMs interactively or in batch. It's also helpful for controlling VMs from the Linux shell and integrates with scripts or automation tools.

How do I delete a Virsh virtual machine?

To Delete a KVM Guest Using Virsh: First, list all running KVM guests using “ virsh list ” command. Next, you need to shut down a guest virtual machine using the “ virsh shutdown VM ” command. Finally, delete a VM Guest with “ virsh undefine VM ” command.


3 Answers

1)

You can try to edit /etc/default/grub in the guest, and make sure you have:

GRUB_TERMINAL=serial
GRUB_SERIAL_COMMAND="serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1"

Then execute:

# update-grub
# reboot

2)

If that does not work, try to replace quiet with console=ttyS0 in GRUB_CMDLINE_LINUX_DEFAULT in /etc/default/grub:

GRUB_CMDLINE_LINUX_DEFAULT="... console=ttyS0"

Then again:

# update-grub
# reboot

3)

You may still need to try:

# systemctl enable [email protected]
# systemctl start [email protected]
# reboot
like image 99
Peque Avatar answered Sep 18 '22 06:09

Peque


You would need to define a tty to be used as a virtual console. In case you have access to your vm either using vnc or ssh create the following file

vi /etc/init/ttyS0.conf

The content should be something like

start on stopped rc RUNLEVEL=[2345]
stop on runlevel [!2345]

respawn
exec /sbin/getty -L 38400 ttyS0 vt102  # This is your term type vt102

Save these settings and subsequently from your host machine

 virsh destroy [vm-name]; service libvirtd stop; service libvirtd start; virsh start [vm-name]

I'm doing here a stop/start of libvirt, because it sometimes tend to not send a SIGTERM to libvirt.

Finally try

 virsh console [vm-name]
like image 45
Valentin Bajrami Avatar answered Sep 21 '22 06:09

Valentin Bajrami


May be simpler than the solution of val0x00ff, you shall add the console=ttyS0 at the end of the kernel lines in the /boot/grub2/grub.cfg file of the VM (this is not done by default it seems):

   (vm)$> grubby --update-kernel=ALL --args="console=ttyS0"
   (vm)$> reboot

Then virsh console shall work as expected.

like image 30
Sebastien Varrette Avatar answered Sep 18 '22 06:09

Sebastien Varrette