Score:0

Linux - set next boot kernel

br flag

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!

muru avatar
us flag
Are some of these menu entries in a sub menu?
rogersjoshmac avatar
br flag
Yeah, when I reboot the server, it says "ubuntu" "advanced" and "memtest"
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.