mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
inspection: More reliable detection of Linux split /usr configurations
In RHEL 8+, /usr/etc no longer exists. Since we were looking for this
directory in order to detect a separate /usr partition, those were no
longer detected, so the merging of /usr data into the root was not
being done. The result was incomplete inspection data and failure of
virt-v2v.
All Linux systems since forever have had /usr/src but not /src, so
detect this instead.
Furthermore the merging code didn't work, because we expected that the
root filesystem had a distro assigned, but in this configuration we
may need to look for that information in /usr/lib/os-release (not on
the root filesystem). This change makes the merging work even if we
have incomplete information about the root filesystem, so long as we
have an /etc/fstab entry pointing to the /usr mountpoint.
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1949683
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1930133
Fixes: commit 394d11be49
This commit is contained in:
@@ -182,11 +182,9 @@ and check_for_duplicated_bsd_root fses =
|
||||
and collect_linux_inspection_info fses =
|
||||
List.map (
|
||||
function
|
||||
| { role = RoleRoot { distro = Some d } } as root ->
|
||||
if d <> DISTRO_COREOS then
|
||||
collect_linux_inspection_info_for fses root
|
||||
else
|
||||
root
|
||||
| { role = RoleRoot { distro = Some DISTRO_COREOS } } as root -> root
|
||||
| { role = RoleRoot _ } as root ->
|
||||
collect_linux_inspection_info_for fses root
|
||||
| fs -> fs
|
||||
) fses
|
||||
|
||||
@@ -196,29 +194,28 @@ and collect_linux_inspection_info fses =
|
||||
* or other ways to identify the OS).
|
||||
*)
|
||||
and collect_linux_inspection_info_for fses root =
|
||||
let root_distro, root_fstab =
|
||||
let root_fstab =
|
||||
match root with
|
||||
| { role = RoleRoot { distro = Some d; fstab = f } } -> d, f
|
||||
| { role = RoleRoot { fstab = f } } -> f
|
||||
| _ -> assert false in
|
||||
|
||||
try
|
||||
let usr =
|
||||
List.find (
|
||||
function
|
||||
| { role = RoleUsr { distro = d } }
|
||||
when d = Some root_distro || d = None -> true
|
||||
| { role = RoleUsr _; fs_location = usr_mp } ->
|
||||
(* This checks that this usr is found in the fstab of
|
||||
* the root filesystem.
|
||||
*)
|
||||
List.exists (
|
||||
fun (mountable, _) ->
|
||||
usr_mp.mountable = mountable
|
||||
) root_fstab
|
||||
| _ -> false
|
||||
) fses in
|
||||
|
||||
let usr_mountable = usr.fs_location.mountable in
|
||||
|
||||
(* This checks that [usr] is found in the fstab of the root
|
||||
* filesystem. If not, [Not_found] is thrown.
|
||||
*)
|
||||
ignore (
|
||||
List.find (fun (mountable, _) -> usr_mountable = mountable) root_fstab
|
||||
);
|
||||
|
||||
eprintf "collect_linux_inspection_info_for: merging:\n%sinto:\n%s"
|
||||
(string_of_fs usr) (string_of_fs root);
|
||||
merge usr root;
|
||||
root
|
||||
with
|
||||
|
||||
@@ -164,10 +164,10 @@ and check_filesystem mountable =
|
||||
()
|
||||
)
|
||||
(* Linux /usr? *)
|
||||
else if Is.is_dir "/etc" &&
|
||||
Is.is_dir "/bin" &&
|
||||
Is.is_dir "/share" &&
|
||||
else if Is.is_dir "/bin" &&
|
||||
Is.is_dir "/local" &&
|
||||
Is.is_dir "/share" &&
|
||||
Is.is_dir "/src" &&
|
||||
not (Is.is_file "/etc/fstab") then (
|
||||
debug_matching "Linux /usr";
|
||||
role := `Usr;
|
||||
|
||||
Reference in New Issue
Block a user