** Tags added: zfs
** Description changed:
update-grub fails on a ZFS root system when /etc is a separate dataset
and that dataset has snapshots. Each failed run leaves the root dataset
and its /etc dataset mounted read-write under /tmp/zfsmnt.XXXXXX.
/etc/os-release is a relative symbolic link to ../usr/lib/os-release.
Line 412 of /etc/grub.d/10_linux_zfs reads this file:
- pretty_name=$(. "${etc_dir}/os-release" && echo "${PRETTY_NAME}")
+ pretty_name=$(. "${etc_dir}/os-release" && echo "${PRETTY_NAME}")
For a snapshot of a separate /etc dataset, etc_dir is
/etc/.zfs/snapshot/<snapshot>. The link then points to
/etc/.zfs/snapshot/usr/lib/os-release, which does not exist. In dash, a
failed "." command ends the shell, so the script stops at this line. The
umount of "${mntdir}/etc" on line 413 and the later cleanup do not run.
A separate /etc dataset is not the installer default. But users create
this layout, and snapshot tools such as zrepl snapshot every dataset
under the root.
Steps to reproduce
1. Install Ubuntu with the root filesystem on ZFS.
2. Put /etc on a separate dataset, for example rpool/ROOT/ubuntu/etc.
3. Snapshot the root dataset and its children: sudo zfs snapshot -r
rpool/ROOT/ubuntu@test
4. Run "sudo update-grub".
Actual result
/etc/grub.d/10_linux_zfs: 412: .: cannot open
/etc/.zfs/snapshot/zrepl_20261014_181513_000/os-release: No such file
umount: /tmp/zfsmnt.fjqn60: target is busy.
rmdir: failed to remove '/tmp/zfsmnt.fjqn60': Device or resource busy
After the failure, findmnt shows the root dataset and its /etc dataset
mounted read-write under /tmp/zfsmnt.fjqn60. Each further run adds
another mount. Package operations that run update-grub, such as kernel
upgrades, can also fail.
Expected result
update-grub completes. A snapshot without a readable os-release gets a
fallback menu name. No mounts remain under /tmp.
Workaround
Replace line 412 with a test that skips a missing file or a broken link:
- if [ -r "${etc_dir}/os-release" ]; then
- pretty_name=$(. "${etc_dir}/os-release" && echo "${PRETTY_NAME}")
- elif [ -r "${mntdir}/usr/lib/os-release" ]; then
- pretty_name=$(. "${mntdir}/usr/lib/os-release" && echo
"${PRETTY_NAME}")
- else
- pretty_name="${dataset}"
- fi
+ if [ -r "${etc_dir}/os-release" ]; then
+ pretty_name=$(. "${etc_dir}/os-release" && echo "${PRETTY_NAME}")
+ elif [ -r "${mntdir}/usr/lib/os-release" ]; then
+ pretty_name=$(. "${mntdir}/usr/lib/os-release" && echo
"${PRETTY_NAME}")
+ else
+ pretty_name="${dataset}"
+ fi
The test "-r" is false for a link that points nowhere. An "||" fallback
after the "." command does not work, because the shell exits before it
reaches the fallback. With this change, update-grub completes and leaves
no mounts.
A complete fix resolves the link against the snapshot of the root
dataset, not the snapshot of the /etc dataset. The menu then shows the
correct name for each snapshot.
Versions
grub-common 2.14-2ubuntu2.1
zfsutils-linux 2.4.1-1ubuntu5.1
linux-image-7.0.0-38-generic
ProblemType: Bug
DistroRelease: Ubuntu 26.04
Package: grub-common 2.14-2ubuntu2.1
ProcVersionSignature: Ubuntu 7.0.0-38.38-generic 7.0.14
Uname: Linux 7.0.0-38-generic x86_64
NonfreeKernelModules: zfs
ApportVersion: 2.34.1-0ubuntu0.1
Architecture: amd64
CasperMD5CheckResult: unknown
Date: Wed Oct 14 21:09:49 2026
EcryptfsInUse: Yes
SourcePackage: grub2
UpgradeStatus: Upgraded to resolute on 2026-04-25 (172 days ago)
modified.conffile..etc.logrotate.d.apport: [modified]
mtime.conffile..etc.logrotate.d.apport: 2020-12-12T01:49:09.203717
--
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2170880
Title:
10_linux_zfs fails and leaves mounts behind when /etc is a separate
dataset with snapshots
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/2170880/+subscriptions
--
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs