Skip to content

add submenu for grub #13

Merged
merged 1 commit into from
Sep 27, 2017
Merged

add submenu for grub #13

merged 1 commit into from
Sep 27, 2017

Conversation

david
Copy link
Contributor

@david david commented Aug 16, 2017

No description provided.

@donald
Copy link
Collaborator

donald commented Aug 18, 2017

This has the problem, that it always switches to the default kernel, because the kernel selected by the last boot or "mxgrub KERNEL" is inside the submenu if it is not the default kernel.

https://www.gnu.org/software/grub/manual/grub.html#default

If the entry is in a submenu, then it must be identified using the number, title, or id of each of the submenus starting from the top level, followed by the number, title, or id of the menu entry itself, with each element separated by ‘>’

@donald
Copy link
Collaborator

donald commented Aug 18, 2017

What about

menuentry "DEFAULT (mariux-4.9.38-164)" id="mariux-4.9.38-164" --unrestricted { save_env chosen ; linux /boot/bzImage.x86_64 crashkernel=256M root=LABEL=root ro ; initrd /boot/grub/initramfs.igz }
menuentry "mariux-4.9.38-164" --unrestricted { save_env chosen ; linux /boot/bzImage-4.9.38.mx64.164 crashkernel=256M root=LABEL=root ro console=ttyS1,115200n8 console=tty0 ; initrd /boot/grub/initramfs.igz }
menuentry "mariux-4.9.32-159" --unrestricted { save_env chosen ; linux /boot/bzImage-4.9.32.mx64.159 crashkernel=256M root=LABEL=root ro console=ttyS1,115200n8 console=tty0 ; initrd /boot/grub/initramfs.igz }
menuentry "mariux-4.9.31-157" --unrestricted { save_env chosen ; linux /boot/bzImage-4.9.31.mx64.157 crashkernel=256M root=LABEL=root ro console=ttyS1,115200n8 console=tty0 ; initrd /boot/grub/initramfs.igz }
menuentry "mariux-4.4.70-156" --unrestricted { save_env chosen ; linux /boot/bzImage-4.4.70.mx64.156 crashkernel=256M root=LABEL=root ro console=ttyS1,115200n8 console=tty0 ; initrd /boot/grub/initramfs.igz }

?

@donald
Copy link
Collaborator

donald commented Sep 19, 2017

Let's assume this is installed on the distmaster and mxgrub --update is run there (e.g. after a kernel install). Now a new grub.cfg is written and pushed around.

However, the individual system will still have their old grubenv. This contains (e.g.) chosen=mariux-4.9.48-175 . A reboot of such a system would unexpectedly boot into the default kernel, because chosen=mariux-4.9.48-175 is no longer valid. The new grub.cfg would boot the old kernel only with chosen=all-other-kernel>mariux-4.9.30-155 in the grubenv.

@david
Copy link
Contributor Author

david commented Sep 26, 2017

That's right.
Then after installation, do this

vers=`grub-editenv list |cut -d"=" -f2`
./mxgrub $vers

mxgrub/mxgrub Outdated
} else {
/^chosen=(.+)/ and return $1;
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this could be reduced to

 while (<$p>) {
     /^chosen=(?:all-other-kernel>)?(.+)/ and return $1
 }

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we need to do ./mxgrub $(grub-editenv list |cut -d"=" -f2) one every system after the dist of the updated grub.cfg anyway, we could even ignore the old chosen=(.+) variant and match the newchosen=all-other-kernel>(.+) variant only.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But when you use
mxgrub default
and after that (without reboot)
mxgrub --list
you don't see the chosen one
But the shorter one is cool

mxgrub/mxgrub Outdated
if [ \$chosen ]; then
set default=\$chosen
unset chosen # must be clear to get a clean value from menuentry
fi
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

white space change intended?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah right
That's not what I want.
I changed it back

@david david force-pushed the grub-submenu branch 5 times, most recently from 0d4e217 to 5b194e1 Compare September 26, 2017 14:36
@donald donald merged commit ed2336b into master Sep 27, 2017
@donald donald deleted the grub-submenu branch September 27, 2017 10:07
@donald
Copy link
Collaborator

donald commented Sep 27, 2017

already disted it and fixup mxgrub $(grub-editenv list |cut -d"=" -f2) run on all nodes

Sign in to join this conversation on GitHub.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants