Maybe I'm missing something(ubuntu specific?), but I can't believe no one mentioned this simple obvious workaround yet (tested to work on Gentoo with btrfs /boot on separate partition):
GRUB_SAVEDEFAULT=false
in your /etc/default/grub
(must rerun Grub after this change, depending on your OS (I'm not on Ubuntu): ie. (Arch/Manjaro)$ sudo update-grub or (Gentoo)# grub2-mkconfig -o /boot/grub/grub.cfg )
Now the `error: sparse file not allowed.` is gone because there's no attempt made to write to the file /boot/grub/grubenv anymore, as were the case when GRUB_SAVEDEFAULT=true
Optionally, also avoid using GRUB_DEFAULT=saved unless you understand what it does if you do. I'm using GRUB_DEFAULT=0 (to have the cursor always be positioned on the first entry in the menu)
Cheers.
E.
I'm copy/pasting relevant `info grub` here to save you some time(in case you were not going to look this up anyway):
`GRUB_DEFAULT'
The default menu entry. This may be a number, in which case it
identifies the Nth entry in the generated menu counted from zero,
or the title of a menu entry, or the special string `saved'.
Using the id may be useful if you want to set a menu entry as the
default even though there may be a variable number of entries
before it.
Previously it was documented the way to use entry title. While
this still works it's not recommended since titles often contain
unstable device names and may be translated
If you set this to `saved', then the default menu entry will be
that saved by `GRUB_SAVEDEFAULT' or `grub-set-default'. This
relies on the environment block, which may not be available in all
situations (*note Environment block::).
The default is `0'.
`GRUB_SAVEDEFAULT'
If this option is set to `true', then, when an entry is selected,
save it as a new default entry for use by future runs of GRUB.
This is only useful if `GRUB_DEFAULT=saved'; it is a separate
option because `GRUB_DEFAULT=saved' is useful without this option,
in conjunction with `grub-set-default'. Unset by default. This
option relies on the environment block, which may not be available
in all situations (*note Environment block::).
15.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 (*note load_env::) loads
environment variables from it, and the `save_env' (*note save_env::)
command saves environment variables to it. From a running system, the
`grub-editenv' utility can be used to edit the environment block.
For safety reasons, this storage is only available when installed on
a plain disk (no LVM or RAID), using a non-checksumming filesystem (no
ZFS), and using BIOS or EFI functions (no ATA, USB or IEEE1275).
`grub-mkconfig' uses this facility to implement `GRUB_SAVEDEFAULT'
(*note Simple configuration::).
Maybe I'm missing something(ubuntu specific?), but I can't believe no one mentioned this simple obvious workaround yet (tested to work on Gentoo with btrfs /boot on separate partition):
GRUB_SAVEDEFAUL T=false
in your /etc/default/grub
(must rerun Grub after this change, depending on your OS (I'm not on Ubuntu): ie. (Arch/Manjaro)$ sudo update-grub or (Gentoo)# grub2-mkconfig -o /boot/grub/grub.cfg )
Now the `error: sparse file not allowed.` is gone because there's no attempt made to write to the file /boot/grub/grubenv anymore, as were the case when GRUB_SAVEDEFAUL T=true
Optionally, also avoid using GRUB_DEFAULT=saved unless you understand what it does if you do. I'm using GRUB_DEFAULT=0 (to have the cursor always be positioned on the first entry in the menu)
Cheers.
E.
I'm copy/pasting relevant `info grub` here to save you some time(in case you were not going to look this up anyway):
`GRUB_DEFAULT'
The default menu entry. This may be a number, in which case it
identifies the Nth entry in the generated menu counted from zero,
or the title of a menu entry, or the special string `saved'.
Using the id may be useful if you want to set a menu entry as the
default even though there may be a variable number of entries
before it.
For example, if you have:
menuentry 'Example GNU/Linux distribution' --class gnu-linux --id example-gnu-linux {
...
}
then you can make this the default using:
Previously it was documented the way to use entry title. While
this still works it's not recommended since titles often contain
unstable device names and may be translated
If you set this to `saved', then the default menu entry will be
that saved by `GRUB_SAVEDEFAULT' or `grub-set-default'. This
relies on the environment block, which may not be available in all
situations (*note Environment block::).
The default is `0'.
`GRUB_SAVEDEFAULT' saved'; it is a separate saved' is useful without this option,
If this option is set to `true', then, when an entry is selected,
save it as a new default entry for use by future runs of GRUB.
This is only useful if `GRUB_DEFAULT=
option because `GRUB_DEFAULT=
in conjunction with `grub-set-default'. Unset by default. This
option relies on the environment block, which may not be available
in all situations (*note Environment block::).
15.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 grub/grubenv' (although you should not assume
normally lives in `/boot/
this). At boot time, the `load_env' command (*note load_env::) loads
environment variables from it, and the `save_env' (*note save_env::)
command saves environment variables to it. From a running system, the
`grub-editenv' utility can be used to edit the environment block.
For safety reasons, this storage is only available when installed on
a plain disk (no LVM or RAID), using a non-checksumming filesystem (no
ZFS), and using BIOS or EFI functions (no ATA, USB or IEEE1275).
`grub-mkconfig' uses this facility to implement `GRUB_SAVEDEFAULT'
(*note Simple configuration::).