@@ -559,7 +559,9 @@ def _autodetect_dm(self, mountpoint, device=None) -> None:
559559 # If the slave source is a CRYPT-SUBDEV device, use its slave instead
560560 if self ["_vblk_info" ].get (slave_source , {}).get ("uuid" , "" ).startswith ("CRYPT-SUBDEV" ):
561561 slave_source = self ["_vblk_info" ][slave_source ]["slaves" ][0 ]
562- self .logger .info (f"[{ c_ (dev_name , 'blue' )} ] Slave is a CRYPT-SUBDEV, using its slave instead: { c_ (slave_source , 'cyan' )} " )
562+ self .logger .info (
563+ f"[{ c_ (dev_name , 'blue' )} ] Slave is a CRYPT-SUBDEV, using its slave instead: { c_ (slave_source , 'cyan' )} "
564+ )
563565 # Add the kmod for it
564566 self .logger .info (f"[{ c_ (dev_name , 'blue' )} ] Adding kmod for CRYPT-SUBDEV: { c_ ('dm-crypt' , 'magenta' )} " )
565567 self ["_kmod_auto" ] = ["dm_integrity" , "authenc" ]
@@ -747,22 +749,10 @@ def autodetect_root(self) -> None:
747749 raise AutodetectError (
748750 "Root mount not found in host mounts.\n Current mounts: %s" % pretty_print (self ["_mounts" ])
749751 )
750- root_dev = _autodetect_mount (self , "/" )
751- if self ["autodetect_dm" ]:
752- if self ["mounts" ]["root" ]["type" ] == "btrfs" :
753- from ugrd .fs .btrfs import _get_btrfs_mount_devices
754-
755- # Btrfs volumes may be backed by multiple dm devices
756- for device in _get_btrfs_mount_devices (self , "/" , root_dev ):
757- _autodetect_dm (self , "/" , device )
758- elif self ["mounts" ]["root" ]["type" ] == "zfs" :
759- for device in get_zpool_info (self , root_dev )["devices" ]:
760- _autodetect_dm (self , "/" , device )
761- else :
762- _autodetect_dm (self , "/" )
752+ _autodetect_mount (self , "/" )
763753
764754
765- def _autodetect_mount (self , mountpoint , mount_class = "mounts" , missing_ok = False ) -> str :
755+ def _autodetect_mount (self , mountpoint , mount_class = "mounts" , missing_ok = False ) -> None :
766756 """Sets mount config for the specified mountpoint, in the specified mount class.
767757
768758 Returns the "real" device path for the mountpoint.
@@ -815,7 +805,7 @@ def _autodetect_mount(self, mountpoint, mount_class="mounts", missing_ok=False)
815805 # Inherit mount options from the host mount for certain mount types
816806 if fs_type in MOUNT_INHERIT_OPTIONS :
817807 mount_options = self ["_mounts" ][mountpoint ].get ("options" , ["ro" ])
818- if 'rw' in mount_options :
808+ if "rw" in mount_options :
819809 mount_options .pop (mount_options .index ("rw" )) # Remove rw option if it exists
820810 else : # For standard mounts, default ro
821811 mount_options = ["ro" ]
@@ -840,8 +830,21 @@ def _autodetect_mount(self, mountpoint, mount_class="mounts", missing_ok=False)
840830 if fs_type == "zfs" :
841831 mount_config [mount_name ]["path" ] = mount_device
842832
833+ # Run device mapper autodetection if enabled
834+ if self ["autodetect_dm" ]:
835+ if fs_type == "btrfs" :
836+ from ugrd .fs .btrfs import _get_btrfs_mount_devices
837+
838+ # Btrfs volumes may be backed by multiple dm devices
839+ for device in _get_btrfs_mount_devices (self , mountpoint , mount_device ):
840+ _autodetect_dm (self , mountpoint , mount_device )
841+ elif fs_type == "zfs" :
842+ for device in get_zpool_info (self , mount_device )["devices" ]:
843+ _autodetect_dm (self , mountpoint , mount_device )
844+ else :
845+ _autodetect_dm (self , mountpoint )
846+
843847 self [mount_class ] = mount_config
844- return mount_device
845848
846849
847850@contains ("auto_mounts" , "Skipping auto mounts, auto_mounts is empty." , log_level = 10 )
@@ -906,7 +909,9 @@ def mount_fstab(self) -> list[str]:
906909 mount_retries sets the number of times to retry the mount, infinite otherwise.
907910 """
908911 if not self ._get_build_path ("/etc/fstab" ).exists ():
909- return self .logger .info ("No initramfs fstab found, skipping mount_fstab. If non-root storage devices are not needed at boot, this is fine." )
912+ return self .logger .info (
913+ "No initramfs fstab found, skipping mount_fstab. If non-root storage devices are not needed at boot, this is fine."
914+ )
910915
911916 out = [
912917 'einfo "Attempting to mount all filesystems."' ,
@@ -1039,8 +1044,12 @@ def export_mount_info(self) -> None:
10391044 self .logger .critical (f"Failed to get source info for the root mount: { e } " )
10401045 if not self ["hostonly" ]:
10411046 self .logger .info ("Root mount infomrmation can be defined under the '[mounts.root]' section." )
1042- raise ValidationError ("Root mount source information is not set, when hostonly mode is disabled, it must be manually defined." )
1043- raise ValidationError ("Root mount source information is not set even though hostonly mode is enabled. Please report a bug." )
1047+ raise ValidationError (
1048+ "Root mount source information is not set, when hostonly mode is disabled, it must be manually defined."
1049+ )
1050+ raise ValidationError (
1051+ "Root mount source information is not set even though hostonly mode is enabled. Please report a bug."
1052+ )
10441053 self ["exports" ]["MOUNTS_ROOT_TYPE" ] = self ["mounts" ]["root" ].get ("type" , "auto" )
10451054 self ["exports" ]["MOUNTS_ROOT_OPTIONS" ] = "," .join (self ["mounts" ]["root" ]["options" ])
10461055 self ["exports" ]["MOUNTS_ROOT_TARGET" ] = self ["mounts" ]["root" ]["destination" ]
0 commit comments