Question about /etc/default/grub

I have a question about a setting in grub: It is about the line

# GRUB_SAVEDEFAULT=true

Does it make a difference if # GRUB_SAVEDEFAULT=true is only commented out or if it says GRUB_SAVEDEFAULT=false? The result is probably the same in either case, right?

The difference is that the commented out version will apply the default value.

Setting it to “false” will always set it to false no matter what the default value is.

Default values can change over time from upstream. So the question is do you want the default value or do you want it to be false?

2 Likes

For the intended result that the last booted kernel is NOT remembered, it is probably better if the value is permanently false, right?

I think you need to have these two lines in /etc/default/grub in order for Grub to remember the last booted entry:

GRUB_DEFAULT=saved
GRUB_SAVEDEFAULT=true

And then re-configure grub.cfg.

1 Like

I am sorry, I totally miss-interpreted your intention. Please ignore my previous post!

:woman_facepalming:t5:

Personally, I prefer it to be set to true, so that I only have to choose once which kernel I want to boot. I’m using linux-lts at the moment, but I also have linux (mainline) and linux-zen installed. I like the fact I don’t have to pick on every boot which kernel I want to use, but I can easily change it.

1 Like

I set this with GRUB_DEFAULT=0.

Here is why I don’t like that. Let’s assume 0th on the list of boot options in GRUB is the kernel I normally use, say it’s linux-zen, just as an example. That works fine, I normally want to boot this kernel. But let’s say an update causes something to render linux-zen unbootable, but the computer boots fine with linux-lts. So, for the next few days until the problem is fixed in another update, I want to boot linux-lts, which is not 0th on the list of kernels in GRUB. That’s a pain, because now I have to select the kernel on every single boot. Or I have to reconfigure GRUB (and then reconfigure it again, when I want to switch back to the original kernel I was using).

However, if I set

GRUB_DEFAULT=saved
GRUB_SAVEDEFAULT=true

that’s not a problem anymore. Now, I only have to select linux-lts once, until I decide to switch back to linux-zen.

4 Likes

You are undoubtedly right, that is a good consideration :+1:t2:

I tried setting this on mine and i get an error that say’s cannot use sparsed file or something just before loading. Trying to figure out what I’m doing that it gives this error message. I can still boot into the kernel?

Edit: Here is my default grub

https://clbin.com/E7jy4

IIRC that doesn’t work with btrfs. Is that your filesystem?

1 Like

Following this thread, I am beginning to be a bit confused about the initial intention of @Balder:

or as the

GRUB_DEFAULT=saved
GRUB_SAVEDEFAULT=true

suggests that it will effectively be remembered?

Yes…

My intention should be recognizable from my input post. Everything that was suggested afterwards has arisen incidentally. I just wanted to know if it makes a difference to comment out said line or to set it to false. I don’t have the slightest idea about programming.

And NO, I didn’t originally want grub to remember the last kernel (which wouldn’t work with btrfs either, if I ever got carried away using it). That’s why my approach is to set the kernel to boot in grub. For ext4, @Kresimir 's method is probably better. But as I said, my question has already been answered, thx @dalto :slight_smile: .

1 Like

If you have some free time then this setup solves many issues.

  • Snapshots have kernel and initrd included.
  • Snapper works like breeze.
  • As grub config are now written on esp, so grub can remember last saved entry.

I don’t use luks2, so can’t verify about that but rest all works.

1 Like

Two things:
First, that setup won’t resolve the issue @ricklinux is referring to above.

Second, the setup he is using is pretty much the default setup on EndeavousOS already. “The problem” as he calls it, is a problem he created himself by mounting ESP at /boot when using grub.

With EOS, you could achieve the more or less the same setup by selecting btrfs and encryption in the installer and then installing grub-btrfs post-install. There would be no reason to do all that manually.

3 Likes

My mistake mate. Completely misunderstood the situation.
I did manual installation on my machine and completely forgot EOS setups up everything already.
For now, I will just leave that up there for posterity sake. If you want then take it down.

2 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.