[Bug 1987679] Re: os-prober leaves filesystems (lvm-thin, lvm snap) mounted
Timo Aaltonen
1987679 at bugs.launchpad.net
Tue Apr 8 13:24:52 UTC 2025
does that include oracular which has it in proposed already?
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to the bug report.
https://bugs.launchpad.net/bugs/1987679
Title:
os-prober leaves filesystems (lvm-thin, lvm snap) mounted
Status in os-prober package in Ubuntu:
Fix Released
Status in os-prober source package in Focal:
Incomplete
Status in os-prober source package in Jammy:
Incomplete
Status in os-prober source package in Kinetic:
Won't Fix
Status in os-prober source package in Noble:
Incomplete
Status in os-prober source package in Oracular:
Fix Committed
Status in os-prober source package in Plucky:
Fix Released
Bug description:
[ Impact ]
os-prober scripts will leave hanging mounts under /var/lib/os-prober/mount,
typically LVM snapshots. This can cause the server installer to hang, and causes
several errors when running grub-update:
Warning: os-prober will be executed to detect other bootable partitions.
Its output will be used to detect bootable binaries on them and create new boot entries.
rmdir: failed to remove '/var/lib/os-prober/mount': Device or resource busy
grub-probe: error: unknown filesystem.
rmdir: failed to remove '/var/lib/os-prober/mount': Device or resource busy
grub-probe: error: unknown filesystem.
rmdir: failed to remove '/var/lib/os-prober/mount': Device or resource busy
rmdir: failed to remove '/var/lib/os-prober/mount': Device or resource busy
/usr/sbin/grub-probe: error: unknown filesystem.
[ Test plan ]
I was able to reproduce this by having multiple LVM disks attached to the same
VM (e.g. from different runs of the Ubuntu installer on top of LVM). To
consistently trigger this issue, I had one of the LVs contain snapshots of the
Ubuntu rootfs (there's no need to mount multiple LVM partitions, as shown
below):
# lsblk /dev/vda /dev/vdb
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
vda 252:0 0 25G 0 disk
├─vda1 252:1 0 1M 0 part
├─vda2 252:2 0 2G 0 part /boot
└─vda3 252:3 0 23G 0 part
└─ubuntu--vg--1-ubuntu--lv--1 253:0 0 11.5G 0 lvm /
vdb 252:16 0 25G 0 disk
├─vdb1 252:17 0 1M 0 part
├─vdb2 252:18 0 2G 0 part
└─vdb3 252:19 0 23G 0 part
├─ubuntu--vg-ubuntu--lv-real 253:1 0 11.5G 0 lvm
│ ├─ubuntu--vg-ubuntu--lv 253:2 0 11.5G 0 lvm
│ ├─ubuntu--vg-rootfs_snap0 253:4 0 11.5G 0 lvm
│ └─ubuntu--vg-rootfs_snap1 253:6 0 11.5G 0 lvm
├─ubuntu--vg-rootfs_snap0-cow 253:3 0 1G 0 lvm
│ └─ubuntu--vg-rootfs_snap0 253:4 0 11.5G 0 lvm
└─ubuntu--vg-rootfs_snap1-cow 253:5 0 1G 0 lvm
└─ubuntu--vg-rootfs_snap1 253:6 0 11.5G 0 lvm
To reproduce:
1. Setup multiple VGs and LVs on a single system, preferably with snapshots of
an Ubuntu install
2. Enable os-prober by adding `GRUB_DISABLE_OS_PROBER=false` to /etc/default/grub
# echo GRUB_DISABLE_OS_PROBER=false >> /etc/default/grub
3. Run update-grub, it'll complain about the busy device on re-runs
# update-grub
4. Verify if there are stale mounts under /var/lib/os-prober/mount
# mount | tail
nsfs on /run/snapd/ns/lxd.mnt type nsfs (rw)
tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,size=201080k,nr_inodes=50270,mode=700,uid=1000,gid=1000,inode64)
grub-mount on /var/lib/os-prober/mount type fuse.grub-mount (rw,nosuid,nodev,relatime,user_id=0,group_id=0)
grub-mount on /var/lib/os-prober/mount type fuse.grub-mount (rw,nosuid,nodev,relatime,user_id=0,group_id=0)
grub-mount on /var/lib/os-prober/mount type fuse.grub-mount (rw,nosuid,nodev,relatime,user_id=0,group_id=0)
grub-mount on /var/lib/os-prober/mount type fuse.grub-mount (rw,nosuid,nodev,relatime,user_id=0,group_id=0)
[ Where problems could occur ]
Since we're now allowing partition types that aren't recongnized by grub-probe,
non-standard partition types could cause issues later on in the os-prober
scripts if they're not handled properly. This would likely show up as further
issues when running "update-grub", or when updating boot loader entries.
Since these scripts are restricted to the non-default case of running os-prober
(as it's not enabled by default), regression potential for existing installs
should be fairly low.
[ Other info ]
The patch prevents 50mounted-tests from exiting out early if grub-probe
encounters an error. We return a new type "bad" that is handled later in the
script, as to not leave the partition type unspecified. We also take care to
revert to the previous "default" of type=fuseblk as it might be used elsewhere.
--
If one happens to have by accident (or on purpose) a thick LVM snapshot, or a thin-LV with a copy of a system on it, update-grub reports
/sbin/grub-probe: error: unknown filesystem.
Found Ubuntu 22.04.1 LTS on /dev/mapper/vgxubuntu-s22.04
and
/sbin/grub-probe: error: disk `lvmid/X7waXv-rMDA-5fQA-aw6l-ei1I-8Gz3-pQl3lr/k3Ze1u-Mfwc-pxUt-7fXa-FjSZ-7IkX-HAxf3b' not found.
Found Ubuntu 22.04.1 LTS (22.04) on /dev/mapper/vgxubuntu-XR22.04.1U
and leaves the systems mounted rw on /var/lib/os-prober/mount.
On subsequent invocations update-grub spews out multiple
mdir: failed to remove '/var/lib/os-prober/mount': Device or resource busy
I'm pretty sure this also causes a new install to hang (though a
power-reset seems to load the new system - not sure if it is complete
or not.)
The missing umounts should be relatively easy to fix, but the thick
snapshot error is particularly vague as most users (I think) would
take the "unknown filesystem" to refer to the previous entry.
I have been playing with grub2-common-2.06-2ubuntu7 on xubuntu
22.04.1, though I am sure this has been around a while
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/os-prober/+bug/1987679/+subscriptions
More information about the foundations-bugs
mailing list