95

This message occurs when leaving the Grub menu and before the Ubuntu splash screen.

How do I fix the problem to clear the message?

And what doe is it mean?

error:  Diskfilter writes are not supported

System boots and seems to work just fine.

RCF
  • 2,097
  • 4
  • 19
  • 25

3 Answers3

154

It's a BUG!

This is a bug that occurs in the most recent version of Ubuntu Server LTS (Ubuntu Server 14.04 LTS), when you create the boot partition (or the root partition, when the boot partition doesn't exists) inside a LVM or a RAID partition.

You can get more info about this bug in Ubuntu Launchpad: Bug #1274320 "Error: diskfilter writes are not supported".

Update: This bug is already fixed in Ubuntu Server 14.04 and some newer Ubuntu versions. Probably, you only need to run apt-get upgrade.

Why does this bug occur?

When the system is booting, GRUB reads (load_env) data in /boot/grub/grubenv. This file is called GRUB Environment Block.

From the GRUB Manual:

It is often useful to be able to remember a small amount of information from one boot to the next.

[...]

At boot time, the load_env command (see load_env) loads environment variables from it, and the save_env (see save_env) command saves environment variables to it.

[...]

grub-mkconfig uses this facility to implement GRUB_SAVEDEFAULT

This behavior can be founded in /etc/grub.d/00_header (update-grub uses this file to generate the /boot/grub/grub.cfg file):

if [ -s $prefix/grubenv ]; then
  set have_grubenv=true
  load_env
fi

The problem is that the save_env statement only works in simple installations (you can't run save_env inside a RAID or LVM disk). From the GRUB manual:

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).

The GRUB recordfail feature uses the save_env statement to update the recordfail state (see Ubuntu Help - Grub 2, "Last Boot Failed or Boot into Recovery Mode" section). However, in Ubuntu 14.04 (and in recent Debian versions), the save_env statement (inside the recordfail feature) is used even if GRUB is installed in a LVM or a RAID.

Let's see the lines from 104 to 124 in /etc/grub.d/00_header:

if [ "$quick_boot" = 1 ]; then
    [...]
    case "$FS" in
      btrfs | cpiofs | newc | odc | romfs | squash4 | tarfs | zfs)
    cat <<EOF
  # GRUB lacks write support for $FS, so recordfail support is disabled.
  [...]
  if [ -n "\${have_grubenv}" ]; then if [ -z "\${boot_once}" ]; then save_env recordfail; fi; fi

GRUB correctly skips the recordfail feature when using unsupported filesystems (btrfs, zfs, etc), but it doesn't skip LVM and RAID at any moment.

How does GRUB protect itself from writing inside RAID and LVM?

To read/write correctly in a filesystems, GRUB loads an appropriate module.

GRUB uses the diskfilter module (insmod diskfilter) in RAID partitions, and the lvm module in LVM partitions.

Let's see the read/write implementation of the diskfilter module:

apt-get source grub2
vim grub2-2.02~beta2/grub-core/disk/diskfilter.c

I'm pasting the code here (lines from 808 to 823). The warning showed in this question appears at line 821:

static grub_err_t
grub_diskfilter_read (grub_disk_t disk, grub_disk_addr_t sector,
                  grub_size_t size, char *buf)
{
  return read_lv (disk->data, sector, size, buf);
}

static grub_err_t grub_diskfilter_write (grub_disk_t disk __attribute ((unused)), grub_disk_addr_t sector __attribute ((unused)), grub_size_t size __attribute ((unused)), const char *buf __attribute ((unused))) { return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, "diskfilter writes are not supported"); }

The grub_diskfilter_read function is implemented (and GRUB can read RAID filesystems). However, the grub_diskfilter_write function raises a GRUB_ERR_NOT_IMPLEMENTED_YET error.

Why does using quick_boot=0 solve the problem? And why is it the wrong solution?

If you look one more time in the /etc/grub.d/00_header code, you will see that the recordfail featured is only used when quick_boot=1. So, changing quick_boot from 1 to 0 disables the recordfail feature, and disables writes in the RAID/LVM partition.

However, it'll disable many other features too (run grep \$quick_boot /etc/grub.d/* and you'll see). More yet, if one day you change your /boot/grub directory to outside the RAID/LVM, the recordfail feature will still disabled.

Summarily, this solution unnecessarily disables features, and it's not generic.

What is the correct solution?

The correct solution should consider disable the save_env statements when GRUB is inside LVM or RAID partitions.

