Terminal-based (non GUI) virtual-computer program

command lineterminalvirtual machinevirtualization

Are there any terminal-based (ie. non-GUI) virtual-computer programs out there?
I've been using programs like VirtualBox and QEMU, but they're obviously GUI-based…

I was hoping for a virtual PC program where I can do everything – create a new virtual machine, create it's disk, install OS (assuming a text-based installer is available) and start the VM on a terminal (thus replacing the host's shell with the VM's boot-message, log-in prompt and shell) – from a virtual-terminal/xterm-window/ssh/screen-session, instead of in a window under X.

The reason I ask, is that I often use ssh at work to connect to my home-computer, and the network is too slow for X or VNC. Still I'd like to tinker with VMs…

Best Answer

In qemu/kvm, you only get a GUI if you attach a video card to your VM and if you don't expose it as SPICE/VNC.

For instance, you can do (zsh syntax, with grub2):

grub-mkimage -O i386-pc -c =(print -l serial 'terminal_input serial' \
 'terminal_output serial' 
 ) -o grub.img configfile biosdisk part_msdos part_gpt ext2 \
   linux test serial halt minicmd cat

And start your VM with:

kvm -kernel grub.img -hda yourdisk.img -nographic

From the grub prompt, load the kernel from the disk passing console=ttyS0... option or equivalent on the system you're booting to have the console on serial. Remember to add a getty on the serial line as well.

Assuming you're running Linux in the VM, you can then update its grub config to display on serial and boot a kernel with serial console, and then you can boot your image disk directly without that grub.img.

To access the qemu "monitor", type Ctrl-Ac (where you can add/remove devices...).

You can have the serial port as a unix domain or TCP socket, instead of stdio if you like as well. Same for the qemu "monitor" interface.

Now, provided you have the sgabios.bin firmware, and that your VM doesn't use graphics (just VGA BIOS text output), you can also just use the -curses option:

kvm -hda yourdisk -curses

The VGA console is then shown in your terminal. If you need to access the qemu monitor, press Alt-2.