2

Stéphane Chazelas wrote that Can I start Debian on a text virtual console in a virtual machine?

You could also not give a virtual graphics card at all to your VM and have the console on serial. Like for a physical server, that makes it easier to operate the VM as you can then more easily copy-paste text when you access that console from a terminal emulator on the host.

In both virsh and virt-manager, how can I:

  • not give a virtual graphics card at all to both a to-be-created VM and an existing VM (created in any way, either by virsh or virt-manager), and
  • have the console on serial, and
  • access that console from a terminal emulator on the host?
slm
  • 363,520
  • 117
  • 767
  • 871
Tim
  • 98,580
  • 191
  • 570
  • 977
  • 2
    Possible duplicate of [Accessing Console Of Ubuntu 16.04 KVM Guest](https://unix.stackexchange.com/questions/288344/accessing-console-of-ubuntu-16-04-kvm-guest) – 0xSheepdog Mar 29 '19 at 15:16
  • `virt-builder` creates preconfigured VMs with the serial console already enabled. – Michael Hampton Mar 29 '19 at 16:43

1 Answers1

5

When I build a new VM, I use the virt-install command. Effectively the command I end up with is something like:

$ virt-install \
-n $machine_name \
-r $ram_size \
--vcpus=1 \
--os-variant=rhel7 \
--accelerate \
-v \
--network=bridge=br0 \
--disk path=$destfile,size=$disksize \
-l $repo \
--nographics \
-x "ks=http://10.20.30.40/CentOS/kickstart/centos7.cfg ksdevice=eth0 ip=dhcp console=ttyS0,9600 cmdline"

This is for a CentOS7 build and points to my internal source server (10.20.30.40) to pick up the kickstart file. The --nographics tells virt-build to not add a graphics card, and the console=ttyS0,9600 cmdline tells the installer to work via serial.

Once the machine has been built and is running then I can do virsh console $machinename to get to the serial console, eg.:

$ virsh console hass
Connected to domain hass
Escape character is ^]

CentOS Linux 7 (Core)
Kernel 3.10.0-957.10.1.el7.x86_64 on an x86_64

hass login: 
slm
  • 363,520
  • 117
  • 767
  • 871
Stephen Harris
  • 42,369
  • 5
  • 94
  • 123