Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
svartkanin committed Oct 10, 2023
1 parent 7539326 commit 137970b
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
2 changes: 2 additions & 0 deletions archinstall/lib/disk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
DiskLayoutConfiguration,
LvmLayoutType,
LvmConfiguration,
LvmVolumeGroup,
LvmVolume,
PartitionTable,
Unit,
Size,
Expand Down
2 changes: 2 additions & 0 deletions archinstall/lib/disk/device_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -851,10 +851,12 @@ def table_data(self) -> Dict[str, Any]:


class LvmLayoutType(Enum):
Default = 'default'
Manual = 'manual_lvm'

def display_msg(self) -> str:
match self:
case LvmLayoutType.Default: return str(_('Default layout'))
case LvmLayoutType.Manual: return str(_('Manual configuration'))

raise ValueError(f'Unknown type: {self}')
Expand Down
35 changes: 33 additions & 2 deletions archinstall/lib/interactions/disk_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,16 @@ def select_lvm_config(
disk_config: disk.DiskLayoutConfiguration,
preset: Optional[disk.LvmConfiguration] = None,
) -> Optional[disk.LvmConfiguration]:
default_mode = disk.LvmLayoutType.Default.display_msg()
manual_mode = disk.LvmLayoutType.Manual.display_msg()

options = [manual_mode]
if disk_config.config_type == disk.DiskLayoutType.Default:
options = [default_mode, manual_mode]
elif disk_config.config_type == disk.DiskLayoutType.Manual:
options = [manual_mode]
else:
raise ValueError(f'Unsupported disk config type for LVM configuration: {disk_config.config_type.value}')

preset_value = preset.config_type.display_msg() if preset else None
warning = str(_('Are you sure you want to reset this setting?'))

Expand All @@ -194,7 +201,9 @@ def select_lvm_config(
case MenuSelectionType.Skip: return preset
case MenuSelectionType.Reset: return None
case MenuSelectionType.Selection:
if choice.value == manual_mode:
if choice.single_value == default_mode:
return suggest_lvm_layout()
elif choice.single_value == manual_mode:
lvm_config = LvmConfigurationMenu(preset, {}, disk_config.device_modifications).run()
return lvm_config
return preset
Expand Down Expand Up @@ -440,3 +449,25 @@ def suggest_multi_disk_layout(
home_device_modification.add_partition(home_partition)

return [root_device_modification, home_device_modification]


def suggest_lvm_layout(disk_config: disk.DiskLayoutConfiguration) -> disk.LvmConfiguration:
lvm_pvs: List[disk.PartitionModification] = []

for mod in disk_config.device_modifications:
for part in mod.partitions:
lvm_pvs.append(part)

lvm_vol_group = disk.LvmVolumeGroup('VolGroup', lvm_pvs=lvm_pvs)

home_vol = disk.LvmVolume(

)



return disk.LvmConfiguration(
disk.LvmLayoutType.Default,
lvm_pvs=lvm_pvs,
lvm_vol_group
)

0 comments on commit 137970b

Please sign in to comment.