Grub can not remember the last selection

I want Grub to remember the last selection and have changed two lines in my /etc/default/grub file:

GRUB_DEFAULT=saved
GRUB_SAVEDEFAULT=true

After restarting, Grub refuses to remember my last selection and chooses the first default entry. Some messages show me “Sparse file not allowed”.

I have read some posts in the forum. They were unsolvable because of BTRFS or would be possibly too old. I use grub-btrfs, which works well with Btrfs Assistant.

I was wondering, does anyone know if the current state of grub version fixes this problem?

Possibly a silly question, but you have run sudo update-grub since you made the edit?

1 Like

This can´t be used with btrfs :cry:

Won´t fix

Because grub can read btrfs, but grub can´t write to btrfs.

https://wiki.archlinux.org/title/GRUB/Tips_and_tricks#Changing_the_default_menu_entry

:footprints:

3 Likes

I did, the problem still persists

Nope. I don’t think Grub maintainers would implement write support for many third-party filesystem drivers like Btrfs and Bcachefs. This requires a lot of work and complex solutions.

You are using the rolling release, now you have two different Btrfs versions: one in the Grub and another in the Kernel.
This is a risky approach, as a new major filesystem version in a future kernel could potentially break the Grub driver’s backward compatibility, leading to boot failure. For example, Btrfs would add a new fastest de/compression LZ4 in future, Grub can not read that.


Alternatively, limine bootloader can handle this.

If you’re looking for a Snapper boot solution with Limine, there’s a combination of two additional tools: limine-snapper-sync and limine-dracut-support-git from AUR, that provides this functionality.

  • limine-dracut-support-git uses Dracut for Limine and works similar to mkinitcpio and update-grub for Grub
  • limine-snapper-sync functions similarly to grub-btrfs for Grub, but it supports Snapper only.
2 Likes

The rEFInd UEFI Boot loader is a possible workaround for your issue.

Of course, this would involve making rEFInd the default bootloader, rather than Grub2. Grub2 would then be chainloaded by rEFInd; I have been doing exactly this for virtually as long as I’ve been multibooting.

Although I don’t use BTRFS, there are BTRFS UEFI drivers available which can be used https://efi.akeo.ie/.

Note that these drivers will not enhance or enable functionality for Grub2, but they will allow rEFInd to discover BTRFS volumes, and boot.

The rEFInd documentation explains how to boot the last selected OS, as default; which, as I recall, was the default setting in any case.

rEFInd:

Adding the rEFInd Bootloader to the mix does no harm to existing bootloaders. Manjaro and Windows are chainloaded from rEFInd and boot as normal.

If you enjoy customising the boot experience (themes), and like to have additional boot options (redundancy), rEFInd is a worthwhile consideration.

rEFInd can bypass GRUB 2 and boot the kernel stub directly, which is handy in the event that GRUB 2 fails to boot - you are still able to then boot into Manjaro and fix the issue in relative comfort.

rEFInd comes with ‘sane defaults’ - everything typically works (OOTB).

Installing rEFInd on a Manjaro/Windows multiboot system should give the following boot choices by default (the naming may be different):

  • Boot Microsoft EFI boot from ESP
    This option boots Windows via the Microsoft bootloader.
  • Boot EFI\Manjaro\grubx64.efi from ESP
    This option boots Manjaro via GRUB 2.
  • Boot boot\vmlinuz-6.6-x86_64 from MANJARO
    This option boots Manjaro via the Kernel stub, bypassing GRUB 2.
Options display as icons; activate with keyboard/mouse:

refind_1024

See also: The rEFInd Boot Manager: Methods of Booting Linux.


The simplest way to see rEFInd in action is to install it;

# Install rEFInd from the official Manjaro repo
sudo pacman -S refind

# Use rEFInd's own tool to setup the ESP directory
sudo refind-install
The ESP directory layout will be similar to:
$ESP
└─ EFI
    ├─ boot
    ├─ manjaro
    ├─ microsoft
    └─ refind
  • Reboot.
1 Like

They look interesting to me. I want to try converting from Grub to Limine, but their documentation on Gitlab says I need more than 1 GB of ESP to store multiple kernel versions.

I planned to shrink my SWAP partition from 16 GB to 12 GB and create a new 4 GB partition for Limine bootloader.

Is this partition size okay?

How can I setup these Limine tools correctly without breaking anything?

4 GB would probably be fine if you are not using Nvidia module or other large DKMS modules for kernel.

On my laptop without Nvidia, I have a 2 GB partition that is 41% full. It contains 3 multi boots and 22 different boot files (kernel & initramfs) for an crazy total of 104 snapshots. Each snapshot uses only one kernel version without fallback due to deduplication.


You do not have to convert Grub to Limine. But you can have two bootloaders.

If Limine works for you, you can remove Grub later.


  1. Your SWAP UUID is outdated after resizing your SWAP. You need to edit UUIDs in fstab to match the new SWAP and the new ESP with FAT32 format. The ESP is mounted to /efi

  2. Make sure that the flag is set as “boot” for the ESP partition.

  3. Run sudo mkdir -p /efi/EFI/BOOT/

  4. Just install limine-dracut-support-git

  5. Reinstall limine (because its EFI image will be copied to /efi/EFI/BOOT/ by limine-dracut-support-git)

  6. Install limine-snapper-sync. After installation, edit /efi/limine.conf to add a keyword /Snapshots at the end of an empty line.

  7. Enable systemctl enable --now limine-snapper-watcher


Note: If you need to configure kernel parameters, copy them from GRUB_CMDLINE_LINUX_DEFAULT in /etc/default/grub to a new empty file: /etc/kernel/cmdline and make your adjustments there.

After that, run dracut-rebuild to update limine.conf and rebuild initramfs.

1 Like

Fantasy, simple setup.

I add remember_last_entry: yes to the Limine config.

That works as expect what I want. :star_struck:

1 Like

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