daemon: inspect: Resolve Ubuntu 22+ /dev/disk/by-uuid/ in fstab

Ubuntu 22= uses /dev/disk/by-uuid/ followed by a filesystem UUID in
fstab entries.  Resolve these to mountables.

A typical fstab entry looks like this:

  # /boot was on /dev/vda2 during curtin installation
  /dev/disk/by-uuid/b4e56462-5a64-4272-b76d-f5e58bd8f128 /boot ext4 defaults 0 1

The comment is generated by the installer and appears in the fstab.
This entry would be translated to /dev/sda2.

(cherry picked from commit 7a1ffd744b)
(cherry picked from commit 0d466cb25e)
This commit is contained in:
Richard W.M. Jones
2025-04-16 10:13:52 +01:00
parent b7286e1ac3
commit a3ac31c6dc

View File

@@ -394,6 +394,19 @@ and resolve_fstab_device spec md_map os_type =
resolve_diskbyid part default
)
(* Ubuntu 22+ uses /dev/disk/by-uuid/ followed by a UUID. *)
else if String.is_prefix spec "/dev/disk/by-uuid/" then (
debug_matching "diskbyuuid";
let uuid = String.sub spec 18 (String.length spec - 18) in
try
(* Try a filesystem UUID. Unclear if this could be a partition UUID
* as well, but in the Ubuntu guest I tried it was an fs UUID XXX.
*)
Mountable.of_device (Findfs.findfs_uuid uuid)
with
Failure _ -> default
)
else if PCRE.matches re_freebsd_gpt spec then (
debug_matching "FreeBSD GPT";
(* group 1 (type) is not used *)