Can something be added as GRUB menu entry to boot to TTY? Sometimes the system won't boot the desktop due to broken packages and in most cases I know what has been broken but I can't fix it bc the system hangs moments before booting the desktop. So it would be easier if I can simply choose the option from the menu, instead of restoring from backup every time something breaks.
As I understand it, the problem here is that the system hangs, so that getting a console with cntl+alt+F#, may not be available due to a freeze of the system, so you may need to reboot.
One could hack the /boot/grub/grub.cfg file to add a copy of one of the menuentries which already exist in the grub.cfg file, to the end of the file but with an added 3 at the end of its linux line, after a space on that line. Then that linux boot option should appear in the grub menu and if selected, boot to a text prompt. It's a hack, so whenever one updates grub, it will be overwritten and not be available. It's possible to write a script that runs after each grub update one might do, to re-include it.
The usual way I deal with it though is to hit e when grub boots, and then navigate down to the linux line and add the 3 there, hit cntl+x and it boots to a prompt. I hope I've understood the issue.
Another route down this track is to investigate the grub customisation process which involves configuring files in /etc/grub.d/.
From the grub manual:
For more detailed customisation of grub-mkconfig’s output, you may edit the scripts
in ‘/etc/grub.d’ directly. ‘/etc/grub.d/40_custom’ is particularly useful for adding entire
custom menu entries; simply type the menu entries you want to add at the end of that file,
making sure to leave at least the first two lines intact.
and from the /etc/grub.d/40_custom file itself:
Code:
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
You could copy one of the menuentries from /boot/grub/grub.cfg into this file but with the added 3 to have it boot to text. After each config change one needs to update grub of course.
In my own case, that customisation hasn't always been reliable, hence the hack. YMMV.