[Bug 1274320] Re: Error: diskfilter writes are not supported
Rarylson Freitas
rarylson at gmail.com
Tue Jul 15 23:47:19 UTC 2014
I added more info about this bug here:
http://askubuntu.com/a/498281/197497
To trying to help everybody with the problem solution, I'm copy/past my
answer in the Ask Ubuntu here.
----
This bug appears when you create the boot partition (or the root
partition, when the boot partition doesn't exists) inside a LVM or a
RAID partition.
When the system is booting, Grub (using its `diskfilter` module) tries
to write some data in `/boot`. However, in this Ubuntu version,
something goes wrong and Grub cannot write the desirable data (and the
warning appears).
Let's look inside the `/boot/grub/grub.cfg` file (generated using the
`/etc/grub.d/00_header` file by the `update-grub` command):
if [ -s $prefix/grubenv ]; then
set have_grubenv=true
load_env
fi
if [ "${next_entry}" ] ; then
set default="${next_entry}"
set next_entry=
save_env next_entry
set boot_once=true
[...]
According to this file, grub reads (`load_env`) the Grub environment
file (`/boot/grub/grubenv`) if it exits in every boot. Sometimes, it
saves (`save_env`) a new environment in this file too (when it's
necessary that the next boot sees a new environment).
This (save `grubenv`) can be used to save the last used grub entry
(setting `GRUB_DEFAULT=saved` in the `/etc/default/grub` file and
running `update-grub`).
This can be used by the **recordfail** feature too (see [Ubuntu Help -
Grub 2](https://help.ubuntu.com/community/Grub2), "Last Boot Failed or
Boot into Recovery ModeLast Boot Failed or Boot into Recovery Mode"
section).
In every boot, Grub updates the `recordfail` value and saves it.
Probably, at this moment, the warning appears to you (lines 104 to 124):
if [ "$quick_boot" = 1 ]; then
cat <<EOF
function recordfail {
set recordfail=1
EOF
FS="$(grub-probe --target=fs "${grubdir}")"
case "$FS" in
btrfs | cpiofs | newc | odc | romfs | squash4 | tarfs | zfs)
cat <<EOF
# GRUB lacks write support for $FS, so recordfail support is disabled.
EOF
;;
*)
cat <<EOF
if [ -n "\${have_grubenv}" ]; then if [ -z "\${boot_once}" ]; then save_env recordfail; fi; fi
EOF
esac
cat <<EOF
}
EOF
fi
See that Grub skips the recordfail feature when using the following
filesystems: `btrfs | cpiofs | newc | odc | romfs | squash4 | tarfs |
zfs`. The LVM and RAID subsystems aren't skipped in any moment.
To work inside RAID partitions (I don't know what happens inside LVM
partitions...), Grub uses the **diskfilter** module (`insmod
diskfilter`). You can get the source code of this module running:
apt-get source grub2
vim grub2-2.02~beta2/grub-core/disk/diskfilter.c
However, even if this module was loaded, the bug will appear when grub
calls the `save_env recordfail` function.
More details about this behaviour can be found at:
https://bugzilla.redhat.com/show_bug.cgi?id=1006289
I read the source code and found the moment when the warning is
dispatched (line 821). I'm pasting the code here (lines 808 to 823):
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");
}
As you can see in this code, the `grub_diskfilter_read` function is
implemented (and Grub can read the environment file). However, the
`grub_diskfilter_write` function isn't implemented and raises a
`GRUB_ERR_NOT_IMPLEMENTED_YET` error. In other words, Grub can't write
in a RAID array because it doesn't know how it can do this.
If you want to do not see this error anymore, you can:
- Change the `quick_boot="1"` to `quick_boot="0"` in the `/etc/grub.d/00_header` file;
- Apply this patch: https://launchpadlibrarian.net/175536511/diskfilter-writes.patch
- It was proposed in the Ubuntu thread [Bug #1274320, comment #34](https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/1274320/comments/34).
I think the first solution is a poor workarround (it can stop working
after a single `apt-get upgrade` of the `grub2` package). The second
solution is a better one.
However, the best solution would be if Grub implements the
`grub_diskfilter_write` function of the `diskfilter` module.
**Update:** The patch proposed in the [Bug #1274320, comment
#34](https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/1274320/comments/34),
is explained above:
- First, the patch runs the command `grub-probe --target=disk "${grubdir}"`;
- The guy that made this patch used the `--target=disk` option. Maybe using the `--target=abstraction` would be a better solution to locate boot partitions inside RAID and LVMs;
- Second, the patch checks if the 'path' where grub is installed contains the `"/dev/mapper"` (LVM) or the `"/dev/md"` (RAID) strings;
- Finally, if it is, the patch writes in the `/boot/grub/grub.cfg` file a comment similar to one showed in the top of this answer:
- For example, in my case:<br>
```# GRUB lacks write support for /dev/md0, so recordfail support is disabled.
```
To apply this path:
# Download
wget https://launchpadlibrarian.net/175536511/diskfilter-writes.patch
# Apply
patch /etc/grub.d/00_header < diskfilter-writes.patch
# Disable the old script
chmod -x /etc/grub.d/00_header.orig
# Update Grub
update-grub
This patch wasn't working for me (maybe the `00_header` was updated
since the patch was proposed). So, I made a new one:
https://gist.github.com/rarylson/23fb3ab46ded7ca2a818
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to grub2 in Ubuntu.
https://bugs.launchpad.net/bugs/1274320
Title:
Error: diskfilter writes are not supported
Status in GRand Unified Bootloader:
New
Status in “grub2” package in Ubuntu:
Triaged
Status in “grub2” package in Fedora:
Unknown
Bug description:
Once grub chooses what to boot to, an error shows up and will sit on
the screen for approx. 5 seconds
"Error: diskfilter writes are not supported.
Press any key to continue..."
From what I understand, this error is related to raid partitions, and
I have two of them (md0, md1). Both partitions are used (root and
swap). Raid is assembled with mdadm and are raid0
This error message started appearing right after grub2 was updated on
01/27/2014.
System: Kernel: 3.13.0-5-generic x86_64 (64 bit) Desktop: KDE 4.11.5 Distro: Ubuntu 14.04 trusty
Drives: HDD Total Size: 1064.2GB (10.9% used)
1: id: /dev/sda model: SanDisk_SDSSDRC0 size: 32.0GB
2: id: /dev/sdb model: SanDisk_SDSSDRC0 size: 32.0GB
3: id: /dev/sdc model: ST31000528AS size: 1000.2GB
RAID: Device-1: /dev/md1 - active raid: 0 components: online: sdb2 sda3 (swap) Device-2: /dev/md0 - active raid: 0 components: online: sdb1 sda1 ( / )
Grub2: grub-efi-amd64 version 2.02~beta2-5
ProblemType: Bug
DistroRelease: Ubuntu 14.04
Package: grub-efi-amd64 2.02~beta2-5
ProcVersionSignature: Ubuntu 3.13.0-5.20-generic 3.13.0
Uname: Linux 3.13.0-5-generic x86_64
NonfreeKernelModules: nvidia
ApportVersion: 2.13.2-0ubuntu2
Architecture: amd64
CurrentDesktop: KDE
Date: Wed Jan 29 17:37:59 2014
SourcePackage: grub2
UpgradeStatus: Upgraded to trusty on 2014-01-23 (6 days ago)
To manage notifications about this bug go to:
https://bugs.launchpad.net/grub/+bug/1274320/+subscriptions
More information about the foundations-bugs
mailing list