Skip to content

Instantly share code, notes, and snippets.

@rjarry
Last active August 29, 2015 14:04
Show Gist options
  • Save rjarry/faf68c60e533a5c313c4 to your computer and use it in GitHub Desktop.
Save rjarry/faf68c60e533a5c313c4 to your computer and use it in GitHub Desktop.
--- a/etc/grub.d/00_header 2014-07-18 18:06:43.409469512 +0200
+++ b/etc/grub.d/00_header 2014-07-18 18:02:34.733561337 +0200
@@ -101,23 +101,43 @@ function savedefault {
}
EOF
+boot_part_writeable() {
+ for abstraction in "$(grub-probe --target=abstraction "${grubdir}")";
+ do
+ case "$abstraction" in
+ diskfilter|lvm)
+ return 1
+ ;;
+ esac
+ done
+
+ case "$(grub-probe --target=fs "${grubdir}")" in
+ btrfs|cpiofs|newc|odc|romfs|squash4|tarfs|zfs)
+ return 1
+ ;;
+ esac
+
+ return 0
+}
+
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.
+ if boot_part_writeable; then
+ cat <<EOF
+ if [ -n "\${have_grubenv}" ]; then
+ if [ -z "\${boot_once}" ]; then
+ save_env recordfail
+ fi
+ fi
EOF
- ;;
- *)
- cat <<EOF
- if [ -n "\${have_grubenv}" ]; then if [ -z "\${boot_once}" ]; then save_env recordfail; fi; fi
+ else
+ cat <<EOF
+ # GRUB lacks write support on the boot partition, so recordfail support is disabled.
EOF
- esac
+ fi
cat <<EOF
}
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment