Results 1 to 5 of 5

Thread: automatic grub2 choice on remote reboot

  1. #1
    Join Date
    Dec 2009
    Beans
    7

    automatic grub2 choice on remote reboot

    I'm trying to figure out if I can do a remote reboot (eg over ssh) and specify a new grub2 os choice for the next boot only (once), in order to boot windows remotely once, but then back to linux on the next reboot.

    I found this related post for grub, but won't work for grub2 ( I never tried it with grub for a remote reboot).

    http://sidvind.com/wiki/GRUB:_Boot_another_OS_once

    which suggests changing the default menu option with the once flag:

    [root@localhost ~]# echo "savedefault --default=2 --once" | grub --batch
    [root@localhost ~]# reboot

    I'm just starting to work with grub2 and am not at all clear whether I can do anything similar.

    BTW Ubuntu karmic and windows 7.

    thanks.
    Last edited by ricoPan; January 10th, 2010 at 10:44 PM. Reason: added ubuntu verision.

  2. #2
    Join Date
    Aug 2009
    Beans
    13

    Re: automatic grub2 choice on remote reboot

    I'm looking basically for exactly the same thing ...

    In my case I have a remote machine that I re-instelled using deb-bootstrap and I wanna try to boot into it just once and if something goes wrong reboot back into the old system... (obviously if something DOES go wrong I can't reconfigure anything)

    does anybody have a good idea on how to do this

    PS: there is absolutely no way that I can get phisical access to this machine ;/

  3. #3
    Join Date
    Jun 2010
    Beans
    1

    Thumbs down Re: automatic grub2 choice on remote reboot

    Here are the steps you need to do to achieve what you wanted.

    1. Modify /etc/default/grub like below
    GRUB_DEFAULT=saved
    2. Re-generate /boot/grub/grub.cfg as root
    grub-mkconfig > /boot/grub/grub.cfg
    3. Set your default OS to boot everytime, replace 0 with 1 for second OS, etc.
    sudo grub-set-default 0
    4. Set a different OS to boot into once only, replace 1 with 2 if you want to boot 3rd OS, etc.
    sudo grub-reboot 1
    5. (Optional) Change the entry below in /boot/grub/grub.cfg so that GRUB doesn't stay at the boot screen waiting for input after an abnormal shutdown.
    From:
    if [ ${recordfail} = 1 ]; then
    set timeout=-1
    else
    set timeout=10
    fi

    To:
    if [ ${recordfail} = 1 ]; then
    set timeout=1
    else
    set timeout=1
    fi

  4. #4
    Join Date
    Mar 2011
    Beans
    1

    Re: automatic grub2 choice on remote reboot

    Here's the simple and complete answer:

    Important note: Configuration changes are normally made to /etc/default/grub and to the custom files located in /etc/grub.d. The /boot/grub/grub.cfg file should not be edited by the user; changes to this file are made by configuration scripts. After editing /etc/default/grub, you need to run sudo update-grub for your changes to take effect on the next boot.
    Some of the most common changes, such as the default OS/kernel and menu timeout, can be changed from within a GUI app called StartUp-Manager. See the community doc StartUpManager for information about how to install and use this application.

    /etc/default/grub (file)


    • The main configuration file for changing default settings. Upon installation, the following lines are available for alteration by the user:
    • GRUB_BACKGROUND - Sets the background image, enter the full path to the image here. See splash image configuration above for further details.
    • GRUB_DEFAULT - Sets the default menu entry. Entries may be numeric, a complete menuentry quotation, or "saved"

      • GRUB_DEFAULT=0 Sets the default menu entry by menu position. As in GRUB, the first "menuentry" in grub.cfg is 0, the second is 1, etc.
      • GRUB_DEFAULT="xxxx" An exact menu entry, including the quotation symbols, may also be used. In this case, location in the menu will not matter. Example: GRUB_DEFAULT="Ubuntu, Linux 2.6.31-9-generic"
      • GRUB_DEFAULT=saved

        • The information in this section applies to GRUB 1.98 and later.
        • Enables the "grub-reboot" and "grub-set-default" commands to set the default OS.
        • The default OS will not be set by an interactive selection of an OS from the menu.
        • grub-set-default Sets the default boot entry until changed.

          • The format is sudo grub-set-default X, with X being the menu entry position (starting with 0 as the first entry) or the exact menu string. Examples: sudo grub-set-default 3 or sudo grub-set-default "Ubuntu, Linux 2.6.32-15-generic"
          • To obtain the existing menu entry choice number (starting from 0) or the menu entry "string", run grep menuentry /boot/grub/grub.cfg
        • grub-reboot This command sets the default boot entry for the next boot only. The format of the command is the same as for grub-set-default (see above).




    for the complete Guide refer to https://help.ubuntu.com/community/Grub2 Section "Configuration GRUB2"

  5. #5
    Join Date
    Apr 2011
    Beans
    1

    Re: automatic grub2 choice on remote reboot

    Thanks for the info - exactly what I was looking for. But, on the case exposed with a dual linux/Windows OS (and grub2 as boot loader), is there any way when I've booted on Windows to reboot next time on linux? Should I try to map the ext4 partition in Windows and manually modify the config files (since obviously update-grub or grub-mkconfig cannot be used there)? Any idea? Regards Timm

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •