Bug 27117 - If rootfs is btrfs, and /boot is on rootfs, grub complains about ../../grub-core/commands/loadenv.c:216:sparse file not allowed.
Summary: If rootfs is btrfs, and /boot is on rootfs, grub complains about ../../grub-c...
Status: NEW
Alias: None
Product: Mageia
Classification: Unclassified
Component: Installer (show other bugs)
Version: Cauldron
Hardware: All Linux
Priority: Normal normal
Target Milestone: ---
Assignee: Mageia tools maintainers
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 22582
Blocks:
  Show dependency treegraph
 
Reported: 2020-08-14 19:15 CEST by Aurelien Oudelet
Modified: 2021-04-19 18:23 CEST (History)
5 users (show)

See Also:
Source RPM:
CVE:
Status comment:


Attachments

Description Aurelien Oudelet 2020-08-14 19:15:27 CEST
mageia 8 beta 1 Classic ISO Installer.

partitions configured as this:
/boot/EFI is on /dev/nvme0n1p1 formated fat32
/ is on /dev/nvme0n1p2 formated btrfs
/var is on /dev/sda3 formated ext4
/home is /dev/sda2 formated xfs
swap is /dev/sda1

Installation is OK and runs to end. But at first reboot:
Grub2 complains about:
-------------------
error: ../../grub-core/commands/loadenv.c:216:sparse file not allowed.
Press any key to continue...
-------------------
After, system boots fine.

Analyzing:
Seems that if /boot is on rootfs (not in a separated partition), grub2 complains as he can't save which is booted. (GRUB_DEFAULT=saved and GRUB_SAVEDEFAULT=true)

I think in installer, we should prevent such configuration or disable saving booting entry.

See 22582.

Workaround:
https://forum.manjaro.org/t/solved-grub-btrfs-error-sparse-file-not-allowed/70031
Comment 1 Aurelien Oudelet 2020-08-14 19:21:39 CEST
Assigning to Mageia Tools maintainers.

I solved my problem by reinstalling and creating a separate /boot ext4 partition.

Workaround proposed above needs to edit /etc/default/grub as root and it is not trivial for "Mme Jane Doe" user...

