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

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

synergy: How to enable crypto (encryption) and generate SSL certificate

The newer Linux versions of the popular mouse/keyboard sharing application “synergy” now has built in encryption. Here’s how to configure it: Just simply passing the –enable-crypto flag on your synergy server without having a proper SSL certificate will result in the inability to connect to clients and generate an error message similar to this in […]

Read More

Change Number Pad Delete (dot) key from a comma in Ubuntu Linux

I recently purchased a new keyboard and updated to the latest Ubuntu, I’m also an avid user of the number pad for quick input when dealing with spreadsheets or accounting. I found that my num pad’s delete key (“.”) was outputting a comma (“,”) instead. Pretty annoying? I agree, but this can be very easily […]

Read More

Leave a Reply

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

Twitter: kireguy

Tweeter button Facebook button Myspace button