One patch was proposed in the Debian Bug Tracker system to implement this solution. It can be found in: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=754921

The idea behind this patch is:

  • Run a grub-probe --target=abstraction "${grubdir}" command to get what kind of abstraction modules GRUB uses to read/write files in the /boot/grub directory;
  • If GRUB uses the diskfilter or lvm module, skip the recordfail save_env statement and write an appropriated comment in the /boot/grub/grub.cfg file;
    • For example, # GRUB lacks write support for /dev/md0, so recordfail support is disabled.

How to apply the correct solution?

If you don't want to wait for this patch be applied by the Ubuntu/Debian guys in the official code, you can use my patched 00_header:

# Download
wget https://gist.githubusercontent.com/rarylson/da6b77ad6edde25529b2/raw/99f266a10e663e1829efc25eca6eddb9412c6fdc/00_header_patched
# Apply
mv /etc/grub.d/00_header /etc/grub.d/00_header.orig
mv 00_header_patched /etc/grub.d/00_header
# Disable the old script and enable the new one
chmod -x /etc/grub.d/00_header.orig
chmod +x /etc/grub.d/00_header
# Update Grub
update-grub
  • Thank you especially for the bug reference. I hope you will understand that I found nux' solution more compelling, though. ;) – Run CMD Jul 24 '14 at 05:48
  • 6
    Hi @ClassStacker, I summarized the answer! It was very big and it was very difficult for many people to understand :p It is still big, but at least I organized it in sections. So now you can look only in the sections of interest. – Rarylson Freitas Jul 31 '14 at 04:16
  • 8
    Wow. Thank you. If there was an "answer of the month" feature, I'd vote for yours. Also, you deserve a "no BS" award. This is the kind of articles which really provide value, and which make a huge difference between this site network as compared to forums. – Run CMD Aug 01 '14 at 08:46
  • 1
    Sadly I have been affected by this bug and none of the fixes in the bug report or here by editing the 00_header file have worked. I won't disable the quick_boot to make it go away. – douggro Aug 18 '14 at 05:13
  • @douggro I'm not sure why the edited 00_header file (as recommended here) wouldn't work. I know that just because it works for me (and for Rarylson Freitas) doesn't mean it necessarily would work for everyone. But did you make sure to give the right permissions to the old and new 00_header and to run update-grub? (If you just edited 00_header in place, no chmod is required, but update-grub remains necessary.) – Eliah Kagan Oct 01 '14 at 15:48
  • @EliahKagan I followed the instructions exactly including the permissions change and updating grub. The issue persisted for a while but it appears that a software update eliminated the issue. – douggro Oct 01 '14 at 19:46
  • @douggro, I'm "affected" and my system is up to date. So no, the scripts were not yet updated. But it does not matter from what we can see, it just means that the grub save_env does nothing. So what? – Alexis Wilke Oct 13 '14 at 09:49
  • I mis-stated that updates fixed the bug - it still persisted. Further digging revealed that I had induced a syntax error in the 00_header file by having an extra cat <<EOF statement in line 106 of the file. Removed that and the error went away. Perhaps I didn't properly run update-grub following the fix at some point, but it's working now. – douggro Nov 27 '14 at 16:33
  • @RarylsonFreitas: great answer. Have some of my rep! Thanks for writing an exemplary answer. Keep up the good work. – 0xC0000022L Mar 18 '15 at 11:53
  • The patch no longer works in Ubuntu 14.04.2. After applying it and rebooting, I still get the error. – Cerin Apr 12 '15 at 18:44
  • In my case, solve is: "rm /boot/grub/grubenv" in /etc/rc.local – ggrandes May 09 '15 at 16:39
  • This patch solves my problem on Ubuntu 14.04.2 LTS, it works even after a couple of reboots. – gerlos Jun 03 '15 at 16:03
  • Interestingly, a recent upgrade to 14.04 re-introduced this problem. I've had to revert to a May 24th backup of 00_header to fix it. – Paul Tomblin Aug 07 '15 at 12:06
  • Hi @PaulTomblin. Recently, the 00_header file was updated in Ubuntu 14.04 to fix an another bug (a different bug). In cases like this one, I usually keep my current file and manually check the new file (*-dpkg or a similar name) to merge the new improvements. More: https://raphaelhertzog.com/2010/09/21/debian-conffile-configuration-file-managed-by-dpkg/. The good news is that I updated my workaround so now it has both the bugfix for this bug and the recent Ubuntu update bugfix. – Rarylson Freitas Aug 08 '15 at 02:31
  • It doesn't make the -dpkg.orig or whatever if you've never modified the file. That's why I had to find an old backup. – Paul Tomblin Aug 08 '15 at 11:36
  • @RarylsonFreitas I finally got around to rebooting to test this, and in spite of the fact that /boot/grub/grub.cfg says function recordfail { set recordfail=1 # GRUB lacks write support for lvm, so recordfail support is disabled. } I still got the error. – Paul Tomblin Aug 18 '15 at 00:28
  • I still get this error in 15.04. According to the Launchpad entry, the official fix will appear in wily (15.10). – nwellnhof Aug 26 '15 at 17:02
  • Thanks @nwellnhof. I updated the post with your information! – Rarylson Freitas Aug 27 '15 at 20:22
  • Here is a short url from google for the file: https://goo.gl/5CJr2h – Stanislav Oct 11 '15 at 00:52
  • I had the same bug (Ubuntu 14.04). This bug was fixed and I just did "apt-get update" to install grib-pc verrsion 2.02~beta2-9ubuntu1.7 and that solved my problem. – dalf Jan 25 '16 at 01:20
  • Wow, great answer. This is right up there with all the best answers on any of the * exchanges. I found it looking for a solution to this error on Manjaro (an Arch derivative) and it helped me fix the issue. If you know the reputations of those distros documentation, you will likely take that as a compliment :). – Red_Tractor May 26 '16 at 12:46
  • 3
    7 years later, is this still a bug? – Typewar Aug 04 '21 at 14:06
  • I have a followup question that is too long for a comment so I asked a new question: https://askubuntu.com/questions/1409016/diskfilter-writes-are-not-supported-want-to-understand-changes-in-patched-file – Amedee Van Gasse May 17 '22 at 09:41
  • 9 years later, this is still a bug! I'm on Ubuntu 22.04 and I installed the lowlatency kernel (sudo apt install linux-lowlatency-hwe-22.04) to combat audio issues. However, Ubuntu still wants to boot the default kernel. I then read somewhere that enabling GRUB_SAVEDEFAULT=true and changing GRUB_DEFAULT=saved should resolve it. That did not resolve it and I'm now getting this error on each reboot. Doesn't seem to cause any issues though. Will revert those GRUB changes and hopefully clear the error OR try solution posted by @nux. – AnthonyK Jul 06 '23 at 01:21
