summaryrefslogtreecommitdiffstats
path: root/src/utils/postinstall.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/postinstall.py')
-rw-r--r--src/utils/postinstall.py35
1 files changed, 26 insertions, 9 deletions
diff --git a/src/utils/postinstall.py b/src/utils/postinstall.py
index 94a7e4b..221da81 100644
--- a/src/utils/postinstall.py
+++ b/src/utils/postinstall.py
@@ -110,16 +110,33 @@ def configure_os_custom(disk, partition):
def windows_register_c_drive(disk, partition):
- cmd_configure = f"ogWindowsRegisterPartition {disk} {partition} C {disk} {partition}"
+ device = get_partition_device(disk, partition)
+ mountpoint = device.replace('dev', 'mnt')
- proc = subprocess.run(cmd_configure,
- stdout=subprocess.DEVNULL,
- stderr=subprocess.DEVNULL,
- encoding='utf-8',
- shell=True,
- check=True)
- if proc.returncode != 0:
- logging.warning(f'{cmd_configure} returned non-zero exit status {proc.returncode}')
+ if not mount_mkdir(device, mountpoint):
+ raise OgError(f'Unable to mount {device} into {mountpoint}')
+
+ hive_path = f'{mountpoint}{WINDOWS_HIVE_SYSTEM}'
+
+ try:
+ hive = hive_handler_open(hive_path, write=True)
+ root = hive.root()
+ device_node = get_node_child_from_path(hive, root, 'MountedDevices')
+
+ if is_uefi_supported():
+ part_id = get_part_id_bytes(disk, partition)
+ value = b'DMIO:ID:' + part_id
+ else:
+ disk_id = get_disk_id_bytes(disk)
+ part_offset = get_part_id_bytes(disk, partition)
+
+ value = bytes(disk_id + part_offset)
+
+ device_value = {'key': '\DosDevices\C:', 't': RegistryType.BINARY.value, 'value': value}
+ hive.node_set_value(device_node, device_value)
+ hive.commit(hive_path)
+ finally:
+ umount(mountpoint)
def configure_mbr_boot_sector(disk, partition):