MCPcopy Index your code
hub / github.com/archlinux/archinstall / FilesystemHandler

Class FilesystemHandler

archinstall/lib/disk/filesystem.py:33–327  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31
32
33class FilesystemHandler:
34 def __init__(self, disk_config: DiskLayoutConfiguration):
35 self._disk_config = disk_config
36 self._enc_config = disk_config.disk_encryption
37
38 def perform_filesystem_operations(self) -> None:
39 if self._disk_config.config_type == DiskLayoutType.Pre_mount:
40 debug('Disk layout configuration is set to pre-mount, not performing any operations')
41 return
42
43 device_mods = [d for d in self._disk_config.device_modifications if d.partitions]
44
45 if not device_mods:
46 debug('No modifications required')
47 return
48
49 # Setup the blockdevice, filesystem (and optionally encryption).
50 # Once that's done, we'll hand over to perform_installation()
51
52 # make sure all devices are unmounted
53 for mod in device_mods:
54 device_handler.umount_all_existing(mod.device_path)
55
56 for mod in device_mods:
57 device_handler.partition(mod)
58
59 udev_sync()
60
61 if self._disk_config.lvm_config:
62 for mod in device_mods:
63 if boot_part := mod.get_boot_partition():
64 debug(f'Formatting boot partition: {boot_part.dev_path}')
65 self._format_partitions([boot_part])
66
67 self.perform_lvm_operations()
68 else:
69 for mod in device_mods:
70 self._format_partitions(mod.partitions)
71
72 for part_mod in mod.partitions:
73 if part_mod.fs_type == FilesystemType.BTRFS and part_mod.is_create_or_modify():
74 device_handler.create_btrfs_volumes(part_mod, enc_conf=self._enc_config)
75
76 def _format_partitions(
77 self,
78 partitions: list[PartitionModification],
79 ) -> None:
80 """
81 Format can be given an overriding path, for instance /dev/null to test
82 the formatting functionality and in essence the support for the given filesystem.
83 """
84
85 # don't touch existing partitions
86 create_or_modify_parts = [p for p in partitions if p.is_create_or_modify()]
87
88 self._validate_partitions(create_or_modify_parts)
89
90 for part_mod in create_or_modify_parts:

Callers 7

mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected