How to get grub2 to remember last choice?

1

Grub2 - Community Ubuntu Documentation says the following:

Saving an OS can be achieved by running sudo grub-set-default if DEFAULT=saved is set in /etc/default/grub. It may also be saved if GRUB_SAVEDEFAULT=true is also set in /etc/default/grub. In this case, the default OS remains until a new OS is manually selected from the GRUB 2 menu or the grub-set-default command is executed.

I put the lines DEFAULT=saved AND GRUB_SAVEDEFAULT=true in /etc/default/grub, and ran sudo grub-set-default. Here is the output:

$ sudo grub-set-default entry not specified. Usage: grub-set-default [OPTION] entry Set the default boot entry for GRUB. -h, --help print this message and exit -v, --version print the version information and exit --boot-directory=DIR expect GRUB images under the directory DIR/grub instead of the /boot/grub directory ENTRY is a number or a menu item title. Report bugs to .

Am I not following the documentation correctly?...

0 0
2

I was having trouble with this using Arch as a VirtualBox guest. The issue turned out to be my use of LVM.

Again, from the GRUB Manual:

13.2 The GRUB environment block

It is often useful to be able to remember a small amount of information from one boot to the next. For example, you might want to set the default menu entry based on what was selected the last time. GRUB deliberately does not implement support for writing files in order to minimise the possibility of the boot loader being responsible for file system corruption, so a GRUB configuration file cannot just create a file in the ordinary way. However, GRUB provides an “environment block” which can be used to save a small amount of state.

The environment block is a preallocated 1024-byte file, which normally lives in /boot/grub/grubenv (although you should not assume this). At boot time, the load_env command (see load_env) loads environment variables from it, and the save_env (see save_env)...

0 0
3

How many times have you rebooted from Linux to load Windows? Those that dual-boot their system have done this quite a lot. The thing about dual-booting is that it relies heavily on the Grub bootloader and its entries. This gets worse when you realize that Windows has to restart a lot as it updates.

The result is users load windows, updates, and find themselves in Linux (or another installed operating system) thanks to Grub’s terrible default settings. Not to worry! There’s a way to set Grub to remember where you last left off! This means when you load Windows (or any operating system), and it restarts, it’ll load it again!

Note: for more tips and tricks on Grub, don’t forget to take our Grub Mastery course.

Before any configurations changes are made, it is a good idea to back up all Grub configurations just in case anything goes wrong. Assuming you are currently running Linux in your machine, start off by opening a terminal and making a backup...

0 0
4

The GRUB2 boot loader can seem confusing at first. Instead of one configuration file, there are several. You run one command update-grub to update the configuration file, another command (grub-install) to write the configuration to the Master Boot Record (MBR) on your hard drive.

On the plus side, GRUB2 can make life much easier if you’re running a dual or multiple boot system – say, switching between Linux and Windows, or hopping between multiple distros. update-grub scans your partitions, automatically detects operating systems, and adds them to the configuration. Yet, the choice of which OS to boot by default remains stupid: in Ubuntu 10.04, the menu highlights the first operating system listed (usually the latest kernel installed by Synaptic or Update Manager). If you don’t select another one within 10 seconds, the Ubuntu OS will boot with that kernel. I think most users want a “sticky” menu selection that boots the very last OS they chose. If you were running Windows XP...

0 0
5
Edite 28/11/2011 - Grub2 has been under some intense development resulting some commands structures altered slightly. In an error is encountered using the commands listed here please check with the latest documentation by typing "man" in front of the command that you want to use. Also the best information is the GNU/Grub2 Manual V 1.99.

Introduction

I notice Grub2 has been shipped by the latest Ubuntu so I have a played with it and reported the following.

For those who are already aware Grub has an unique feature that you can communicate with it before an operating system is booted. The instruction to talk to Grub is given in any text Grub menu screen by pressing the "c" key and return. Then you will be greeted by a command prompt known as Grub prompt. In this mode Grub has an command interpretor very much like Dos or any mini operating system. Both Grub1 and Grub2 have such capability. The biggest secret in Linux I have found is that there in no installed operating...

0 0
6

In the original Grub you'd do this by setting, in /boot/grub/menu.lst, the default keyword to "saved" and then using the savedefault keyword in each boot menu entry.

Updated:
Grub2 is a little more complicated. It's also still evolving, so even though Ubuntu 9.10 and 10.04 both use Grub2, there are enough differences in how things are packaged and configured to make things interesting.

Here's how to do the savedefault trick in both:

Ubuntu 10.04:
The 9.10 directions are a trick; Lucid is much simpler. See Ubuntu's help for more gory details. You need to make two changes in /etc/default/grub:

Change the line that reads GRUB_DEFAULT=0 to GRUB_DEFAULT=saved

Add a line with GRUB_SAVEDEFAULT=true

That's it. Actually isn't that bad, is it? Don't forget to run sudo update-grub.

Ubuntu 9.10:
There are several hacks on the Ubuntu forums for getting this to work; apparently the savedefault keyword was buggy in Grub v1.97....

0 0
7

This question was already asked once but it hasn't helped me in my trouble.

I have Ubuntu and Windows 7 on my laptop. Usually I use Windows 7 but GRUB always boots Ubuntu by default. My /ect/default/grub contains the following lines:

GRUB_DEFAULT=saved GRUB_SAVEDEFAULT=true

I did run sudo update-grub after I changed the values for these variables. Also I made sure that my grubenv file existed and had right permissions (with save_env GRUB command).

