Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 23

Thread: Trying to save/remember last OS booted with 9.10 (Karmic Koala) and Grub2

  1. #11
    Join Date
    May 2009
    Location
    North West England
    Beans
    2,676
    Distro
    Ubuntu Development Release

    Re: Trying to save/remember last OS booted with 9.10 (Karmic Koala) and Grub2

    Hmm. it didn't save my choice of Win as last booted..... However, and next on my list of things to play with is this little snippet..

    • Custom entries can be added to the 40_custom file or in a newly created file. Based on its name, 40_custom entries by default appear at the bottom of the menu. A custom file beginning with 06_ would appear at the top of the menu since its alphanumeric sorting would place it ahead of 10_ through 40_ files.

    So, 06_ will always be ahead of any thing else ... Now, it can't update itself as to the last booted OS, but it seems like doing a manual entry into .lst from the grub legacy days.

    I hope drs305 has enjoyed his well deserved break to Egypt. It'll be nice to have him back, though

    Phill.

  2. #12
    Join Date
    Aug 2007
    Beans
    256
    Distro
    Xubuntu 22.04 Jammy Jellyfish

    Re: Trying to save/remember last OS booted with 9.10 (Karmic Koala) and Grub2

    Quote Originally Posted by darkod View Post
    Did you try ="saved"? I know it was without quotes in the instructions, but try it like that too.
    I just tried that, same behavior. As if it is set to =0.

    Since there is a bit of automagic partition detection with this new Grub, where does one look to see if savedefault is a behavior of a given menu choice?
    Michael Lueck

  3. #13
    Join Date
    Jan 2007
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: Trying to save/remember last OS booted with 9.10 (Karmic Koala) and Grub2

    Quote Originally Posted by mdlueck View Post
    I just tried that, same behavior. As if it is set to =0.

    Since there is a bit of automagic partition detection with this new Grub, where does one look to see if savedefault is a behavior of a given menu choice?
    The entry is stored in /boot/grub/grubenv, but it's not as simple as that.

    Warning: Geek alert. You may not wish to read any further.

    I played a bit with the "saved" setting when G2 first came out but haven't used it much since, and not with Windows.

    After stumbling on this thread about three hours ago, I've been testing the "saved" entry.

    The "saved" string is entered into /boot/grub/grubenv. If you change the default to "saved" and run update-grub, you won't see it immediately. The "saved" entry appears to be updated when a selection is made from the Grub 2 menu.

    For Windows, I just entered "saved" as the DEFAULT in /etc/default/grub, ran "sudo update-grub" and booted to Windows. While in Windows, I checked the contents of /boot/grub/grubenv and indeed it contained the Windows title. When I rebooted, Windows was the highlighted entry.

    Now a couple of interesting points. If you return to the G2 menu with Windows highlighted and change to Ubuntu, boot, and then check grubenv, it will now show "Ubuntu... " or whatever you just booted to. So the only way you would normally ever see the Windows entry in grubenv would be from within Windows (when Windows was the last booted entry).

    Secondly, "saved" would be better labeled "lastused" IMO. It is saved only if no other selection is made. If you make another selection from the menu, that item now becomes the "saved" entry.

    Another point: You can probably edit grub environment and place the title on the second line, EXACTLY as the string is depicted in grub.cfg (everything between the quotes), HOWEVER:: it appears grubenv must be exactly 1024 bytes. I've edited and saved it before and it generated an error message on boot saying it was an incorrect size. So if you edit it, it looks like it needs to be exactly 1024 bytes (add or subtract # symbols if not). Fortunately, there is a script to do this for you: grub-editenv run as root.

    You can view the current contents with this command:
    Code:
    sudo grub-editenv /boot/grub/grubenv list
    You can create a new, default grubenv file. For me, I have to delete the current /boot/grub/grubenv file before it will create the new one. This will also fix "environment" errors (if you delete the existing file first).
    Code:
    sudo grub-editenv /boot/grub/grubenv create
    To create a new saved default without having to boot into it first:
    Code:
    sudo grub-editenv /boot/grub/grubenv set saved_entry="Exact_menuentry_from_grub.cfg"
    sudo update-grub
    One final bit of geekiness: In Grub legacy, the "saved" setting was saved as the DEFAULT number (0,1,2,etc). If a new kernel was added automatically, it became 0 and you would no longer get your old kernel, even if it was "saved". G2 stores the "saved" value as a string, so even after an update, the older kernel would still be the "saved" one, if though it's position in the menu had dropped down one entry.

    Summary
    Here is how it should work:
    /etc/default/grub: DEFAULT=saved
    sudo update-grub
    Boot to Windows
    Windows should be highlighted the next time you boot.
    It should stay Windows until you select another OS.

    Here is what I'd try if "saved" isn't working:
    Remove /boot/grub/grubenv
    Create a new grubenv (see above)
    Add the exact Windows entry to grubenv using the grub-editenv set command (see above).
    Update grub.
    Reboot.
    See if the Windows entry is highlighted.

    If you always want to have Windows as the highlighted entry, use the Windows string in the DEFAULT setting of /etc/default/grub.
    Example:
    GRUB_DEFAULT="Microsoft Windows XP Home Edition (on /dev/sda1)"
    Then update grub.
    Last edited by drs305; December 21st, 2009 at 01:30 AM.
    Back to Xorg...

    Retired.

  4. #14
    Join Date
    Aug 2007
    Beans
    256
    Distro
    Xubuntu 22.04 Jammy Jellyfish

    Re: Trying to save/remember last OS booted with 9.10 (Karmic Koala) and Grub2

    Quote Originally Posted by drs305 View Post
    For Windows, I just entered "saved" as the DEFAULT in /etc/default/grub, ran "sudo update-grub" and booted to Windows. While in Windows, I checked the contents of /boot/grub/grubenv and indeed it contained the Windows title. When I rebooted, Windows was the highlighted entry.
    That is how I want it to work, however that is not how I am seeing it work.

    I hand install Windows at the front of the HDD, then install Ubuntu 9.10 beyond Windows on Extended / Logical. Ubuntu adds Windows to the bottom of the Grub menu.

    With these settings...

    Quote Originally Posted by drs305 View Post
    Summary
    Here is how it should work:
    /etc/default/grub: DEFAULT=saved
    sudo update-grub
    Boot to Windows
    Windows should be highlighted the next time you boot.
    It should stay Windows until you select another OS.
    Linux, the top Grub choice, is still active when Windows reboots.

    Quote Originally Posted by drs305 View Post
    If you always want to have Windows as the highlighted entry, use the Windows string in the DEFAULT setting of /etc/default/grub.
    Example:
    Quote:
    GRUB_DEFAULT="Microsoft Windows XP Home Edition (on /dev/sda1)"
    Then update grub.
    This does work, and is the workaround I am using since =saved is not working... thus the point of this thread.

    I have installed multiple systems with dual XP/Ubuntu, and all systems are working the same (wrong) way.
    Michael Lueck

  5. #15
    Join Date
    Jan 2007
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: Trying to save/remember last OS booted with 9.10 (Karmic Koala) and Grub2

    Quote Originally Posted by mdlueck View Post
    That is how I want it to work, however that is not how I am seeing it work.
    From within Windows, have you tried to view what's contained in Linux's /boot/grub/grubenv ? At least you can see if grubenv is storing the correct value.

    You could also check when the Grub 2 menu appears on a reboot after using Windows, by pressing "c" to get to the command line and then typing:
    cat (hdX,Y)/boot/grub/grubenv
    Finding out what value is stored in grubenv might be the first step in determining why it doesn't work for you.

    Note: I also know that if I have an improper entry listed as the default in G2 it will also always revert to the top menu item.
    Last edited by drs305; December 21st, 2009 at 02:48 AM.
    Back to Xorg...

    Retired.

  6. #16
    Join Date
    Aug 2007
    Beans
    256
    Distro
    Xubuntu 22.04 Jammy Jellyfish

    Re: Trying to save/remember last OS booted with 9.10 (Karmic Koala) and Grub2

    Quote Originally Posted by drs305 View Post
    From within Windows, have you tried to view what's contained in Linux's /boot/grub/grubenv ?
    How? The /boot partition is an ext4 filesystem.

    Quote Originally Posted by drs305 View Post
    You could also check when the Grub 2 menu appears on a reboot after using Windows, by pressing "c" to get to the command line and then typing:
    I will at least try that... that seems doable.

    Quote Originally Posted by drs305 View Post
    Note: I also know that if I have an improper entry listed as the default in G2 it will also always revert to the top menu item.
    If it is improper, then the Ubuntu 9.10 installer and/or Grub2 made the mistake.
    Michael Lueck

  7. #17
    Join Date
    Jan 2007
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: Trying to save/remember last OS booted with 9.10 (Karmic Koala) and Grub2

    As far as reading linux partitions from within Windows, Ext2Fsd is reported by some users to be able to read ext4 partitions.
    Back to Xorg...

    Retired.

  8. #18
    Join Date
    Aug 2007
    Beans
    256
    Distro
    Xubuntu 22.04 Jammy Jellyfish

    Re: Trying to save/remember last OS booted with 9.10 (Karmic Koala) and Grub2

    Quote Originally Posted by drs305 View Post
    You could also check when the Grub 2 menu appears on a reboot after using Windows, by pressing "c" to get to the command line and then typing:

    Finding out what value is stored in grubenv might be the first step in determining why it doesn't work for you.
    Using this method, the appropriate "Windows XP ..." string is set, throgh the selected menu entry was the top one, Ubuntu Linux.

    So at least Grub saved the last OS properly... trouble is picking it from the list at the next boot.
    Michael Lueck

  9. #19
    Join Date
    Jan 2007
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: Trying to save/remember last OS booted with 9.10 (Karmic Koala) and Grub2

    Just for reference, here are the applicable lines from grub.cfg for my Windows entry, when using "saved". They were copied from within Windows, or you could check with the cat command from the G2 command line before selecting the next OS:

    load_env
    set default="${saved_entry}"
    if [ ${prev_saved_entry} ]; then
    saved_entry=${prev_saved_entry}
    save_env saved_entry
    prev_saved_entry=
    save_env prev_saved_entry
    fi
    ...
    ...
    menuentry "Microsoft Windows XP Home Edition (on /dev/sda1)" {
    saved_entry=${chosen}
    save_env saved_entry
    insmod ntfs
    set root=(hd0,1)
    search --no-floppy --fs-uuid --set ceecff9eecff7f51
    drivemap -s (hd0) ${root}
    chainloader +1
    }
    And the grubenv first/second lines:
    # GRUB Environment Block
    saved_entry=Microsoft Windows XP Home Edition (on /dev/sda1)
    By the way, I couldn't get Ext2Fsd to read ext4 partitions from Windows.
    Back to Xorg...

    Retired.

  10. #20
    Join Date
    Aug 2007
    Beans
    256
    Distro
    Xubuntu 22.04 Jammy Jellyfish

    Re: Trying to save/remember last OS booted with 9.10 (Karmic Koala) and Grub2

    Understood.

    Since at the G2 command line the XP entry seems to be correctly indicated, I assume the trouble is in Grub selecting that entry from the list.
    Michael Lueck

Page 2 of 3 FirstFirst 123 LastLast

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
  •