Accessing Console Of Ubuntu 16.04 KVM Guest

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












2















When I added Debian 8 to my KVM management tool, I found that I could not access the console unless I added console=ttyS0 to the grub boot configuration. It wasn't great but it worked. I am in the process of adding Ubuntu 16.04 to the management tool, and this time when the guest is installed it has the same problem, but I can no longer see the grub menu options when I reboot the instance whilst connected to the console. Therefore, I cannot implement the workaround.



I managed to find the IP address of the guest instance by running arp -an on the hypervisor and connecting to the IPs on the KVM bridge until I found the right one. This allowed me to confirm that the guest was installed and running correctly. I would like to be able to connect to the console using sudo virsh console [guest ID] in case something goes wrong with the networking or if openssh suddenly decides to stop working. What do I need to do to be able to connect to the guest ubuntu 16.04 console from the hypervisor?



My gut feeling is that I should just need to tweak the configuration settings which are accessed by sudo virsh edit [guestID]. At the moment I have:



...
<serial type='pty'>
<target port='0'/>
</serial>
<console type='pty'>
<target type='serial' port='0'/>
</console>
...


Extra Info



  • Ubuntu 14.04 KVM hypervisor using kernel 4.2.0-36-generic

  • Virsh 1.2.2









share|improve this question
























  • if you are allocating an IP to the VM by DHCP, see my find-vm-ip-by-name.sh script in unix.stackexchange.com/a/239170/7696. Even better would be to allocate a static IP by MAC address to the VM in the dhcpd (or dnsmasq) config, and then add a matching entry to your DNS (or /etc/hosts file).

    – cas
    Jun 8 '16 at 11:03












  • That's useful, but users will need to ensure that they install the openssh-server package during installation, otherwise that and my solution below will not be able to help them.

    – Programster
    Jun 8 '16 at 11:12











  • To me, it's an absolute given that a VM can, should, and WILL have sshd installed. Even if it only has a private address on a local bridge...it just never occurred to me that sshd wouldn't be installed. BTW, if there's no network or sshd, and no serial console, virt-manager can give access to the console. The VM may be configured for VNC access (use virsh dumpxml and search for graphics type='vnc' to check).

    – cas
    Jun 8 '16 at 11:25











  • BTW, if you're building ubuntu 16.04 VMs by preseed, add ssh packages to your preseed.cfg (e.g. with d-i pkgsel/include string ssh). Or if users are cloning an existing VM image, make sure it has ssh installed first.

    – cas
    Jun 8 '16 at 11:30











  • I've made sure that the default kickstart script that my tool uses will automatically install openssh-server, but I'm thinking about the users who decide to manually step through the installation.

    – Programster
    Jun 8 '16 at 15:05















2















When I added Debian 8 to my KVM management tool, I found that I could not access the console unless I added console=ttyS0 to the grub boot configuration. It wasn't great but it worked. I am in the process of adding Ubuntu 16.04 to the management tool, and this time when the guest is installed it has the same problem, but I can no longer see the grub menu options when I reboot the instance whilst connected to the console. Therefore, I cannot implement the workaround.



I managed to find the IP address of the guest instance by running arp -an on the hypervisor and connecting to the IPs on the KVM bridge until I found the right one. This allowed me to confirm that the guest was installed and running correctly. I would like to be able to connect to the console using sudo virsh console [guest ID] in case something goes wrong with the networking or if openssh suddenly decides to stop working. What do I need to do to be able to connect to the guest ubuntu 16.04 console from the hypervisor?



My gut feeling is that I should just need to tweak the configuration settings which are accessed by sudo virsh edit [guestID]. At the moment I have:



...
<serial type='pty'>
<target port='0'/>
</serial>
<console type='pty'>
<target type='serial' port='0'/>
</console>
...


Extra Info



  • Ubuntu 14.04 KVM hypervisor using kernel 4.2.0-36-generic

  • Virsh 1.2.2









