[arch-general] How to choose which grub entry boots next from the cli via ssh in Arch?
Listmates, How do I choose which grub entry will boot the next time the machine is rebooted from the command line? In suse there is a package called 'grubonce' which you issue from the command line giving the grub entry you want to boot next. Example, if your menu.lst looks like: # (0) Arch Linux - The Ferarri of Distros title Arch Linux on SuperSFF root (hd0,7) kernel /boot/vmlinuz26 root=/dev/sda6 ro vga=0x317 initrd /boot/kernel26.img # (1) Arch Linux title Arch Linux Fallback root (hd0,7) kernel /boot/vmlinuz26 root=/dev/sda6 ro initrd /boot/kernel26-fallback.img # (2) Arch Linux LTS title Arch Linux LTS on SuperSFF root (hd0,7) kernel /boot/vmlinuz26-lts root=/dev/sda6 ro vga=0x31a initrd /boot/kernel26-lts.img I could issue: # grubonce 2 and Arch Linux LTS would be booted next. I thought the grubonce package was part of grub, but it isn't. Also, I don't need it for a local machine (obviously), but I need something I can use via ssh. What do we use here? -- David C. Rankin, J.D.,P.E. Rankin Law Firm, PLLC 510 Ochiltree Street Nacogdoches, Texas 75961 Telephone: (936) 715-9333 Facsimile: (936) 715-9339 www.rankinlawfirm.com
On 26.08.2009 04:44, David C. Rankin wrote:
Listmates,
How do I choose which grub entry will boot the next time the machine is rebooted from the command line? In suse there is a package called 'grubonce' which you issue from the command line giving the grub entry you want to boot next. Example, if your menu.lst looks like:
# (0) Arch Linux - The Ferarri of Distros title Arch Linux on SuperSFF root (hd0,7) kernel /boot/vmlinuz26 root=/dev/sda6 ro vga=0x317 initrd /boot/kernel26.img
# (1) Arch Linux title Arch Linux Fallback root (hd0,7) kernel /boot/vmlinuz26 root=/dev/sda6 ro initrd /boot/kernel26-fallback.img
# (2) Arch Linux LTS title Arch Linux LTS on SuperSFF root (hd0,7) kernel /boot/vmlinuz26-lts root=/dev/sda6 ro vga=0x31a initrd /boot/kernel26-lts.img
I could issue:
# grubonce 2
and Arch Linux LTS would be booted next. I thought the grubonce package was part of grub, but it isn't. Also, I don't need it for a local machine (obviously), but I need something I can use via ssh. What do we use here?
There are multiple ways: You can put "default 2" at the very top of your menu.lst which will always select the 2nd entry (0-based) by default. Another and maybe more modern way to do it is to add "default saved" at the top and then add "savedefault" below each individual entry. This way, Grub will always select the last selected entry.
On Tuesday 25 August 2009 09:51:50 pm Sven-Hendrik Haase wrote:
There are multiple ways: You can put "default 2" at the very top of your menu.lst which will always select the 2nd entry (0-based) by default. Another and maybe more modern way to do it is to add "default saved" at the top and then add "savedefault" below each individual entry. This way, Grub will always select the last selected entry.
Sven, Thanks, sorry, I know all that. I'm looking for a quick command that does NOT alter the menu.lst file, but sets some type of flag that tells grub do NOT boot the default entry, instead, boot entry 5. I know there is something in kde4 that will do it because when you hold-down the Restart option, you can set the next OS you want to boot if you have more than 1 entry in menu.lst. Ever hear of anything like that for Arch? With grubonce, you just enter grubonce (without arguments) and it returns a list of what is in your menu.lst file: [23:52 dcrgx/home/david/scripts/file] # grubonce 0: openSUSE 11.0 - 2.6.25.20-0.5 1: Failsafe -- openSUSE 11.0 - 2.6.25.20-0.5 2: openSUSE 11.1 - 2.6.27.19-3.2 (/dev/sdb1) 3: Windows Then all you have to do is issue the command: # grubonce 2 and you will boot suse 11.1 next time. That's what I'm looking for. I'll keep digging. -- David C. Rankin, J.D.,P.E. Rankin Law Firm, PLLC 510 Ochiltree Street Nacogdoches, Texas 75961 Telephone: (936) 715-9333 Facsimile: (936) 715-9339 www.rankinlawfirm.com
On Tuesday 25 August 2009 11:54:21 pm David C. Rankin wrote:
On Tuesday 25 August 2009 09:51:50 pm Sven-Hendrik Haase wrote:
There are multiple ways: You can put "default 2" at the very top of your menu.lst which will always select the 2nd entry (0-based) by default. Another and maybe more modern way to do it is to add "default saved" at the top and then add "savedefault" below each individual entry. This way, Grub will always select the last selected entry.
Sven,
Thanks, sorry, I know all that. I'm looking for a quick command that does NOT alter the menu.lst file, but sets some type of flag that tells grub do NOT boot the default entry, instead, boot entry 5.
I know there is something in kde4 that will do it because when you hold-down the Restart option, you can set the next OS you want to boot if you have more than 1 entry in menu.lst. Ever hear of anything like that for Arch?
With grubonce, you just enter grubonce (without arguments) and it returns a list of what is in your menu.lst file:
[23:52 dcrgx/home/david/scripts/file] # grubonce 0: openSUSE 11.0 - 2.6.25.20-0.5 1: Failsafe -- openSUSE 11.0 - 2.6.25.20-0.5 2: openSUSE 11.1 - 2.6.27.19-3.2 (/dev/sdb1) 3: Windows
Then all you have to do is issue the command:
# grubonce 2
and you will boot suse 11.1 next time. That's what I'm looking for. I'll keep digging.
A, hah! Should have checked in the first place. suse just uses a script. Here it is: #!/usr/bin/perl # Keep this sort of configurable for the future. $GRUBDIR="/boot/grub"; # Parse the menu file, and see if we can get a match for a maybe given arg. open(MENU, "<$GRUBDIR/menu.lst") || die "no menu.lst in $GRUBDIR"; $gotit = 0; $titleno = -1; $global_default = undef; while(<MENU>) { m,\s*default\s+(.+), && $titleno == -1 && ($global_default = $1); next unless m,\s*title\s+(.*),i; $title_name = $1; $titleno++; if (@ARGV > 0) { # Argument may be entirely numerical, in which case it is an index, # or a perl RE that leads to the first title matching. if (( $ARGV[0] =~ m,^[0-9]+$, && $titleno eq $ARGV[0] ) || ( $ARGV[0] !~ m,^[0-9]+$, && $title_name =~ m,$ARGV[0],i) ) { $gotit = 1; last; } } else { print "$titleno: $title_name\n"; } } close(MENU); print "Warning: you haven't set a global default!\n" if !defined($global_default); # Without a command line argument, we have now listet the titles and are done. exit 0 if @ARGV < 1; # Else the user wants to write the default file. We have better found a match! if ($gotit > 0) { print "Warning: your global default is 'saved'; changing default permanently!" if $global_default eq "saved"; print "Using entry #$titleno: $title_name\n"; # set the magic one-time flag $titleno |= 0x4000; open(DEFFILE, ">$GRUBDIR/default") || die "Cannot open default file for writing"; $buf = $titleno . "\0" . "\n" x 9; syswrite(DEFFILE, $buf, 10); close(DEFFILE); exit 0; } else { print $ARGV[0] . " not found in $GRUBDIR/menu.lst\n"; exit 1; } -- David C. Rankin, J.D.,P.E. Rankin Law Firm, PLLC 510 Ochiltree Street Nacogdoches, Texas 75961 Telephone: (936) 715-9333 Facsimile: (936) 715-9339 www.rankinlawfirm.com
On Wed, Aug 26, 2009 at 08:04, David C. Rankin<drankinatty@suddenlinkmail.com> wrote:
On Tuesday 25 August 2009 11:54:21 pm David C. Rankin wrote:
Thanks, sorry, I know all that. I'm looking for a quick command that does NOT alter the menu.lst file, but sets some type of flag that tells grub do NOT boot the default entry, instead, boot entry 5.
A, hah!
Should have checked in the first place. suse just uses a script. Here it is:
Instead of the script you could use grub-set-default. Here is more information: http://www.gnu.org/software/grub/manual/html_node/Invoking-grub_002dset_002d... http://www.gnu.org/software/grub/manual/html_node/Booting-fallback-systems.h... -- Roman Kyrylych (Роман Кирилич)
On Wed, Aug 26, 2009 at 13:56, Roman Kyrylych<roman.kyrylych@gmail.com> wrote:
On Wed, Aug 26, 2009 at 08:04, David C. Rankin<drankinatty@suddenlinkmail.com> wrote:
On Tuesday 25 August 2009 11:54:21 pm David C. Rankin wrote:
Thanks, sorry, I know all that. I'm looking for a quick command that does NOT alter the menu.lst file, but sets some type of flag that tells grub do NOT boot the default entry, instead, boot entry 5.
A, hah!
Should have checked in the first place. suse just uses a script. Here it is:
Instead of the script you could use grub-set-default. Here is more information: http://www.gnu.org/software/grub/manual/html_node/Invoking-grub_002dset_002d... http://www.gnu.org/software/grub/manual/html_node/Booting-fallback-systems.h...
This is more specific link: http://www.gnu.org/software/grub/manual/html_node/Booting-once_002donly.html -- Roman Kyrylych (Роман Кирилич)
On Wednesday 26 August 2009 05:58:23 am Roman Kyrylych wrote:
Instead of the script you could use grub-set-default. Here is more information: http://www.gnu.org/software/grub/manual/html_node/Invoking-grub_002dset_0 02ddefault.html http://www.gnu.org/software/grub/manual/html_node/Booting-fallback-system s.html
This is more specific link: http://www.gnu.org/software/grub/manual/html_node/Booting-once_002donly.htm l
Roman, Thank you for the link. That's excellent. That's what I love about Linux. There is always more than 1 way to skin the cat ;-) [ We now have two more pelts... ] -- David C. Rankin, J.D.,P.E. Rankin Law Firm, PLLC 510 Ochiltree Street Nacogdoches, Texas 75961 Telephone: (936) 715-9333 Facsimile: (936) 715-9339 www.rankinlawfirm.com
David C. Rankin wrote:
On Tuesday 25 August 2009 09:51:50 pm Sven-Hendrik Haase wrote:
There are multiple ways: You can put "default 2" at the very top of your menu.lst which will always select the 2nd entry (0-based) by default. Another and maybe more modern way to do it is to add "default saved" at the top and then add "savedefault" below each individual entry. This way, Grub will always select the last selected entry.
Sven,
Thanks, sorry, I know all that. I'm looking for a quick command that does NOT alter the menu.lst file, but sets some type of flag that tells grub do NOT boot the default entry, instead, boot entry 5.
I know there is something in kde4 that will do it because when you hold-down the Restart option, you can set the next OS you want to boot if you have more than 1 entry in menu.lst. Ever hear of anything like that for Arch?
With grubonce, you just enter grubonce (without arguments) and it returns a list of what is in your menu.lst file:
[23:52 dcrgx/home/david/scripts/file] # grubonce 0: openSUSE 11.0 - 2.6.25.20-0.5 1: Failsafe -- openSUSE 11.0 - 2.6.25.20-0.5 2: openSUSE 11.1 - 2.6.27.19-3.2 (/dev/sdb1) 3: Windows
Then all you have to do is issue the command:
# grubonce 2
and you will boot suse 11.1 next time. That's what I'm looking for. I'll keep digging.
David, When you find it, please respond to this thread as I'm also interested in finding a method such as you describe. -Tim
Tim Gelter wrote:
David C. Rankin wrote:
On Tuesday 25 August 2009 09:51:50 pm Sven-Hendrik Haase wrote:
There are multiple ways: You can put "default 2" at the very top of your menu.lst which will always select the 2nd entry (0-based) by default. Another and maybe more modern way to do it is to add "default saved" at the top and then add "savedefault" below each individual entry. This way, Grub will always select the last selected entry.
Sven,
Thanks, sorry, I know all that. I'm looking for a quick command that does NOT alter the menu.lst file, but sets some type of flag that tells grub do NOT boot the default entry, instead, boot entry 5.
I know there is something in kde4 that will do it because when you hold-down the Restart option, you can set the next OS you want to boot if you have more than 1 entry in menu.lst. Ever hear of anything like that for Arch?
With grubonce, you just enter grubonce (without arguments) and it returns a list of what is in your menu.lst file:
[23:52 dcrgx/home/david/scripts/file] # grubonce 0: openSUSE 11.0 - 2.6.25.20-0.5 1: Failsafe -- openSUSE 11.0 - 2.6.25.20-0.5 2: openSUSE 11.1 - 2.6.27.19-3.2 (/dev/sdb1) 3: Windows
Then all you have to do is issue the command:
# grubonce 2
and you will boot suse 11.1 next time. That's what I'm looking for. I'll keep digging.
David, When you find it, please respond to this thread as I'm also interested in finding a method such as you describe. -Tim
whoops, hadn't checked mail again before sending that last message. thanks for including your solution.
participants (4)
-
David C. Rankin
-
Roman Kyrylych
-
Sven-Hendrik Haase
-
Tim Gelter