36

I think this error occur because of raid or LVM partition .

For a temporary fix for this problem :

Edit :/etc/grub.d/10_linux

Replace 'quick_boot="1"' with 'quick_boot="0"'

Then :

sudo update-grub
nux
  • 38,017
  • 35
  • 118
  • 131
  • Thanks, it worked perfectly. Yes, I am using LVM for all volumes. – RCF May 18 '14 at 00:42
  • Thank you for this solution. It saved me a lot of work. Do you have a bit of background info also? – Run CMD Jul 24 '14 at 05:43
  • @ClassStacker if you are asking for more info from nux, you need to edit your comment to begin with (@nux). If you are asking me, what type of background are you seeking? – RCF Jul 24 '14 at 16:43
  • 2
    @RCF-U14.04 1) No, I don't have to. Just click on "add comment" -> "help" to learn that "The post author will always be notified of your comment". 2) I wanted to know (from nux) why this solves the problem, especially given the extensive answer by Rarylson Freitas. But if you can answer that, feel free to do so. – Run CMD Jul 25 '14 at 03:20
0

This error isn't (anymore) due to a bug as I got it on my Debian 12 server few days back. Though Rarylson Freitas' answer covers it, it mentions it as a Ubuntu bug, but the actual root cause lies buried.

Root cause: You setup GRUB to remember something for you but didn't provide a fixed, non-checksumming filesystem partition for storage.

Commonly, for GRUB to remember your last menu selection, you'd do

GRUB_SAVEDEFAULT=true

in your /etc/default/grub. To achieve this GRUB needs to write/save the selection information somewhere i.e. somewhere on a persistent disk. info grub environment 'environment block' states

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).

...

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).

I created a partition scheme where /boot/grub lived on a LVM logical volume and got this error.

When I moved my /boot to a fixed (ext4) partition (and fixed corresponding /etc/fstab entry) the issue got fixed.

GRUB: 2.12

legends2k
  • 279