0

I have multiple kernels installed. I'm trying to create a script that would temporarily set the the next boot to the stock Ubuntu kernel.

From my online research, I understood that the kernel order is the result of the following command awk -F\' '/menuentry / {print $2}' /boot/grub/grub.cfg, where the first line is 0.

This is the output when I run the command:

root@server150:~# awk -F\' '/menuentry / {print $2}' /boot/grub/grub.cfg  
Ubuntu
Ubuntu, with Linux 4.9.24
Ubuntu, with Linux 4.9.24 (recovery mode)
Ubuntu, with Linux 4.4.0-81-generic                    # <- I want this
Ubuntu, with Linux 4.4.0-81-generic (recovery mode)
Memory test (memtest86+)
Memory test (memtest86+, serial console 115200)

Since I need the fourth line, I ran grub-reboot 3.

However, this boots into a memtest.

Am I doing something wrong? How can I create a script that when executed, would always set the next boot to the stock kernel?

PS: I'm eventually doing it in ansible, but since I couldn't find a module for it, I'm using bash.

Thanks ahead!

0 Answers0