LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-13-2017, 11:33 AM   #1
ezaluzec
LQ Newbie
 
Registered: Jun 2017
Posts: 3

Rep: Reputation: Disabled
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!
 
Old 06-13-2017, 12:11 PM   #2
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 20 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2918Reputation: 2918Reputation: 2918Reputation: 2918Reputation: 2918Reputation: 2918Reputation: 2918Reputation: 2918Reputation: 2918Reputation: 2918Reputation: 2918
Quote:
Originally Posted by ezaluzec View Post
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?
 
Old 06-13-2017, 01:55 PM   #3
ezaluzec
LQ Newbie
 
Registered: Jun 2017
Posts: 3

Original Poster
Rep: Reputation: Disabled
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.
 
Old 06-13-2017, 02:01 PM   #4
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 20 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2918Reputation: 2918Reputation: 2918Reputation: 2918Reputation: 2918Reputation: 2918Reputation: 2918Reputation: 2918Reputation: 2918Reputation: 2918Reputation: 2918
Quote:
Originally Posted by ezaluzec View Post
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] GRUB2 New menu entry pointing to USB drive id2205 Linux - Software 13 06-21-2016 12:52 PM
grub2 boots only a single entry sustik Linux - General 2 01-10-2015 12:00 PM
LXer: Windows entry disappeared in Grub2 menu LXer Syndicated Linux News 0 10-19-2011 01:01 AM
Adding a menu entry to grub2 Jeff91 Linux - General 1 08-28-2009 06:12 PM
How to add e menu entry to KDE start menu over CLI browny_amiga Linux - General 7 02-08-2009 03:05 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:09 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration