30

I've installed Ubuntu without creating a swap partition and with / on a btrfs.# Now I get the message "Sparse file is not allowed" on each boot. This message appears before the splash-screen. Is there a way to kill this warning?

5
  • On my system, hitting any key does nothing, it's stuck!
    – Michael
    Jun 10, 2015 at 19:55
  • 2
    the solution in 2016 is to set GRUB_SAVEDEFAULT=false in /etc/default/grub & run update-grub Jun 9, 2016 at 19:59
  • in 2020 I solved this grub / btrfs issue with GRUB_DEFAULT="1" to boot the 2nd kernel in the GRUB menu Dec 2, 2020 at 23:12
  • 1
    @StuartCardall your comments are not solutions. They disable quite useful features. I think the real solution is to create a non-btrfs /boot partition.
    – xeruf
    Dec 14, 2021 at 17:04
  • @xeruf - I have been running a btrfs root filesystem WITHOUT a separate /boot for about 6 YEARS now & am using the same settings as in my comment 2 years ago. The whole point of which being the ability to snapshot the entire root filesystem so GRUB has the ability to boot from snapshots. Dec 15, 2021 at 21:04

2 Answers 2

35
+50

OK after a bit of rummaging around I found a how-to too get rid of this problem at least temporarily it is fairly simple however I don't have my system set-up with btrfs so I can't confirm this fix.

either comment out or remove this line:

if [ -n ${have_grubenv} ]; then save_env recordfail; fi

or

if [ -n "\${have_grubenv}" ]; then if [ -z "\${boot_once}" ]; then save_env \
recordfail; fi; fi

in this file

/etc/grub.d/00_header

then run

update-grub

the reason for not editing /boot/grub/grub.cfg directly is that it will be over written every time grub is updated in this case you would only have to "re do" the fix if the grub common packages is updated.

This is the bug on launchpad if you want to add yourself bug #736743

Quoting Colin Watson from the bug report

This is actually a misleading error message: what's happening is that GRUB's btrfs implementation doesn't implement the file read hook interface for returning blocklists to calling code. I posted to grub-devel about this and the upstream maintainer pointed out that, even aside from multi-device problems, writing to btrfs from GRUB is fundamentally risky because:

the same block may be used by multiple snapshots every tree which uses a given block will contain its checksum, and so on recursively

However, btrfs reserves space at the start for the boot loader. This space is more than GRUB needs to embed itself, and so we could use 1KB of it for an environment block.

In any case, this is not a new problem that arose from using subvolumes, nor does it prevent booting (you get a spurious "Press any key to continue" prompt, but if you just ignore it it'll boot anyway). Downgrading to wishlist.

Hope this helps

10
  • 1
    Can you find an explanation as to why it spits out this error to begin with? Thanks. :)
    – jrg
    Feb 17, 2012 at 21:31
  • In my config file, the line looks like this: if [ -n "\${have_grubenv}" ]; then if [ -z "\${boot_once}" ]; then save_env recordfail; fi; fi
    – FUZxxl
    Feb 17, 2012 at 22:26
  • 1
    I would comment out. If it fails to boot you should still be able to uncomment the line using a live disk
    – Allan
    Feb 17, 2012 at 22:57
  • 2
    Nice, it works!
    – FUZxxl
    Feb 18, 2012 at 23:27
  • 2
    Please explain what the code we're commenting out does.
    – Zaz
    Jun 10, 2015 at 1:43
0

I'm running al development branch of Raring Ringtail.
I experienced the same problem about a sparse file not allowed message. GRUB not showing at all and booting straight into Ubuntu.

I was reading a Linux Magazine (LXF), which had a few articles about recovering and repairing partitions, files, bootloaders and other stuff.

One of the article writers mentioned a simple tool to be used... Boot-Repair.
This tool did the trick for me and in my opinion should get a prominent place in the repositories of Ubuntu.

Add Boot-Repair to your system:

  1. Open a terminal window and copy/paste/type the following:

    sudo add-apt-repository ppa:yannubuntu/boot-repair && sudo apt-get update
    
  2. Copy/paste/type the following to install and start Boot-Repair:

    sudo apt-get install -y boot-repair && boot-repair
    
  3. The main GUI of Boot-Repair is visible now.

    Click on a button called 'Recommended repair'.
    

    Let the tool do it's 'magic'.

  4. When the magic spell ends,

    create a little note of the url visible. 
    
  5. Reboot the system and check if you can access your recovered operating systems.

  6. When there's no success use the url showed at the end of the repair to seek help.

3
  • I don't think that helps since this is a bug in grub itself.
    – FUZxxl
    Dec 19, 2012 at 11:38
  • Why do you think that? I did several virtual installs of 13.04, all had the same problem. Edited the grub.cfg, no results. That didn't solve the 'sparse file not allowed' message for me at all. GRUB wasn't even visible either. After I tried the solution I provided in my post earlier today, it worked like a charm and still is.
    – C Schilder
    Dec 19, 2012 at 16:50
  • Sadly not working in 14.04 Trusty amd64 Apr 30, 2014 at 9:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .