for ARG in $@; do
if [ "${ARG%%[!/]*}" = "/" ]; then
OPTIONS=
if FSTYPE=$( findmnt -n -o FSTYPE "$ARG" ); then
if [ "$FSTYPE" = "overlay" ]; then
OPTIONS=$(findmnt -n -o OPTIONS "$ARG")
fi
elif FSTYPE=$( findmnt -n -o FSTYPE / ); then
if [ "$FSTYPE" = "overlay" ]; then
OPTIONS=$(findmnt -n -o OPTIONS /)
fi
fi
if LOWERDIR=$(echo "$OPTIONS" | grep -m 1 -oP 'lowerdir=\K[^,]+'); then
# echo "[DEBUG] Overlay filesystem detected \${ARG} --> \${LOWERDIR}\${ARG%*/}" 1>&2
ARG="${LOWERDIR}${ARG%*/}"
fi
fi
ARGS="$ARGS $ARG"
done
NOTE: package name can also be "grub-efi-amd64" or "grub-efi-ia32" or something else, depending on what you use
PROS
====
- works perfectly with overlay filesystem
- shows a general solution (maybe someone can use it to fix the grub-probe source code)
- no patching of grub scripts required (some people tried patches as solution, but grub-probe is used in many grub scripts --> patching nightmare)
CONS
====
- grub-probe must be renamed (for this reason, I recommend that you set the status of your grub package to "hold")
WORKING SOLUTION
================
After encountering this problem, I developed a very simple solution:
nano /usr/sbin/ grub-probe- overlay
-----[BEGIN] ------- ------- ------- ------- ------- ------- ------- ------- ------
#!/bin/sh
ARGS=
for ARG in $@; do
if [ "${ARG%%[!/]*}" = "/" ]; then
OPTIONS=
if FSTYPE=$( findmnt -n -o FSTYPE "$ARG" ); then $(findmnt -n -o OPTIONS "$ARG") $(findmnt -n -o OPTIONS /)
if [ "$FSTYPE" = "overlay" ]; then
OPTIONS=
fi
elif FSTYPE=$( findmnt -n -o FSTYPE / ); then
if [ "$FSTYPE" = "overlay" ]; then
OPTIONS=
fi
fi
if LOWERDIR=$(echo "$OPTIONS" | grep -m 1 -oP 'lowerdir= \K[^,]+ '); then \${ARG% */}" 1>&2 "${LOWERDIR} ${ARG%* /}"
# echo "[DEBUG] Overlay filesystem detected \${ARG} --> \${LOWERDIR}
ARG=
fi
fi
ARGS="$ARGS $ARG"
done
grub-probe-default $ARGS
exit $? ------- ------- ------- ------- ------- ------- ------- ------- ------- -
-----[END]
mv /usr/sbin/ grub-probe /usr/sbin/ grub-probe- default
ln -s /usr/sbin/ grub-probe- overlay /usr/sbin/ grub-probe
OPTIONAL STEP:
==============
apt-mark hold grub-pc
NOTE: package name can also be "grub-efi-amd64" or "grub-efi-ia32" or something else, depending on what you use
PROS
====
- works perfectly with overlay filesystem
- shows a general solution (maybe someone can use it to fix the grub-probe source code)
- no patching of grub scripts required (some people tried patches as solution, but grub-probe is used in many grub scripts --> patching nightmare)
CONS
====
- grub-probe must be renamed (for this reason, I recommend that you set the status of your grub package to "hold")