share|improve this question
























  • if you are allocating an IP to the VM by DHCP, see my find-vm-ip-by-name.sh script in unix.stackexchange.com/a/239170/7696. Even better would be to allocate a static IP by MAC address to the VM in the dhcpd (or dnsmasq) config, and then add a matching entry to your DNS (or /etc/hosts file).

    – cas
    Jun 8 '16 at 11:03












  • That's useful, but users will need to ensure that they install the openssh-server package during installation, otherwise that and my solution below will not be able to help them.

    – Programster
    Jun 8 '16 at 11:12











  • To me, it's an absolute given that a VM can, should, and WILL have sshd installed. Even if it only has a private address on a local bridge...it just never occurred to me that sshd wouldn't be installed. BTW, if there's no network or sshd, and no serial console, virt-manager can give access to the console. The VM may be configured for VNC access (use virsh dumpxml and search for graphics type='vnc' to check).

    – cas
    Jun 8 '16 at 11:25











  • BTW, if you're building ubuntu 16.04 VMs by preseed, add ssh packages to your preseed.cfg (e.g. with d-i pkgsel/include string ssh). Or if users are cloning an existing VM image, make sure it has ssh installed first.

    – cas
    Jun 8 '16 at 11:30











  • I've made sure that the default kickstart script that my tool uses will automatically install openssh-server, but I'm thinking about the users who decide to manually step through the installation.

    – Programster
    Jun 8 '16 at 15:05













2












2








2


3






When I added Debian 8 to my KVM management tool, I found that I could not access the console unless I added console=ttyS0 to the grub boot configuration. It wasn't great but it worked. I am in the process of adding Ubuntu 16.04 to the management tool, and this time when the guest is installed it has the same problem, but I can no longer see the grub menu options when I reboot the instance whilst connected to the console. Therefore, I cannot implement the workaround.



I managed to find the IP address of the guest instance by running arp -an on the hypervisor and connecting to the IPs on the KVM bridge until I found the right one. This allowed me to confirm that the guest was installed and running correctly. I would like to be able to connect to the console using sudo virsh console [guest ID] in case something goes wrong with the networking or if openssh suddenly decides to stop working. What do I need to do to be able to connect to the guest ubuntu 16.04 console from the hypervisor?



My gut feeling is that I should just need to tweak the configuration settings which are accessed by sudo virsh edit [guestID]. At the moment I have:



...
<serial type='pty'>
<target port='0'/>
</serial>
<console type='pty'>
<target type='serial' port='0'/>
</console>
...


Extra Info



  • Ubuntu 14.04 KVM hypervisor using kernel 4.2.0-36-generic

  • Virsh 1.2.2









share|improve this question
















When I added Debian 8 to my KVM management tool, I found that I could not access the console unless I added console=ttyS0 to the grub boot configuration. It wasn't great but it worked. I am in the process of adding Ubuntu 16.04 to the management tool, and this time when the guest is installed it has the same problem, but I can no longer see the grub menu options when I reboot the instance whilst connected to the console. Therefore, I cannot implement the workaround.



I managed to find the IP address of the guest instance by running arp -an on the hypervisor and connecting to the IPs on the KVM bridge until I found the right one. This allowed me to confirm that the guest was installed and running correctly. I would like to be able to connect to the console using sudo virsh console [guest ID] in case something goes wrong with the networking or if openssh suddenly decides to stop working. What do I need to do to be able to connect to the guest ubuntu 16.04 console from the hypervisor?



My gut feeling is that I should just need to tweak the configuration settings which are accessed by sudo virsh edit [guestID]. At the moment I have:



...
<serial type='pty'>
<target port='0'/>
</serial>
<console type='pty'>
<target type='serial' port='0'/>
</console>
...


Extra Info



  • Ubuntu 14.04 KVM hypervisor using kernel 4.2.0-36-generic

  • Virsh 1.2.2






console tty kvm






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 13 '17 at 12:37









Community

1




1










asked Jun 8 '16 at 7:51









