LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   GRUB2.02 hide a single menu entry. (https://www.linuxquestions.org/questions/linux-software-2/grub2-02-hide-a-single-menu-entry-4175607856/)

ezaluzec 06-13-2017 11:33 AM

GRUB2.02 hide a single menu entry.
 
I have an embedded Linux system that uses GRUB2.02. I have added a custom grub.cfg file which lists four menu entries. These entries are, 'Boot base Linux system', 'Boot upgraded Linux system', 'Action: Restore To Factory Defaults', and 'Action: Upgrade System From Network'. The actions are handled through systemd unit services called in kernel command line.

I would like to add one more menu entry but this entry is hidden from users during boot. The purpose of this last menu entry is if an API triggers a 'network upgrade', then the default grub menu entry is changed to this hidden entry id and the system is rebooted and the network upgrade is handled from there on out by the system services booted from that hidden menu entry.

I've looked around the web and on the grub2.02 manual but could not find any specific commands to hide a grub menu entry id. Does anybody know a way to hide a grub menu entry id from users during boot?

Code:

set default=ulinux
set fallback=linux
set timeout=3
menuentry "Linux 4.4.26 x86_64" --id linux {
    search --no-floppy --fs-uuid 0493-E6D8 --set root
    linux /vmlinuz root=/dev/sda2  rw  console=ttyS0,115200 console=tty0 quiet
}
menuentry "Updated Linux 4.4.26 x86_64 - 20170607152653" --id ulinux {
    search --no-floppy --fs-uuid 0493-E6D8 --set root
    linux /vmlinuz root=/dev/sda4  rw  console=ttyS0,115200 console=tty0 quiet
}
menuentry "Action: Restore Linux System To Default Image" {
    search --no-floppy --fs-uuid 0493-E6D8 --set root
    linux /vmlinuz root=PARTUUID=d2acde84-1bfd-4a83-aee3-0cad05226017 systemd.unit=restore.service  rw  console=ttyS0,115200 console=tty0 quiet
}
menuentry "Action: Update Linux System Image From Network" {
    search --no-floppy --fs-uuid 0493-E6D8 --set root
    linux /vmlinuz root=PARTUUID=d2acde84-1bfd-4a83-aee3-0cad05226017 systemd.unit=update.service  rw  console=ttyS0,115200 console=tty0 quiet
}

The embedded system is a very minimal linux system and not a standard distro so I would like to stay clear of downloading tools like grub-customizer if possible.

Currently I only have a grub.cfg file and have noting else like /etc/default/grub or /etc/grub.d. If passing a command option to /etc/default/grub file, would allow a specific grub menu entry ID to be hidden, then this would be a viable option.

Any help, feedback, or suggestions would be greatly appreciated Cheers!

hydrurga 06-13-2017 12:11 PM

Quote:

Originally Posted by ezaluzec (Post 5722342)
then the default grub menu entry is changed to this hidden entry id and the system is rebooted.

How are you going to do this?

Could you use the same method to swap (and change names) grub.cfg with a grub.network (containing only the network upgrade boot option) before initiating a reboot and then swapping them back again after the network upgrade?

ezaluzec 06-13-2017 01:55 PM

Thanks hydrurga. Your proposed option definitely came to mind. I can have the API calls that trigger the system reboot to also switch a grub-network.cfg file to grub.cfg before reboot. Then once network upgrade is complete, have the grub.cfg's switched back by the same service that is handling the network upgrades. This should work fine.

I guess I was just wanting to see if I was missing any GRUB command options.

Closing issue.

hydrurga 06-13-2017 02:01 PM

Quote:

Originally Posted by ezaluzec (Post 5722402)
Thanks hydrurga. Your proposed option definitely came to mind. I can have the API calls that trigger the system reboot to also switch a grub-network.cfg file to grub.cfg before reboot. Then once network upgrade is complete, have the grub.cfg's switched back by the same service that is handling the network upgrades. This should work fine.

I guess I was just wanting to see if I was missing any GRUB command options.

Closing issue.

Ok, great. Of course an alternative way would be to programmatically comment in or out various lines in grub.cfg (using #'s), but I think the swap method is cleaner and safer.


All times are GMT -5. The time now is 02:33 PM.