Do not mount btrfs partitions unless required, tested working and solves issue #3689 (#3992)

This commit is contained in:
scrypt-kitty 2026-01-01 21:27:53 -05:00 committed by GitHub
parent 7889a5417f
commit 4582d60f13
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 23 additions and 9 deletions

View File

@ -364,6 +364,9 @@ class Installer:
target = self.target / part_mod.relative_mountpoint target = self.target / part_mod.relative_mountpoint
device_handler.mount(part_mod.dev_path, target, options=part_mod.mount_options) device_handler.mount(part_mod.dev_path, target, options=part_mod.mount_options)
elif part_mod.fs_type == FilesystemType.Btrfs: elif part_mod.fs_type == FilesystemType.Btrfs:
# Only mount BTRFS subvolumes that have mountpoints specified
subvols_with_mountpoints = [sv for sv in part_mod.btrfs_subvols if sv.mountpoint is not None]
if subvols_with_mountpoints:
self._mount_btrfs_subvol( self._mount_btrfs_subvol(
part_mod.dev_path, part_mod.dev_path,
part_mod.btrfs_subvols, part_mod.btrfs_subvols,
@ -379,6 +382,9 @@ class Installer:
device_handler.mount(volume.dev_path, target, options=volume.mount_options) device_handler.mount(volume.dev_path, target, options=volume.mount_options)
if volume.fs_type == FilesystemType.Btrfs and volume.dev_path: if volume.fs_type == FilesystemType.Btrfs and volume.dev_path:
# Only mount BTRFS subvolumes that have mountpoints specified
subvols_with_mountpoints = [sv for sv in volume.btrfs_subvols if sv.mountpoint is not None]
if subvols_with_mountpoints:
self._mount_btrfs_subvol(volume.dev_path, volume.btrfs_subvols, volume.mount_options) self._mount_btrfs_subvol(volume.dev_path, volume.btrfs_subvols, volume.mount_options)
def _mount_luks_partition(self, part_mod: PartitionModification, luks_handler: Luks2) -> None: def _mount_luks_partition(self, part_mod: PartitionModification, luks_handler: Luks2) -> None:
@ -386,6 +392,9 @@ class Installer:
return None return None
if part_mod.fs_type == FilesystemType.Btrfs and part_mod.btrfs_subvols: if part_mod.fs_type == FilesystemType.Btrfs and part_mod.btrfs_subvols:
# Only mount BTRFS subvolumes that have mountpoints specified
subvols_with_mountpoints = [sv for sv in part_mod.btrfs_subvols if sv.mountpoint is not None]
if subvols_with_mountpoints:
self._mount_btrfs_subvol(luks_handler.mapper_dev, part_mod.btrfs_subvols, part_mod.mount_options) self._mount_btrfs_subvol(luks_handler.mapper_dev, part_mod.btrfs_subvols, part_mod.mount_options)
elif part_mod.mountpoint: elif part_mod.mountpoint:
target = self.target / part_mod.relative_mountpoint target = self.target / part_mod.relative_mountpoint
@ -398,6 +407,9 @@ class Installer:
device_handler.mount(luks_handler.mapper_dev, target, options=volume.mount_options) device_handler.mount(luks_handler.mapper_dev, target, options=volume.mount_options)
if volume.fs_type == FilesystemType.Btrfs and luks_handler.mapper_dev: if volume.fs_type == FilesystemType.Btrfs and luks_handler.mapper_dev:
# Only mount BTRFS subvolumes that have mountpoints specified
subvols_with_mountpoints = [sv for sv in volume.btrfs_subvols if sv.mountpoint is not None]
if subvols_with_mountpoints:
self._mount_btrfs_subvol(luks_handler.mapper_dev, volume.btrfs_subvols, volume.mount_options) self._mount_btrfs_subvol(luks_handler.mapper_dev, volume.btrfs_subvols, volume.mount_options)
def _mount_btrfs_subvol( def _mount_btrfs_subvol(
@ -406,7 +418,9 @@ class Installer:
subvolumes: list[SubvolumeModification], subvolumes: list[SubvolumeModification],
mount_options: list[str] = [], mount_options: list[str] = [],
) -> None: ) -> None:
for subvol in sorted(subvolumes, key=lambda x: x.relative_mountpoint): # Filter out subvolumes without mountpoints to avoid errors when sorting
subvols_with_mountpoints = [sv for sv in subvolumes if sv.mountpoint is not None]
for subvol in sorted(subvols_with_mountpoints, key=lambda x: x.relative_mountpoint):
mountpoint = self.target / subvol.relative_mountpoint mountpoint = self.target / subvol.relative_mountpoint
options = mount_options + [f'subvol={subvol.name}'] options = mount_options + [f'subvol={subvol.name}']
device_handler.mount(dev_path, mountpoint, options=options) device_handler.mount(dev_path, mountpoint, options=options)