ProgramsterProgramster

1,04241323




1,04241323












  • if you are allocating an IP to the VM by DHCP, see my find-vm-ip-by-name.sh script in unix.stackexchange.com/a/239170/7696. Even better would be to allocate a static IP by MAC address to the VM in the dhcpd (or dnsmasq) config, and then add a matching entry to your DNS (or /etc/hosts file).

    – cas
    Jun 8 '16 at 11:03












  • That's useful, but users will need to ensure that they install the openssh-server package during installation, otherwise that and my solution below will not be able to help them.

    – Programster
    Jun 8 '16 at 11:12











  • To me, it's an absolute given that a VM can, should, and WILL have sshd installed. Even if it only has a private address on a local bridge...it just never occurred to me that sshd wouldn't be installed. BTW, if there's no network or sshd, and no serial console, virt-manager can give access to the console. The VM may be configured for VNC access (use virsh dumpxml and search for graphics type='vnc' to check).

    – cas
    Jun 8 '16 at 11:25











  • BTW, if you're building ubuntu 16.04 VMs by preseed, add ssh packages to your preseed.cfg (e.g. with d-i pkgsel/include string ssh). Or if users are cloning an existing VM image, make sure it has ssh installed first.

    – cas
    Jun 8 '16 at 11:30











  • I've made sure that the default kickstart script that my tool uses will automatically install openssh-server, but I'm thinking about the users who decide to manually step through the installation.

    – Programster
    Jun 8 '16 at 15:05

















  • if you are allocating an IP to the VM by DHCP, see my find-vm-ip-by-name.sh script in unix.stackexchange.com/a/239170/7696. Even better would be to allocate a static IP by MAC address to the VM in the dhcpd (or dnsmasq) config, and then add a matching entry to your DNS (or /etc/hosts file).

    – cas
    Jun 8 '16 at 11:03












  • That's useful, but users will need to ensure that they install the openssh-server package during installation, otherwise that and my solution below will not be able to help them.

    – Programster
    Jun 8 '16 at 11:12











  • To me, it's an absolute given that a VM can, should, and WILL have sshd installed. Even if it only has a private address on a local bridge...it just never occurred to me that sshd wouldn't be installed. BTW, if there's no network or sshd, and no serial console, virt-manager can give access to the console. The VM may be configured for VNC access (use virsh dumpxml and search for graphics type='vnc' to check).

    – cas
    Jun 8 '16 at 11:25











  • BTW, if you're building ubuntu 16.04 VMs by preseed, add ssh packages to your preseed.cfg (e.g. with d-i pkgsel/include string ssh). Or if users are cloning an existing VM image, make sure it has ssh installed first.

    – cas
    Jun 8 '16 at 11:30











  • I've made sure that the default kickstart script that my tool uses will automatically install openssh-server, but I'm thinking about the users who decide to manually step through the installation.

    – Programster
    Jun 8 '16 at 15:05
















if you are allocating an IP to the VM by DHCP, see my find-vm-ip-by-name.sh script in unix.stackexchange.com/a/239170/7696. Even better would be to allocate a static IP by MAC address to the VM in the dhcpd (or dnsmasq) config, and then add a matching entry to your DNS (or /etc/hosts file).

– cas
Jun 8 '16 at 11:03






if you are allocating an IP to the VM by DHCP, see my find-vm-ip-by-name.sh script in unix.stackexchange.com/a/239170/7696. Even better would be to allocate a static IP by MAC address to the VM in the dhcpd (or dnsmasq) config, and then add a matching entry to your DNS (or /etc/hosts file).

– cas
Jun 8 '16 at 11:03














That's useful, but users will need to ensure that they install the openssh-server package during installation, otherwise that and my solution below will not be able to help them.

– Programster
Jun 8 '16 at 11:12





That's useful, but users will need to ensure that they install the openssh-server package during installation, otherwise that and my solution below will not be able to help them.

– Programster
Jun 8 '16 at 11:12













