[Libguestfs] [PATCH] daemon: In list_filesystems ignore /dev/mapper/osprober-* devices

Richard W.M. Jones rjones at redhat.com
Tue May 17 10:20:33 UTC 2022


After virt-v2v runs grub2, which runs osprober, the osprober tool
leaves around read-only linear DM maps covering existing filesystems.
These should be ignored since they duplicate the existing filesystems.

https://listman.redhat.com/archives/libguestfs/2022-May/028871.html
https://bugzilla.redhat.com/show_bug.cgi?id=2003503#c12

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2003503
---
 daemon/listfs.ml | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/daemon/listfs.ml b/daemon/listfs.ml
index 63ced260a1..fef8b72bb7 100644
--- a/daemon/listfs.ml
+++ b/daemon/listfs.ml
@@ -41,6 +41,7 @@ let rec list_filesystems () =
    *)
   let devices = Lvm_dm.list_dm_devices () in
   let devices = List.filter is_not_partitioned_device devices in
+  let devices = List.filter is_not_osprober_device devices in
   List.iter (check_with_vfs_type ret) devices;
 
   (* Partitions. *)
@@ -90,6 +91,15 @@ and is_not_partitioned_device device =
 
   not has_partition
 
+(* In some circumstances the osprober tool (run by grub2) leaves
+ * around orphaned device-mapper maps which cover existing filesystems.
+ * These should be ignored.  See:
+ * https://listman.redhat.com/archives/libguestfs/2022-May/028871.html
+ * https://bugzilla.redhat.com/show_bug.cgi?id=2003503#c12
+ *)
+and is_not_osprober_device device =
+  not (String.is_prefix device "/dev/mapper/osprober-")
+
 (* We should ignore Windows Logical Disk Manager (LDM) partitions,
  * because these are members of a Windows dynamic disk group.  Trying
  * to read them will cause errors (RHBZ#887520).  Assuming that
-- 
2.35.1



More information about the Libguestfs mailing list