Error: sparse file not allowed. - press any key to continue booting

Possibly the wrong category: I changed my /root partition to btrfs and changed /etc/deafult/grub as follows to select the last used kernel at boot:

GRUB_DEFAULT=saved
GRUB_SAVEDEFAULT=true

This worked fine with ext4, but with btrfs it gives the error message at boot time:

error: sparse file not allowed. - press any key to continue booting

I found out that under btrfs it is not possible to write to grub.env. Resetting the values to default helps, but I have to manually select my kernel every time I boot.

I followed the following tip on the net to reinstall GRUB, but that didn’t help either:

sudo grub-install --recheck --no-rs-codes --modules="btrfs part_gpt part_msdos"
sudo update-grub

Edit: Try this

GRUB_SAVEDEFAULT=false
GRUB_DEFAULT=0

So let me get this straight: with
GRUB_SAVEDEFAULT=false
GRUB_DEFAULT=0

I only achieve that there is no error message, but still the last selected kernel is not booted. How also, if that is avoided with it. I have the last LTS kernel as fallback 8at 1st and 2nd place in the grubloader, at 3rd place the CURRENT kernel to be booted. If I
GRUB_DEFAULT=2, the error message comes again. Sh. btrfs …

The best guy to ask is @2000 i think. I really know little about Btrfs setup. I found that on the Manjaro forum.

I found it there too … :wink:

Well it did say the error message was gone. :laughing:

You could always not use grub… :wink:

1 Like

Well you’re funny, what else should I take?

I found this:

The reason is the grub.env which is on a filesystem not writable by grub and grub config defaults to writing the selected entry to grub.env. To work around it edit your /etc/default/grub and change from

GRUB_SAVEDEFAULT=true
GRUB_DEFAULT=saved

To

GRUB_SAVEDEFAULT=false
GRUB_DEFAULT=0

OK, I’ve been there, so there’s no point in changing the grub.config. But how can I achieve that the kernel I preset boots?

The first boot entry is 0 so if you want the other one then it is 1

GRUB_DEFAULT=1

Edit: I assume the next one would be 2 and so on

grub isn’t the only bootloader. :slight_smile:

I remove it from all my installs.

1 Like

As soon as I write something other than 0 on GRUB_DEFAULT, I get the error message back. I’ve been searching the net for a solution for several hours now. Or I kick btrfs in the a… and take ext4 again.Too bad, I wanted it for the snapshots …

I have btrfs set up on mine but it was done with the wiki using quick copy and paste method.

Edit: I only have the current kernel and it is luks encryption with snapshots & timeshift.

I probably already did everything wrong during the setup. I should have created subvolumes, but my swap partition is still ext4. I’ll go to sleep now and think about it tomorrow, if the whole effort is worth it.

Well - immediately systemd boot and rEFInd come to mind (rEFInd for me). However, if you use grub to select between Timeshift snapshots, you might want to keep it. Of course, you can use rEFInd to boot the grub - but I’m not sure it gets around the difficulty you are having.

I think swap partition cannot be ext4…

1 Like

Tried this in a VM with a btrfs disk:

  • changed GRUB_DEFAULT=2 in /etc/default/grub
  • sudo grub-mkconfig -o /boot/grub/grub.cfg

And now it boots to linux instead of linux-lts. So here it works.

1 Like

You could always shrink the btrfs partition and add an ext4 boot partition.

The reason for the message originates in the fact that grub cannot write to grub environment file (/boot/grub/grubenv) - I am not using grub - so I may remember the name incorrect - but grub writes the last used entry to the environment file and because grub cannot write on btrfs you get this grub message.

Only way around it is to have your /boot mounted on a ext filesystem or disable the save function.

3 Likes

Wait, I have a boot partition in fat32 (boot-efi). Is THAT the reason? I just replace it with ext4?