To me, it's an absolute given that a VM can, should, and WILL have sshd installed. Even if it only has a private address on a local bridge...it just never occurred to me that sshd wouldn't be installed. BTW, if there's no network or sshd, and no serial console, virt-manager can give access to the console. The VM may be configured for VNC access (use virsh dumpxml and search for graphics type='vnc' to check).

– cas
Jun 8 '16 at 11:25





To me, it's an absolute given that a VM can, should, and WILL have sshd installed. Even if it only has a private address on a local bridge...it just never occurred to me that sshd wouldn't be installed. BTW, if there's no network or sshd, and no serial console, virt-manager can give access to the console. The VM may be configured for VNC access (use virsh dumpxml and search for graphics type='vnc' to check).

– cas
Jun 8 '16 at 11:25













BTW, if you're building ubuntu 16.04 VMs by preseed, add ssh packages to your preseed.cfg (e.g. with d-i pkgsel/include string ssh). Or if users are cloning an existing VM image, make sure it has ssh installed first.

– cas
Jun 8 '16 at 11:30





BTW, if you're building ubuntu 16.04 VMs by preseed, add ssh packages to your preseed.cfg (e.g. with d-i pkgsel/include string ssh). Or if users are cloning an existing VM image, make sure it has ssh installed first.

– cas
Jun 8 '16 at 11:30













I've made sure that the default kickstart script that my tool uses will automatically install openssh-server, but I'm thinking about the users who decide to manually step through the installation.

– Programster
Jun 8 '16 at 15:05





I've made sure that the default kickstart script that my tool uses will automatically install openssh-server, but I'm thinking about the users who decide to manually step through the installation.

– Programster
Jun 8 '16 at 15:05










4 Answers
4






active

oldest

votes


















6














Update 13th March 2017



For those already in the situation described above, you can fix your existing guest using the original answer below. However, for those of you who would rather never have to go through this pain again, you can just add the following so the %post section of your kickstart file:



%post --nochroot
(
sed -i "s;quiet;quiet console=ttyS0;" /target/etc/default/grub
sed -i "s;quiet;quiet console=ttyS0;g" /target/boot/grub/grub.cfg
) 1> /target/root/post_install.log 2>&1
%end


This will ensure that the necessary changes to grub are made as described below, so that new guests you deploy through using the kickstart file won't suffer from this problem.



Original Answer



For those who manage to connect via SSH after finding out the IP using arp -an on the host, you can perform the following steps (taken from the bottom of this page) once you are connected to the guest.



Edit the grub configuration file:



sudo vim /etc/default/grub


Add the text console=ttyS0 to the GRUB_CMDLINE_LINUX_DEFAULT parameter as shown below:



enter image description here



Then have the grub menu be rebuilt using your change by executing:



sudo update-grub


Now you should be able to connect to a working console with virsh console [guest ID].



This will keep working as future kernels are added to the system, but I would much rather have a solution that didn't require me to have SSH access to the guest in the first place.






share|improve this answer




















  • 1





    Note that %post must be terminated by %end.

    – John McGehee
    Mar 11 '18 at 19:04











  • @JohnMcGehee thanks, I've put that in. Better late than never :)

    – Programster
    May 5 '18 at 17:24


















4














Thanks @Programster solution works for me.
Since I do not even have SSH access, I have to install and use virt-edit.



sudo apt install libguestfs-tools
sudo virt-edit -d myVM /boot/grub/grub.cfg


Replace all instances of quiet with quiet console=ttyS0 in the grub.cfg file and start my VM for console connect.



virsh start myVM && virsh console myVM


Do not forget to edit and update grub per @programster answer after login.






share|improve this answer

























  • This just saved me a world of pain after upgrading to 18.04. It's just a shame that installing libguestfs-tools requires pulling down a lot of packages.

    – Programster
    May 3 '18 at 14:17


















0














Fix the grub configuration in a post installation step as suggested in @Programster's excellent answer. Here is how to do it in some other situations.