And still... it doesn't work! GRUB alwas intends to load Ubuntu despite I choosed Windows last time.

What else do I lose sight of?

BTW, I don't have neither RAID nor LVM volumes (at least I don't have LVM manager installed).

You can use Grub Customizer for the work it's very simple, just check the box to remember last choice, install it with the commands:

sudo add-apt-repository ppa:danielrichter2007/grub-customizer sudo apt-get update sudo apt-get install grub-customizer

Press Alt+F2 type...

0 0
8

Note: This is an RHCSA 7 exam objective.

Presentation of GRUB2

GRUB2 is the new Linux bootloader. GRUB2 stands for GRand Unified Bootloader version 2.

As GRUB was not maintained for some time and lacked some critical features like GPT management needed to handle disks bigger than 2.4TB, it was decided to start a new version from scratch with modularity in mind.

GRUB2 provides the following new features:

ability to boot on various file systems (xfs, ext4, ntfs, hfs+, raid, etc), gzip files decompression on the fly, management of all disk geometries, support for GPT (GUID Partition Tables) and MBR (Master Boot Record), portability with different architectures (BIOS, EFI, Coreboot, etc), ability to load modules at execution time.

GRUB2 Organization

The GRUB2 configuration is spread over several files:

/boot/grub2/grub.cfg: this file contains the final GRUB2 configuration (do not edit it directly!), /etc/grub2.cfg: this is a...
0 0
9

I'm currently trying out various distros so when I boot up my laptop I have several OS to choose from. Usually, all those distros install grub2 and locate themselves at the top of the list so they're the default ones to boot up after the installation is complete.

But Manjaro did something different. It installed some version of grub2 that would remember which distro I booted last time and kept booting that one (upon restart) until I selected another one (and then it would boot that one and so on).

Did I imagine this? Does Manjaro actually do that? If so, how can I install that version of grub to my system? Cheers.

This is my /etc/grub.d/40_custom file:

#!/bin/sh exec tail -n +3 $0 # This file provides an easy way to add custom menu entries. Simply type the # menu entries you want to add after this comment. Be careful not to change # the 'exec tail' line above.

and this is my /etc/default/grub file:

# If you change this file, run 'update-grub'...
0 0
10

I have two disks in my box - one is slow - the other is fast. Unfortunately I installed mint on the slow disk. I cloned the mint partion and had some issue to get the second cloned partition to boot but finally solved the issue (see

this thread

for details). Now I can boot by mint on the faster disk - but I still use grub2 on the slow disk. Actually I want to remove the slow disk from my box. I'm new to grub2 - with grub that's quite easy. Just copy menu.lst install grub on the faster disk in the MBR and remove the slow disk or wipe out the MBR on the slow disk. grub2 is much more complicated. What's your suggested way to migrate the grub2 config from my slow mint partition/disk to my fast mint partition/disk and finally remove the slow disk from my...

0 0
11

Recently most of the leading Linux distributions have moved to GRUB2 Boot loader. It has a long list of features. Given that it has some learning curve also. Since it is a boot loader, not an user space application, we don’t care about it till it puts us in rescue prompt :-).

As usual today I was playing with my laptop and resulted in GRUB rescue prompt. I mean when I boot my laptop, I was not welcomed with GRUB menu, instead with a rescue prompt. I tried grub1 commands in this shell, but unfortunately it did not respond to any command positively. Then I learned about GRUB2 commands and able to get into my Linux installation (Debian wheezy) without any Live CD or other OS installation. So I thought of sharing the commands I used at rescue prompt to boot successfully into the existing Linux installation.

Here is the snapshot of my grub rescue prompt session. I believe this will be sweet and short. Enter the following command in sequence. I have given (hdx,y) as generic...

0 0
12
alright, so I tried a number of things: pressing it once right after POST, continually pressing it after POST, holding it down after POST, alternating 'shift' and the 'up' key, holding the 'shift' key while I am continually pressing the 'up' key, all of the above during post from power-on during POST and to win7. None of them worked.

Here is what I am seeing:

If I power-on and don't press a thing, my machine goes through a normal POST then right into loading win7. If I press ESC or 'shift' during or right after post, when GRUB would normally load, in the upper left corner I see for maybe a total of 1 second, "Loading Grub", or something to that affect (basically it states that it is loading the grub menu, that is the jist) but then win7 starts to load. I don't see the menu. I don't see the splash screen, nothing. Just those words then BAM, win7 loading. Now, if I continually press the 'shift' key after post and when grub should load, I will see those words but if I continue...

0 0
13

This page provides the user with information on options available for repairing GRUB 2 boot issues and specific instructions on how to use the GRUB 2 terminal. The instructions are written for GRUB 1.99, which is the version of GRUB 2 which is included on Ubuntu 11.04, Natty Narwhal, and later. Differences for version 1.98 (Ubuntu 10.4, Lucid Lynx) are noted when the procedures differ.

GRUB 2's ability to fix boot problems is greatly improved over the original GRUB bootloader. In addition to an automatic fallback mode if booting from a menuentry in a submenu, GRUB 2 allows the user to edit its menu before the operating system is loaded. The rescue mode GRUB 2 terminal can help boot an operating system so that permanent repairs to system files can be made.

The instructions on this page are written for a fully-installed Ubuntu operating system. WUBI boot problems are not covered in detail although they are addressed in several sections.

GRUB 2 boot...

0 0