inside the mind of a linux admin

Virtualization: KVM equivalent to “vzctl enter” in OpenVZ

If you are used to using Virtuozzo or OpenVZ containers and are looking to make the switch to the full virtualization solution KVM (Kernel-based Virtual Machine), you may find one very convenient feature missing: the ability to enter into a virtual environment from the parent node.

Of course, the most popular solution used to access KVM VM is simply connecting via SSH. But what if your key gets removed or the SSH service becomes inaccessible? Rest assured, you can use this little trick to gain access directly to a root shell and manage your VM:

1. Inside the KVM VM edit /etc/default/grub and add the line:

GRUB_CMDLINE_LINUX_DEFAULT=”quiet console=tty0″

2. Update grub


3. Next, add this line to the VM’s /etc/inittab file:

T0:23:respawn:/sbin/getty -l /usr/local/bin/autologin -n -L ttyS0 115200 vt102

4. Then create an executable file /usr/local/bin/autologin that will execute /bin/login:

echo ‘#!/bin/sh exec /bin/login -f root’ > /usr/local/bin/autologin
chmod +x /usr/local/bin/autologin

5. Restart the VM

6. Finally, enter the VM using the command:

virsh console vm_name

Related Posts

How to revert back to X11 / Xorg from Wayland

Wayland is intended as a “simpler replacement for X”, and is getting quite a bit of hype around the Linux community. So much so, that it’s the default in the latest versions of Fedora, GNOME, KDE and others. While Wayland may be the future, it really is in future. At least for Ubuntu 17.10. The […]

Read More

Touchpad stops working after sleep + resume (Fedora 26 on Dell XPS)

After recently upgrading my Dell XPS 13 w/Touchscreen to Fedora 26, the touchpad suddenly stopped working upon resuming from sleep mode. It was reproduced 100% of the time, and required a complete restart in order to get the touchpad working again. There have been several forum posts and bug reports regarding others experiencing these exact […]

Read More

Leave a Reply

Your email address will not be published. Required fields are marked *

Twitter: kireguy

Tweeter button Facebook button Myspace button