When installing Ubuntu 16.04 using a Debconf preseed file, add this to your preseed file:




d-i preseed/late_command string (
sed -i "s;quiet;quiet console=ttyS0;" /target/etc/default/grub;
sed -i "s;quiet;quiet console=ttyS0;g" /target/boot/grub/grub.cfg
) 1> /target/root/post_install.log 2>&1


When installing RHEL 7 or CentOS 7 using Kickstart, add this to your kickstart file:




%post --nochroot --log /mnt/sysimage/root/post.log
(
sed -i "s;quiet;quiet console=ttyS0;" /mnt/sysimage/etc/default/grub
sed -i "s;quiet;quiet console=ttyS0;g" /mnt/sysimage/boot/grub2/grub.cfg
) > /mnt/sysimage/root/post_install.log 2>&1
%end





share|improve this answer
































    0














    A simpler and easier method as per the redhat docs



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





    share|improve this answer






















      Your Answer








      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "106"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f288344%2faccessing-console-of-ubuntu-16-04-kvm-guest%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      4 Answers
      4






      active

      oldest

      votes








      4 Answers
      4






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      6














      Update 13th March 2017



      For those already in the situation described above, you can fix your existing guest using the original answer below. However, for those of you who would rather never have to go through this pain again, you can just add the following so the %post section of your kickstart file:



      %post --nochroot
      (
      sed -i "s;quiet;quiet console=ttyS0;" /target/etc/default/grub
      sed -i "s;quiet;quiet console=ttyS0;g" /target/boot/grub/grub.cfg
      ) 1> /target/root/post_install.log 2>&1
      %end


      This will ensure that the necessary changes to grub are made as described below, so that new guests you deploy through using the kickstart file won't suffer from this problem.



      Original Answer



      For those who manage to connect via SSH after finding out the IP using arp -an on the host, you can perform the following steps (taken from the bottom of this page) once you are connected to the guest.



      Edit the grub configuration file:



      sudo vim /etc/default/grub


      Add the text console=ttyS0 to the GRUB_CMDLINE_LINUX_DEFAULT parameter as shown below:



      enter image description here



      Then have the grub menu be rebuilt using your change by executing:



      sudo update-grub


      Now you should be able to connect to a working console with virsh console [guest ID].



      This will keep working as future kernels are added to the system, but I would much rather have a solution that didn't require me to have SSH access to the guest in the first place.






      share|improve this answer




















      • 1





        Note that %post must be terminated by %end.

        – John McGehee
        Mar 11 '18 at 19:04











      • @JohnMcGehee thanks, I've put that in. Better late than never :)

        – Programster
        May 5 '18 at 17:24















      6














      Update 13th March 2017



      For those already in the situation described above, you can fix your existing guest using the original answer below. However, for those of you who would rather never have to go through this pain again, you can just add the following so the %post section of your kickstart file:



      %post --nochroot
      (
      sed -i "s;quiet;quiet console=ttyS0;" /target/etc/default/grub
      sed -i "s;quiet;quiet console=ttyS0;g" /target/boot/grub/grub.cfg
      ) 1> /target/root/post_install.log 2>&1
      %end


      This will ensure that the necessary changes to grub are made as described below, so that new guests you deploy through using the kickstart file won't suffer from this problem.



      Original Answer



      For those who manage to connect via SSH after finding out the IP using arp -an on the host, you can perform the following steps (taken from the bottom of this page) once you are connected to the guest.



      Edit the grub configuration file:



      sudo vim /etc/default/grub


      Add the text console=ttyS0 to the GRUB_CMDLINE_LINUX_DEFAULT parameter as shown below:



      enter image description here



      Then have the grub menu be rebuilt using your change by executing:



      sudo update-grub


      Now you should be able to connect to a working console with virsh console [guest ID].



      This will keep working as future kernels are added to the system, but I would much rather have a solution that didn't require me to have SSH access to the guest in the first place.






      share|improve this answer




















      • 1





        Note that %post must be terminated by %end.

        – John McGehee
        Mar 11 '18 at 19:04











      • @JohnMcGehee thanks, I've put that in. Better late than never :)

        – Programster
        May 5 '18 at 17:24













      6












      6








      6







      Update 13th March 2017



      For those already in the situation described above, you can fix your existing guest using the original answer below. However, for those of you who would rather never have to go through this pain again, you can just add the following so the %post section of your kickstart file:



      %post --nochroot
      (
      sed -i "s;quiet;quiet console=ttyS0;" /target/etc/default/grub
      sed -i "s;quiet;quiet console=ttyS0;g" /target/boot/grub/grub.cfg
      ) 1> /target/root/post_install.log 2>&1
      %end


      This will ensure that the necessary changes to grub are made as described below, so that new guests you deploy through using the kickstart file won't suffer from this problem.



      Original Answer



      For those who manage to connect via SSH after finding out the IP using arp -an on the host, you can perform the following steps (taken from the bottom of this page) once you are connected to the guest.



      Edit the grub configuration file:



      sudo vim /etc/default/grub


      Add the text console=ttyS0 to the GRUB_CMDLINE_LINUX_DEFAULT parameter as shown below:



      enter image description here



      Then have the grub menu be rebuilt using your change by executing:



      sudo update-grub


      Now you should be able to connect to a working console with virsh console [guest ID].



      This will keep working as future kernels are added to the system, but I would much rather have a solution that didn't require me to have SSH access to the guest in the first place.






      share|improve this answer















      Update 13th March 2017



      For those already in the situation described above, you can fix your existing guest using the original answer below. However, for those of you who would rather never have to go through this pain again, you can just add the following so the %post section of your kickstart file:



      %post --nochroot
      (
      sed -i "s;quiet;quiet console=ttyS0;" /target/etc/default/grub
      sed -i "s;quiet;quiet console=ttyS0;g" /target/boot/grub/grub.cfg
      ) 1> /target/root/post_install.log 2>&1
      %end


      This will ensure that the necessary changes to grub are made as described below, so that new guests you deploy through using the kickstart file won't suffer from this problem.



      Original Answer



      For those who manage to connect via SSH after finding out the IP using arp -an on the host, you can perform the following steps (taken from the bottom of this page) once you are connected to the guest.



      Edit the grub configuration file:



      sudo vim /etc/default/grub


      Add the text console=ttyS0 to the GRUB_CMDLINE_LINUX_DEFAULT parameter as shown below:



      enter image description here



      Then have the grub menu be rebuilt using your change by executing:



      sudo update-grub


      Now you should be able to connect to a working console with virsh console [guest ID].



      This will keep working as future kernels are added to the system, but I would much rather have a solution that didn't require me to have SSH access to the guest in the first place.







      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited May 5 '18 at 17:23

























      answered Jun 8 '16 at 8:29









      ProgramsterProgramster

      1,04241323




      1,04241323







      • 1





        Note that %post must be terminated by %end.

        – John McGehee
        Mar 11 '18 at 19:04











      • @JohnMcGehee thanks, I've put that in. Better late than never :)

        – Programster
        May 5 '18 at 17:24












      • 1





        Note that %post must be terminated by %end.

        – John McGehee
        Mar 11 '18 at 19:04











      • @JohnMcGehee thanks, I've put that in. Better late than never :)

        – Programster
        May 5 '18 at 17:24







      1




      1





      Note that %post must be terminated by %end.

      – John McGehee
      Mar 11 '18 at 19:04





      Note that %post must be terminated by %end.

      – John McGehee
      Mar 11 '18 at 19:04













      @JohnMcGehee thanks, I've put that in. Better late than never :)

      – Programster
      May 5 '18 at 17:24





      @JohnMcGehee thanks, I've put that in. Better late than never :)

      – Programster
      May 5 '18 at 17:24













      4














      Thanks @Programster solution works for me.
      Since I do not even have SSH access, I have to install and use virt-edit.



      sudo apt install libguestfs-tools
      sudo virt-edit -d myVM /boot/grub/grub.cfg


      Replace all instances of quiet with quiet console=ttyS0 in the grub.cfg file and start my VM for console connect.



      virsh start myVM && virsh console myVM


      Do not forget to edit and update grub per @programster answer after login.






      share|improve this answer

























      • This just saved me a world of pain after upgrading to 18.04. It's just a shame that installing libguestfs-tools requires pulling down a lot of packages.

        – Programster
        May 3 '18 at 14:17















      4














      Thanks @Programster solution works for me.
      Since I do not even have SSH access, I have to install and use virt-edit.



      sudo apt install libguestfs-tools
      sudo virt-edit -d myVM /boot/grub/grub.cfg


      Replace all instances of quiet with quiet console=ttyS0 in the grub.cfg file and start my VM for console connect.



      virsh start myVM && virsh console myVM


      Do not forget to edit and update grub per @programster answer after login.






      share|improve this answer

























      • This just saved me a world of pain after upgrading to 18.04. It's just a shame that installing libguestfs-tools requires pulling down a lot of packages.

        – Programster
        May 3 '18 at 14:17













      4












      4








      4







      Thanks @Programster solution works for me.
      Since I do not even have SSH access, I have to install and use virt-edit.



      sudo apt install libguestfs-tools
      sudo virt-edit -d myVM /boot/grub/grub.cfg


      Replace all instances of quiet with quiet console=ttyS0 in the grub.cfg file and start my VM for console connect.



      virsh start myVM && virsh console myVM


      Do not forget to edit and update grub per @programster answer after login.






      share|improve this answer















      Thanks @Programster solution works for me.
      Since I do not even have SSH access, I have to install and use virt-edit.



      sudo apt install libguestfs-tools
      sudo virt-edit -d myVM /boot/grub/grub.cfg


      Replace all instances of quiet with quiet console=ttyS0 in the grub.cfg file and start my VM for console connect.



      virsh start myVM && virsh console myVM


      Do not forget to edit and update grub per @programster answer after login.







      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Jan 13 at 20:37









      ljwobker

      205311




      205311










      answered Oct 11 '17 at 4:22









      Erich ChenErich Chen

      411




      411












      • This just saved me a world of pain after upgrading to 18.04. It's just a shame that installing libguestfs-tools requires pulling down a lot of packages.

        – Programster
        May 3 '18 at 14:17

















      • This just saved me a world of pain after upgrading to 18.04. It's just a shame that installing libguestfs-tools requires pulling down a lot of packages.

        – Programster
        May 3 '18 at 14:17
















      This just saved me a world of pain after upgrading to 18.04. It's just a shame that installing libguestfs-tools requires pulling down a lot of packages.

      – Programster
      May 3 '18 at 14:17





      This just saved me a world of pain after upgrading to 18.04. It's just a shame that installing libguestfs-tools requires pulling down a lot of packages.

      – Programster
      May 3 '18 at 14:17











      0














      Fix the grub configuration in a post installation step as suggested in @Programster's excellent answer. Here is how to do it in some other situations.



      When installing Ubuntu 16.04 using a Debconf preseed file, add this to your preseed file:




      d-i preseed/late_command string (
      sed -i "s;quiet;quiet console=ttyS0;" /target/etc/default/grub;
      sed -i "s;quiet;quiet console=ttyS0;g" /target/boot/grub/grub.cfg
      ) 1> /target/root/post_install.log 2>&1


      When installing RHEL 7 or CentOS 7 using Kickstart, add this to your kickstart file:




      %post --nochroot --log /mnt/sysimage/root/post.log
      (
      sed -i "s;quiet;quiet console=ttyS0;" /mnt/sysimage/etc/default/grub
      sed -i "s;quiet;quiet console=ttyS0;g" /mnt/sysimage/boot/grub2/grub.cfg
      ) > /mnt/sysimage/root/post_install.log 2>&1
      %end





      share|improve this answer





























        0














        Fix the grub configuration in a post installation step as suggested in @Programster's excellent answer. Here is how to do it in some other situations.



        When installing Ubuntu 16.04 using a Debconf preseed file, add this to your preseed file:




        d-i preseed/late_command string (
        sed -i "s;quiet;quiet console=ttyS0;" /target/etc/default/grub;
        sed -i "s;quiet;quiet console=ttyS0;g" /target/boot/grub/grub.cfg
        ) 1> /target/root/post_install.log 2>&1


        When installing RHEL 7 or CentOS 7 using Kickstart, add this to your kickstart file:




        %post --nochroot --log /mnt/sysimage/root/post.log
        (
        sed -i "s;quiet;quiet console=ttyS0;" /mnt/sysimage/etc/default/grub
        sed -i "s;quiet;quiet console=ttyS0;g" /mnt/sysimage/boot/grub2/grub.cfg
        ) > /mnt/sysimage/root/post_install.log 2>&1
        %end





        share|improve this answer



























          0












          0








          0







          Fix the grub configuration in a post installation step as suggested in @Programster's excellent answer. Here is how to do it in some other situations.



          When installing Ubuntu 16.04 using a Debconf preseed file, add this to your preseed file:




          d-i preseed/late_command string (
          sed -i "s;quiet;quiet console=ttyS0;" /target/etc/default/grub;
          sed -i "s;quiet;quiet console=ttyS0;g" /target/boot/grub/grub.cfg
          ) 1> /target/root/post_install.log 2>&1


          When installing RHEL 7 or CentOS 7 using Kickstart, add this to your kickstart file:




          %post --nochroot --log /mnt/sysimage/root/post.log
          (
          sed -i "s;quiet;quiet console=ttyS0;" /mnt/sysimage/etc/default/grub
          sed -i "s;quiet;quiet console=ttyS0;g" /mnt/sysimage/boot/grub2/grub.cfg
          ) > /mnt/sysimage/root/post_install.log 2>&1
          %end





          share|improve this answer















          Fix the grub configuration in a post installation step as suggested in @Programster's excellent answer. Here is how to do it in some other situations.



          When installing Ubuntu 16.04 using a Debconf preseed file, add this to your preseed file:




          d-i preseed/late_command string (
          sed -i "s;quiet;quiet console=ttyS0;" /target/etc/default/grub;
          sed -i "s;quiet;quiet console=ttyS0;g" /target/boot/grub/grub.cfg
          ) 1> /target/root/post_install.log 2>&1


          When installing RHEL 7 or CentOS 7 using Kickstart, add this to your kickstart file:




          %post --nochroot --log /mnt/sysimage/root/post.log
          (
          sed -i "s;quiet;quiet console=ttyS0;" /mnt/sysimage/etc/default/grub
          sed -i "s;quiet;quiet console=ttyS0;g" /mnt/sysimage/boot/grub2/grub.cfg
          ) > /mnt/sysimage/root/post_install.log 2>&1
          %end






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 11 '18 at 21:45

























          answered Mar 11 '18 at 19:09









          John McGeheeJohn McGehee

          1013




          1013





















              0














              A simpler and easier method as per the redhat docs



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





              share|improve this answer



























                0














                A simpler and easier method as per the redhat docs



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





                share|improve this answer

























                  0












                  0








                  0







                  A simpler and easier method as per the redhat docs



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





                  share|improve this answer













                  A simpler and easier method as per the redhat docs



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






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 15 '18 at 10:34









                  nelaaronelaaro

                  5602714




                  5602714



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Unix & Linux Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f288344%2faccessing-console-of-ubuntu-16-04-kvm-guest%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown






                      Popular posts from this blog

                      How to check contact read email or not when send email to Individual?

                      Displaying single band from multi-band raster using QGIS

                      How many registers does an x86_64 CPU actually have?