Solved GRUB menu entry to boot to TTY?

Solved issue

rado84

Well-Known Member
Joined
Feb 25, 2019
Messages
757
Reaction score
623
Credits
4,705
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.
 


If the graphical environment doesn't load but the system it booted you can just use the ctrl+alt+f? shortcuts to switch to a tty without having to boot from the Arch live environment to chroot into your system to rescue it. Why would you need to add it to a grub menu, if you can switch to a tty at any moment if it's only the graphical environment fails to load?
 
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.
 
Last edited:
This is the menu entry:
Code:
menuentry "Arch 6.x LTS" --class arcolinux --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-linux-advanced-73719eb1-eb34-4234-9a3e-fd86f6999d54' {
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_msdos
        insmod ext2
        set root='hd1,msdos1'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd1,msdos1 --hint-efi=hd1,msdos1 --hint-baremetal=ahci1,msdos1  73719eb1-eb34-4234-9a3e-fd86f6999d54
        else
          search --no-floppy --fs-uuid --set=root 73719eb1-eb34-4234-9a3e-fd86f6999d54
        fi
        echo    'Loading Linux linux-lts ...'
        linux    /boot/vmlinuz-linux-lts root=UUID=73719eb1-eb34-4234-9a3e-fd86f6999d54 rw  acpi=force acpi_enforce_resources=lax intel_pstate=disable
        echo    'Loading initial ramdisk ...'
        initrd    /boot/initramfs-linux-lts.img
}

So where, exactly, do I put the number "3"?
 
rado84 asked:
So where, exactly, do I put the number "3"?
At the end of the linux line after a space ... like so:
Code:
linux    /boot/vmlinuz-linux-lts root=UUID=73719eb1-eb34-4234-9a3e-fd86f6999d54 rw  acpi=force acpi_enforce_resources=lax intel_pstate=disable 3
 
Cool, I'll try that now.
Also, I'm editing grub.cfg directly myself. Not just now but in principle. Arch wiki says (as I have discovered myself, long before I read it) that directly editing grub.cfg doesn't require you to execute update-grub or whatever that command was. Grub.cfg remains the same as what I've made of it, even if the package grub updates.

Edit, 20 seconds later: Yesss, it works! :D Thanks, man, that's a cool hack!
 
Cool, I'll try that now.
Also, I'm editing grub.cfg directly myself. Not just now but in principle. Arch wiki says (as I have discovered myself, long before I read it) that directly editing grub.cfg doesn't require you to execute update-grub or whatever that command was. Grub.cfg remains the same as what I've made of it, even if the package grub updates.
Yes, that's the hack I was referring to, and mentioned that a grub update would nullify it. It's for the other "conventional" means of changing the configs that one needs to update grub.
 
rado84 asked:

At the end of the linux line after a space ... like so:
Code:
linux    /boot/vmlinuz-linux-lts root=UUID=73719eb1-eb34-4234-9a3e-fd86f6999d54 rw  acpi=force acpi_enforce_resources=lax intel_pstate=disable 3
Didn't work for debian 12. Could this hack be distro specific?
 
Didn't work for debian 12. Could this hack be distro specific?
Re-configuring grub when the grub menu appears, as mentioned in post #3, repeating it as follows:
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.
is not distro specific, rather it's grub specific and is a common way of dealing with the issue as presented in the thread. (There needs to be a space before the 3, as mentioned elsewhere). If this method doesn't work, then there may be a problem with the installation of grub.

Grub can check its files for errors with the grub-script-check command, e.g.
grub-script-check /boot/grub/grub.cfg

Grub itself can always be re-installed to regain a clean default installation of it whereupon the above re-configuring from the grub menu should work as intended and expected.

If this continues to be a problem in your case, it's probably best to start your own thread since this thread has been marked as solved.
 
Last edited:
Re-configuring grub when the grub menu appears, as mentioned in post #3, repeating it as follows:

is not distro specific, rather it's grub specific and is a common way of dealing with the issue as presented in the thread. (There needs to be a space before the 3, as mentioned elsewhere). If this method doesn't work, then there may be a problem with the installation of grub.

Grub can check its files for errors with the grub-script-check command, e.g.


Grub itself can always be re-installed to regain a clean default installation of it whereupon the above re-configuring from the grub menu should work as intended and expected.

If this continues to be a problem in your case, it's probably best to start your own thread since this thread has been marked as solved.
Oh..I wrongly assumed it would work if I edited the /boot/grub/grub.cfg file with the '3' appended on the linux line, since it was the same file (kind of). Doing it your way actually worked.
 
Glad that it worked. That's a standard grub process. The hack which was described in post #3 is however, non-standard.

Just to clarify, the hack in post #3 referring to the editing of /boot/grub/grub.cfg, was indeed to add the 3 (with the preceding space) to the linux line in the menuentry, of which there are usually a few. If the user knows which menuentry grub will use when it boots, then the 3 only needs to be added to that linux line, but if the user is unsure, they can add it to every linux line in that file which will ensure that whichever linux kernel is booted, it will boot to the text prompt.
 
Last edited:
Glad that it worked. That's a standard grub process. The hack which was described in post #3 is however, non-standard.

Just to clarify, the hack in post #3 referring to the editing of /boot/grub/grub.cfg, was indeed to add the 3 (with the preceding space) to the linux line in the menuentry, of which there are usually a few. If the user knows which menuentry grub will use when it boots, then the 3 only needs to be added to that linux line, but if the user is unsure, they can add it to every linux line in that file which will ensure that whichever linux kernel is booted, it will boot to the text prompt.
Exactly what I thought as well. I did the same thing (appending 3 after a space to every linux line in the file) but still didn't work. I'm glad the hack worked instead.

Edit: or maybe I'm supposed to run update-grub after making the changes to the file. I will try that
 
Last edited:

Members online


Latest posts

Top