Article View: linux.debian.bugs.dist
Article #6994Bug#1156015: refind: refind-install mounts /boot and /boot/efi again when they are already mounted
From: Kel Modderman
Date: Tue, 01 Dec 2026 12:10
Date: Tue, 01 Dec 2026 12:10
194 lines
9688 bytes
9688 bytes
This is a multi-part MIME message sent by reportbug.
--===============7677536889181518481==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Package: refind
Version: 0.14.2-2.1
Severity: normal
Tags: patch upstream
Hi Rod,
FindMountedESP() in refind-install starts by running "mount /boot",
"mount /boot/efi" and "mount /efi" without checking if they are mounted
already. mount does not refuse a second mount of an fstab entry, so each
run of refind-install mounts /boot/efi (and /boot, if it is a separate
partition) again, on top of the first. In a VM, mounting an fstab entry
a second time gives two mounts; only "mount -a" skips what is mounted.
On a running system that mostly goes unnoticed. It breaks installers
that run refind-install in a chroot of the target, as the Calamares
bootloader module does. With a separate /boot partition, the second
/boot hides the first /boot/efi, and the install fails at the last step
with "Could not unmount target system": the second "umount /boot/efi"
finds nothing mounted there.
I hit it in a Calamares install of a Debian sid based system with rEFInd
and a separate /boot, and reproduced it with refind-install alone in a
VM. The attached refind-chroot-mounts-repro.sh (VM only: it runs
refind-install, which tries to write a boot entry) sets up a target the
way an installer does (a root, an ext4 /boot with the ESP under it,
/proc /sys /dev /run bound in, /boot and /boot/efi in its fstab) and
runs refind-install in a chroot of it. After that, findmnt lists /boot
and /boot/efi twice each.
The attached patch makes FindMountedESP() mount each directory only if
mountpoint says it is not mounted yet. With exactly this patch, the same
test mounts each file system once, and unmounting them in the order
Calamares uses works.
The code is the same in upstream master, so the patch applies there too.
Thanks, Kel
-- System Information:
Debian Release: forky/sid
APT prefers unstable
APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)
Kernel: Linux 7.3.0-6.slh.3-aptosid-amd64 (SMP w/20 CPU threads; PREEMPT)
Locale: LANG=en_AU.UTF-8, LC_CTYPE=en_AU.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
--===============7677536889181518481==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="refind-install-chroot-mounts.patch"
--- a/refind-install 2026-12-01 21:57:13.535104520 +1000
+++ b/refind-install 2026-12-01 21:57:13.546651468 +1000
@@ -1242,9 +1242,15 @@
# any of these locations.
# Sets InstallDir to the ESP mount point.
FindMountedESP() {
- mount /boot &> /dev/null
- mount /boot/efi &> /dev/null
- mount /efi &> /dev/null
+ local Dir
+
+ # Mount each only if it isn't mounted yet: mount itself would stack a
+ # second mount on top of the first.
+ for Dir in /boot /boot/efi /efi ; do
+ if ! mountpoint -q "$Dir" ; then
+ mount "$Dir" &> /dev/null
+ fi
+ done
EspLine=$(df "$RootDir/efi" 2> /dev/null | grep efi)
if [[ -z "$EspLine" ]] ; then
EspLine=$(df "$RootDir"/boot/efi 2> /dev/null | grep boot/efi)
--===============7677536889181518481==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="refind-chroot-mounts-repro.sh"
#!/bin/bash
# VM ONLY: run as root in a throwaway live VM, never on a real machine. It
# runs the real refind-install, which writes an EFI boot entry, and makes
# loop devices.
# refind-install mounts /boot and /boot/efi again when they are mounted
# already; an installer runs it in a chroot of its target, where that
# stacked /boot breaks the installer's final unmount.
# usage: refind-chroot-mounts-repro.sh <refind .deb> [<patched refind-install>]
# A fake target the way Calamares lays it out: root, a plain /boot and the
# ESP mounted beneath it, /proc /sys /dev /run bound in, fstab naming both.
set -u
deb=$1
patched=${2:-}
T=/tmp/calamares-root-repro
work=/tmp/refind-repro
setup() {
mkdir -p "$work" "$T"
truncate -s 300M "$work/esp.img"
truncate -s 1G "$work/boot.img"
truncate -s 2G "$work/root.img"
esp=$(losetup -f --show "$work/esp.img")
boot=$(losetup -f --show "$work/boot.img")
root=$(losetup -f --show "$work/root.img")
mkfs.vfat -F32 -n EFI "$esp" > /dev/null
mkfs.ext4 -q -L boot "$boot"
mkfs.ext4 -q -L rootfs "$root"
mount "$root" "$T"
# the live system's userland stands in for the installed one
mkdir -p "$T"/{usr,etc,proc,sys,dev,run,tmp,boot,efi}
mount --bind /usr "$T/usr"
for l in bin sbin lib lib64; do [ -L "/$l" ] && cp -a "/$l" "$T/"; done
cp -a /etc/. "$T/etc/"
mount "$boot" "$T/boot"
mkdir -p "$T/boot/efi"
mount "$esp" "$T/boot/efi"
for d in proc sys dev run; do mount --bind "/$d" "$T/$d"; done
{
echo "UUID=$(blkid -s UUID -o value "$root") / ext4 defaults 0 1"
echo "UUID=$(blkid -s UUID -o value "$boot") /boot ext4 defaults 0 2"
echo "UUID=$(blkid -s UUID -o value "$esp") /boot/efi vfat umask=0077 0 2"
} > "$T/etc/fstab"
mkdir -p "$T/tmp/refind"
dpkg-deb -x "$deb" "$T/tmp/refind"
}
mounts() {
echo "-- mounts under $T:"
findmnt -rn -o TARGET,SOURCE | grep "^$T/boot" | sed 's/^/ /'
}
# what Calamares' UmountJob does: every mount under the target, sorted by
# path descending, each `umount -lv`; the first failure fails the install
calamares_umount() {
echo "-- Calamares-style unmount (path order):"
local rc=0
for m in $(findmnt -rn -o TARGET | grep "^$T/" | sort -r); do
if ! umount -l "$m" 2> "$work/err"; then
echo " umount $m FAILED: $(cat "$work/err")"
rc=1
break
fi
echo " umount $m ok"
done
return $rc
}
teardown() {
umount -R -l "$T" 2> /dev/null
losetup -d "$esp" "$boot" "$root"
rm -rf "$work"
}
run_case() {
echo "== $1"
setup
mounts
chroot "$T" /tmp/refind/usr/share/refind/refind-install --yes > "$work/ri.log" 2>&1
echo "-- refind-install exit $?; $(grep -m1 -i -e 'installing rEFInd' "$work/ri.log")"
grep -i -m3 -e "error" -e "abort" "$work/ri.log" | sed 's/^/ /'
mounts
calamares_umount && echo "-- install would have completed"
teardown
echo
}
run_case "refind-install 0.14.2 as shipped"
[ -n "${patched}" ] || exit 0
mkdir -p /tmp/deb-patched && dpkg-deb -R "$deb" /tmp/deb-patched
cp "${patched}" /tmp/deb-patched/usr/share/refind/refind-install
echo "== the change:"
diff -u <(dpkg-deb --fsys-tarfile "$deb" | tar -xO ./usr/share/refind/refind-install) \
/tmp/deb-patched/usr/share/refind/refind-install | sed -n '3,$p'
dpkg-deb -b /tmp/deb-patched /tmp/refind-patched.deb > /dev/null
deb=/tmp/refind-patched.deb
run_case "refind-install 0.14.2 with the change"
rm -rf /tmp/deb-patched /tmp/refind-patched.deb
--===============7677536889181518481==--
Technical Details
Message-ID:
<O5uQi-fkmm-21@gated-at.bofh.it>Path:
mbox-mo1.pugleaf.net!srl.newsdeef.eu!news.corradoroberto.it!news.servidellagleba.it!bofh.it!news.nic.it!robomodShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srl.newsdeef.eu!news.corradoroberto.it!news.servidellagleba.it!bofh.it!news.nic.it!robomod
From: Kel Modderman <kelvmod@gmail.com>
Newsgroups: linux.debian.bugs.dist
Subject: Bug#1156015: refind: refind-install mounts /boot and /boot/efi again when they are already mounted
Date: Tue, 01 Dec 2026 13:10:02 +0100
Message-ID: <O5uQi-fkmm-21@gated-at.bofh.it>
X-Original-To: Debian Bug Tracking System <submit@bugs.debian.org>
X-Mailbox-Line: From debian-bugs-dist-request@lists.debian.org Tue Dec 1 12:03:09 2026
Old-Return-Path: <debbugs@buxtehude.debian.org>
X-Spam-Flag: NO
X-Spam-Score: -0.548
Reply-To: Kel Modderman <kelvmod@gmail.com>, 1156015@bugs.debian.org
Resent-To: debian-bugs-dist@lists.debian.org
Resent-Cc: rod.smith@canonical.com
X-Debian-Pr-Message: report 1156015
X-Debian-Pr-Package: refind
X-Debian-Pr-Keywords: patch upstream
X-Debian-Pr-Source: refind
X-Gm-Message-State: APuU4Z8J5GBn/aY0Wh7bVSR/GuaRfP9PC4vo9pogxU+PsYSKvtwfilSx
CzxbO4JZYCYMXP7QgQvoJP6MqDK/Ck9Rbnh46XuyM9RLjGbH0grWrQfcU7Jj8SfP
X-Gm-Gg: AZFdTZeSsuPJo0AL8J/lZVYFTg5uPwrEUWJ4gwOMf1Gk3aydFnQx+n8d463hBpfPecB
3jMtK/ebbf44OR0b0+Kx7SZlU0rWaoI2jgl2X7zq83Xv0TniIUOC5bu0jZINKIkHaBzjvqCq9Se
cQoe2WKEMSyR/qDPA2+lgetc8Fogcpk83bB1uvryMVCCQAhfTF1SjCNGMCzCjhN3rLKAwAbaxka
HjPVStqpVgJlnfZh6e55wAifATigXvsHvv30cONTQp5JpgfxLmCCR45viblYALyWTHz5X3VAFs7
Q3iBEQ35KqXadSUT8Ip0ntwhU1Y+NohC+Q5Yva8hHKtkuWXSmi5YHRIQmOZxRGOh/YwnXY1vmmQ
o25JeDH6ii6cnQIaYFU9d4uYqFQfYV3d9nbp1cB3gxDmQs5QYtYjpBExLH8tuIIYn8r09KOqW7n
vxi4jNKBtME96NxhictN3IWZkBq5Iqn68ojlWpWIpxAvLxB9bi/IwPJec2SnboHxaWz+Y8IeZWb
9XVKcbmdwjm9SFWGG4LJTTZUVMneAC5Lm+ilALCrDoBwqyW5yjkDAGNrT6n0C0Yvx6P/r9Oh0Lo
Un8GUetHBRXuJoXqrXzwVR2SxviN9JxP7N8iqLhfb9sZIQ515UXq2eKW921lHmghk0qQwrTYd/k
YiPEh
X-Received: by 2002:a05:701a:cccb:10b0:1b5:9c35:13e with SMTP id a92af1059eb24-1b59c3502a0mr11708877c88.33.1796126437029;
Tue, 01 Dec 2026 04:00:37 -0800 (PST)
Content-Type: multipart/mixed; boundary="===============7677536889181518481=="
MIME-Version: 1.0
X-Mailer: reportbug 13.2.0+nmu1
X-Debian-Message: from BTS
X-Mailing-List: <debian-bugs-dist@lists.debian.org> archive/latest/2006272
List-ID: <debian-bugs-dist.lists.debian.org>
List-URL: <https://lists.debian.org/debian-bugs-dist/>
Approved: robomod@news.nic.it
Lines: 194
Organization: linux.* mail to news gateway
Sender: robomod@news.nic.it
X-Original-Date: Tue, 01 Dec 2026 22:00:05 +1000
X-Original-Message-ID: <179612640531.2065441.9307131612249032815.reportbug@flipper>