-2

This question already has an answer here:

I have created a Debian virtual machine in virt-manager/KVM/QEMU.

When I run the Debian virtual machine, I don't really need the desktop environment, which is also resource consuming. Can I start Debian only on a text virtual console (e.g. like ctrl-alt-f1) instead of the graphical virtual console (i.e. ctrl-alt-f7) on the virtual machine?

Thanks.

marked as duplicate by telcoM, DarkHeart, icarus, Prvt_Yadv, muru Mar 31 at 6:20

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • And maybe, you should have installed Debian using a Netinstall ISO, that has the essential minimal for a Non-X setup - debian.org/distrib/netinst - Also, remember to not select a desktop environment during the setup process, or it will download it. Keep up the bare minimal, and the ssh server if you want... – user34720 Mar 28 at 10:59
  • 1
    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. – Stéphane Chazelas Mar 29 at 12:31
  • @StéphaneChazelas Thanks. How shall I not give a virtual graphics card at all to your VM and have the console on serial? – Tim Mar 29 at 14:45
1

You need to switch from the graphical.target to multi-user.target:

systemctl set-default multi-user.target
reboot

then use the chvt to switch between tty.


If debian already up , you can use the virsh send-key command from the host machine to switch to the tty.

e,g: to switch to tty2 use the following command:

virsh send-key guest --codeset linux  KEY_LEFTCTRL KEY_LEFTALT KEY_F2

( guest is the VM Name use virsh list --all to get the exact name)

Edit

To switch to the GUI from the default multi-user target:

systemctl start graphical.target

You should start the graphical target then you will be able to send Ctrl+Alt+F7 from the host.

  • 1
    Thanks. (1) With multi-user.target, can I switch to GUI? Sending ctrl-alt-f7 from host by virsh send-key guest --codeset linux KEY_LEFTCTRL KEY_LEFTALT KEY_F7 doesn't seem to work. (2) With graphical.target, if I switch to a text virtual console from GUI console by ctrl-alt-f1, can I kill the GUI processes? – Tim Mar 29 at 2:35
2

There are several ways of going about this, but in your case, I think the best one is to remove the display manager and anything which depends on it, for example

sudo apt purge lightdm

Next time you set up a VM, if you don’t want a graphical environment, you can skip installing it altogether.

  • Thanks. Why uninstall lightdm, instead of Xorg? – Tim Mar 29 at 2:41
  • Because removing the display manager is sufficient to get Debian to start on a text VC, which is what you asked for in your question. – Stephen Kitt Mar 29 at 10:23
  • If I uninstall Xorg, which virtual console will it ends up with? Will Debian still start the display manager which then forks other processes, regardless of whether Xorg is installed or not? – Tim Mar 29 at 13:45
  • Well, have you tried it? The answer depends on the display manager. Just uninstall the display manager. – Stephen Kitt Mar 29 at 14:00

Not the answer you're looking for? Browse other questions tagged or ask your own question.