Hi community,
I have a situation where I can access several VMs only by ssh.I have to update the kernel, but I don't want to lock myself out if the new kernel panics.
Here is my idea, but I can't make it to work.
1. Add "panic=10" to the kernel parameters (/etc/default/grub), in order to reboot on kernel panic after 10 seconds.
2. Enabling grub_default=saved in "/etc/default/grub" (Not sure if this is needed),so I can save the default entry.
3. Modify grub.cfg in such way that when selecting the newest kernel entry it will automatically change the default grub entry to an older kernel.If the VM gets into kernel panic and reboots - it should not select the newest kernel again.
4. Setting in crontab "@reboot root /sbin/grub2-set-default 0", so if the VM manages to boot successfully - the default kernel entry in grub to be set to the newest one.
If anyone has an idea how to do this, I will be really happy.
Thanks in advance.
GRUB2 Fallback
-
hunter86_bg
- Posts: 2019
- Joined: 2015/02/17 15:14:33
- Location: Bulgaria
- Contact:
-
hunter86_bg
- Posts: 2019
- Joined: 2015/02/17 15:14:33
- Location: Bulgaria
- Contact:
Re: GRUB2 Fallback
Ok, I think I found a solution.
1. Set "panic=10" for all kernels in "/etc/default/grub"
2. Set a fallback entry , in case grub fails to boot the newest kernel for some reason
3. Regenerate the grub menu:
4. Set default grub to an older entry:
5. Set to boot only 1 time to latest entry via
6. Reboot. If a kernel panic occurs and the kernel reboots - it will fall back to the default "1" - which should be our older kernel.
If anyone has a better solution - be my guest.
Edit: changed the order and added another step.
1. Set "panic=10" for all kernels in "/etc/default/grub"
2. Set a fallback entry , in case grub fails to boot the newest kernel for some reason
Code: Select all
echo "set fallback=1" >> /etc/grub.d/40_customCode: Select all
grub2-mkconfig -o /etc/grub2.cfgCode: Select all
grub2-set-default 1Code: Select all
grub2-reboot 0If anyone has a better solution - be my guest.
Edit: changed the order and added another step.
-
hunter86_bg
- Posts: 2019
- Joined: 2015/02/17 15:14:33
- Location: Bulgaria
- Contact:
Re: GRUB2 Fallback
I have tested this and everything is fine. Don't forget to , once you manage to boot the latest kernel.
Code: Select all
grub2-set-default 0