Reboot (once) to selected different Grub2 boot partitions. Also label/reorder partitions in Grub2

When updating my 89-year old mother’s PC, I found it very useful to be able to reboot (one time only) from one boot partition direct to another partition on her PC.

Why ?

I live in Europe, and my mother lives in North America. I find this is very useful when I am accessing her PC remotely (from Europe, when her PC is in North America), and I need to access a different partition on her PC, and I do not want to ask her to reboot the PC.

To perform the reboot, I use the program ‘grub2-reboot’ that comes with grub2. The command is very basic (sent from a konsole in KDE) :


 grub2-reboot [option] MENU_ENTRY
 

where MENU_ENTRY is a number, a menu item title or a menu item identifier. Rather than possibly ‘fight’ with the syntax a menu item title, I chose instead to use the menu item # identifier.

This menu item # identifier is a number where the numbers correspond to the entries in the grub menu.

The number is relatively easy to deduce, just by looking at the Grub2 menu when the PC boots. For example, in the case of my mother’s PC, her grub2 boot entries are (approximately – in order):

  • Primary boot – openSUSE-13.2
  • Primary boot – Advanced options for openSUSE-13.2
  • Backup boot – openSUSE-13.2
  • Backup boot - Advanced options for openSUSE-13.2
  • Windows7 (on /dev/sdb1)
  • Windows7 (on /dev/sdb2)
  • Window Recovery
  • Old harddrive openSUSE-13.1
  • Old harddrive – Advanced options for openSUSE-13.1

To explain a bit, my mother’s PC has 3 separate openSUSE GNU/Linux installs (in separate partitions/drives) and a Windows7 install. The two openSUSE-13.2 installs are identical and are located in separate partitions on a new 1TB hard drive. The Windows7 install and the openSUSE-13.1 install are on on old hard drive that is giving some potential symptoms of failing, but has not failed yet.

The ‘new’ 1TB hard drive, I purchased last week for her PC, installed it in her PC (next to her old possibly failing hard drive) and put the two openSUSE-13.2 installs on that drive. In her PCs BIOS I setup that new hard drive as the ‘primary’ boot hard drive.

Why two openSUSE-13.2 installs (in addition to an old failing install) ? This way if one gets corrupted, she has a back up openSUSE-13.2 to boot to, in addition to having her old openSUSE-13.1 to boot to. Take a look at this blog entry which resulted in me adopting this approach: openSUSE Forums

Since I am in Europe and she is in North America, her having this additional redundancy makes the possibility of her not being able to boot her PC much less. If one of her partitions does have some corruption, there is a good chance when she boots to her backup, I can then log on to her PC remotely from Europe, and repair the failed hard drive partition.

But I want to keep all her openSUSE’s up to date (as long as there is support from SuSE-GmbH), and hence if she leaves her PC powered (in the Primary Boot – openSUSE-13.2) I want to be able to command a reboot to either of the other two openSUSE installs. I will then access those remotely and update those openSUSE versions. AND I do not need to bother her while I remotely perform these reboots and updates (from over 7000km away).

The ‘numbers’ (MENU_ENTRYs) I used for ‘grub2-reboot’ command were as follows:

  1. Primary boot – openSUSE-13.2
  2. Primary boot – Advanced options for openSUSE-13.2
  3. Backup boot – openSUSE-13.2
  4. Backup boot - Advanced options for openSUSE-13.2
  5. Windows7 – DO NOT USE - (on /dev/sdb1)
  6. Windows7 – DO NOT USE - (on /dev/sdb2)
  7. Window Recovery – DO NOT USE
  8. Old harddrive openSUSE-13.1
  9. Old harddrive – Advanced options for openSUSE-13.1

For example, to reboot to the ‘Backup boot’ … - After she has started the PC to the “Primary boot – openSUSE-13.2” (which is the default boot) she will then leave the PC running. Then I will conduct an update on the ‘Primary boot’, and then restart the PC to the Backup boot, using the commands (in a konsole) with root permissions:


 grub2-reboot 3
 shutdown -r now
 

and the PC will then reboot to the “Backup boot – openSUSE-13.2”. The next time I restart the PC, it will go back to its default “Primary boot – openSUSE-13.2”.

Wrt the Grub2 entry orders and labels, I used the GUI program “grub-customizer” to name the Grub2 entries and also to place the Grub2 entries in the order that I want to use.

The above is very basic, but I do find it quite useful.

Edit - I should note my mother’s partitions are EXT4. I have read grub2-reboot has some problems with btrfs (reference : Bug 856391 – grub2-reboot sets default boot entry permanently <==== where I do not know if that bug report has been fully addressed/fixed yet).

Dear Wolfgang!

What did you use for remote connection, ssh?

Hugo

As it turns out, I am not Wolfgang. We have more than one Wolfgang on this forum, who are more knowledgeable than I wrt GNU/Linux, so I may not be the person who can answer your questions.

I command ssh remotely using a terminal. I don’t use a GUI for setting it up. Instead, on my PC here in Europe, I open two konsole sessions and type in one:


ssh -t -L 5900:localhost:5900 mother@mothercpu.ipaddress.net 'x11vnc -localhost -nolookup -nopw -display :0'

where mothercpu.ipaddress.net is the mapped ip address of my mother’s pc, and ‘mother’ is her user name (these are arbitrary names chosen for illustrative purposes and not her real name). My mother’s router is setup to constantly map her IP address to “mothercpu.ipaddress.net” (again, that is chosen for illustrative purposes and is not her real router IP address mapped name).

My mother’s PC router is setup to route all port 22 traffic to her PC’s port 22. Hence after sending the above I obtain a request for a password. I then enter the password for user ‘mother’ on my mother’s PC.

I have the ssh daemon running on my mother’s PC, and I have port 22 open on her PC (ie ssh service in her firewall).

The above command starts x11vnc on my mother’s PC, and sends the output back to my PC here in Europe, encrypted, over the ssh port.

Then in the second terminal on my PC here in Europe I type:


vncviewer encodings "tight copyrect hextile" localhost:0

That will then display my mother’s PC desktop (in North America) here on my PC in Europe.
.