I do think installer should prevent installing with / as btrfs and without /boot separated.
Comment 2 Florian Hubold 2021-03-03 14:53:46 CET
(In reply to Aurelien Oudelet from comment #1)

> I do think installer should prevent installing with / as btrfs and without
> /boot separated.

Why do you think so? /boot does not need to be a separate filesystem, grub can boot from btrfs on / just fine, and we're not really at risk because we don't use btrfs subvolumes by default.

FWIW, this was already fixed previously via bug 18781, seems the patch got dropped in the meantime, here's a link for reference: http://svnweb.mageia.org/packages/cauldron/grub2/current/SOURCES/grub2-2.00-mga-dont_write_sparse_file_error_to_screen.patch?view=markup&pathrev=1040611

CC: (none) => doktor5000
See Also: (none) => https://bugs.mageia.org/show_bug.cgi?id=18781

Comment 3 Dieter Schütze 2021-03-26 21:32:45 CET
Same here 
/ as btrfs
/boot/EFI as vfat

and the solution on
---------------------------------
https://forum.manjaro.org/t/grub-error-sparse-file-not-allowed/20267

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

rebuild grub config

 sudo grub-mkconfig -o /boot/grub/grub.cfg
----------------------------------
works

CC: (none) => dieter

Morgan Leijström 2021-03-27 12:31:13 CET

CC: (none) => fri

Comment 4 Neal Gompa 2021-03-27 17:37:16 CET
(In reply to Aurelien Oudelet from comment #0)
> mageia 8 beta 1 Classic ISO Installer.
> 
> partitions configured as this:
> /boot/EFI is on /dev/nvme0n1p1 formated fat32
> / is on /dev/nvme0n1p2 formated btrfs
> /var is on /dev/sda3 formated ext4
> /home is /dev/sda2 formated xfs
> swap is /dev/sda1
> 
> Installation is OK and runs to end. But at first reboot:
> Grub2 complains about:
> -------------------
> error: ../../grub-core/commands/loadenv.c:216:sparse file not allowed.
> Press any key to continue...
> -------------------
> After, system boots fine.
> 
> Analyzing:
> Seems that if /boot is on rootfs (not in a separated partition), grub2
> complains as he can't save which is booted. (GRUB_DEFAULT=saved and
> GRUB_SAVEDEFAULT=true)
> 
> I think in installer, we should prevent such configuration or disable saving
> booting entry.
> 
> See 22582.
> 
> Workaround:
> https://forum.manjaro.org/t/solved-grub-btrfs-error-sparse-file-not-allowed/
> 70031

Having done significant work on Btrfs enablement in the past few years, I can answer a few things here.

GRUB reads and writes data from filesystems by locating the offset and doing stuff in-place. Most filesystems treat write operations this way as corruption, though some filesystems like ext4 tolerate this better than xfs (which winds up trying to "repair" it) or Btrfs (which will lock the filesystem to prevent further damage).

To avoid this problem with Btrfs, the GRUB filesystem driver is explicitly *read-only*. The error is printed because GRUB wants to write data and is forbidden from doing so.

This will also happen when you are working with /boot on any filesystem on RAID (such as MD or LVM).

(In reply to Aurelien Oudelet from comment #1)
> Assigning to Mageia Tools maintainers.
> 
> I solved my problem by reinstalling and creating a separate /boot ext4
> partition.
> 
> Workaround proposed above needs to edit /etc/default/grub as root and it is
> not trivial for "Mme Jane Doe" user...
> 
> I do think installer should prevent installing with / as btrfs and without
> /boot separated.

I've been talking to GRUB upstream about this problem already for a while. There's some talk about expanding the "BIOS boot partition" to be slightly larger and to be mandatory for all installs to have GRUB boot state data which is normally saved in the grubenv file. In practice, nobody but GRUB makes the "BIOS boot partition", so GRUB is considering just renaming this to "GRUB data partition" for this stuff, which avoids all kinds of nasty issues around this.

CC: (none) => ngompa13

Comment 5 Neal Gompa 2021-03-27 17:43:24 CET
(In reply to Aurelien Oudelet from comment #1)
> 
> I do think installer should prevent installing with / as btrfs and without
> /boot separated.

If we didn't have other issues around having separate /boot, I would say that we should just do that by default until this is fixed. But since there's a path to having this resolved in Mageia 9 and having a separate /boot is a worse user experience than just having a small error that has no impact on booting, I'd say we should leave things as-is and make adjustments once upstream has the fix for this in place.
Comment 6 Morgan Leijström 2021-03-27 17:53:03 CET
Thank you for the thorough explanations :)
Comment 7 Dieter Schütze 2021-03-27 23:39:55 CET
(In reply to Aurelien Oudelet from comment #4)
> 
> This will also happen when you are working with /boot on any filesystem on
> RAID (such as MD or LVM).
> 
I don't understand why are you write such things but this is definitely not true.
On my side i have 3 servers with mageia 7 and linux Raid (MD) and all of them runs fine without any errors or errors on boot. You can only use grub2 for linux raid with /boot on md stuff. My Partitions on such systems with linux raid are:

Dateisystem    Größe Benutzt Verf. Verw% Eingehängt auf
devtmpfs        3,9G       0  3,9G    0% /dev
tmpfs           3,9G    196K  3,9G    1% /dev/shm
tmpfs           3,9G    908K  3,9G    1% /run
/dev/md1         30G    5,3G   23G   20% /
tmpfs           3,9G       0  3,9G    0% /sys/fs/cgroup
/dev/md0        485M     40M  416M    9% /boot
/dev/md3        420G     27G  372G    7% /var
/dev/md2        1,5G    2,4M  1,4G    1% /tmp
tmpfs           796M       0  796M    0% /run/user/0

And btrfs works fine with grub2 on other linux systems but not on mageia ?
Comment 8 Neal Gompa 2021-03-28 00:26:22 CET
(In reply to Dieter Schütze from comment #7)
> (In reply to Aurelien Oudelet from comment #4)
> > 
> > This will also happen when you are working with /boot on any filesystem on
> > RAID (such as MD or LVM).
> > 
> I don't understand why are you write such things but this is definitely not
> true.
> On my side i have 3 servers with mageia 7 and linux Raid (MD) and all of
> them runs fine without any errors or errors on boot. You can only use grub2
> for linux raid with /boot on md stuff. My Partitions on such systems with
> linux raid are:
> 
> Dateisystem    Größe Benutzt Verf. Verw% Eingehängt auf
> devtmpfs        3,9G       0  3,9G    0% /dev
> tmpfs           3,9G    196K  3,9G    1% /dev/shm
> tmpfs           3,9G    908K  3,9G    1% /run
> /dev/md1         30G    5,3G   23G   20% /
> tmpfs           3,9G       0  3,9G    0% /sys/fs/cgroup
> /dev/md0        485M     40M  416M    9% /boot
> /dev/md3        420G     27G  372G    7% /var
> /dev/md2        1,5G    2,4M  1,4G    1% /tmp
> tmpfs           796M       0  796M    0% /run/user/0
> 
> And btrfs works fine with grub2 on other linux systems but not on mageia ?

There is no support for LVM2, though, which is the most common way this is done.

While it's true there's direct MD support, it's very limited. Upstream still does not recommend having /boot on such configurations (except Btrfs with RAID 1/10).
Ulrich Beckmann 2021-04-13 22:27:05 CEST

CC: (none) => bequimao.de

Comment 9 Florian Hubold 2021-04-19 18:23:06 CEST
(In reply to Dieter Schütze from comment #7)
 
> And btrfs works fine with grub2 on other linux systems but not on mageia ?

Hi Dieter,

other linux systems have the same issue, but they have patches to suppress that error message displayed by grub. Which is the same way that you're doing by disabling GRUB_SAVEDEFAULT (as this also prevents writes).
We already had such a patch as linked above but seems it has been dropped somewhere before mga8, and it should be put back.

Note You need to log in before you can comment on or make changes to this bug.