6

Issue

  • I have Ubuntu 16 as the host running Ubuntu 14 as a guest (kvm).
  • I installed the VM using virt-install
  • All settings and configuration seems fine

# virsh list
Id Name State
-------------------
2 myVM running
# virsh console myVM
Connected to domain myVM
Escape character is ^]

and nothing.... the cursor doesn't blink... typing doesn't do anything..... the VM is not responding.

Help!

  • 1
    virsh console connects to the "virtual serial console" of your VM. Is that what you want? Or do you want a virtual screen, which depends on your configuration (vnc or spice)? Or something like terminal connection via ssh? Did you try virt-viewer myVM? – ridgy Apr 27 '17 at 20:29
  • Try virsh vncdisplay myVM – Stancu Mihai Apr 28 '17 at 9:06
  • Check the vnc port and try to connect to the vm with vnc – Stancu Mihai Apr 28 '17 at 9:07
  • @ridgy - yes. I want the serial console. something more in the likes of a terminal connection via ssh. I can't use virt-viewer since I have a terminal to the host, and not a GUI interface. – somethingorange May 3 '17 at 8:21
  • @StancuMihai - Same thing - no response.... – somethingorange May 3 '17 at 8:22
7

Just managed to get it to work:

Suppose your virtual domain is myGuest, your preferred editor is vi, and your guest is installed with grub2and uses systemd. If the last assumption is not true, you might have a look at Working with the serial console.

First, install libguestfs-toolson the host:sudo apt install libguestfs-tools. You will need this when working with headless guests.

Second, shut down your guest: virsh shutdown myGuest.

Next, mount the virtual disk: guestmount -g myGuest -i /mnt (or use any other existing directory as mountpoint). Now in /mnt you should be able to see the filesystem of the guest.

With grub2and systemd, you only have to modify the grub configuration: vi /mnt/etc/default/grub, and modify like

GRUB_CMDLINE_LINUX='console=tty0 console=ttyS0,19200n8'
GRUB_TERMINAL=serial
GRUB_SERIAL_COMMAND="serial --speed=19200 --unit=0 --word=8 --parity=no --stop=1"

As you will have to run update-grubon the guest, for the first start you have to also modify /mnt/boot/grub/grub.cfg. Find the default boot menu item and append the console information to the linuxentry to look similar to

linux   /boot/vmlinuz-4.4.0-75-generic root=UUID=76f3e237-d791-4e9d-8ad7-fe5c9165ae55 ro console=ttyS0,19200 earlyprint=serial,ttyS0,19200

Maybe you need root privileges to mount and edit the files.

Now restart the guest and start the virtual console:

virsh start myGuest && virsh console myGuest

You should see the kernel log and then a login prompt. After logging in, don't forget to run sudo update-grub.

  • 2
    In the version of guestmount I'm using (1.36.13), the options seem to be different (there is no -g - instead it's -d or --domain): guestmount -d myGuest -i /mnt – Dennis Williamson Mar 22 at 21:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.