From 3c1589082301f2bbe9b8a58279e5a342ce85e839 Mon Sep 17 00:00:00 2001 From: Codex Date: Tue, 13 Oct 2026 22:29:56 +0300 Subject: [PATCH] Mount installer root and ESP using their known filesystem types --- hydra/installer.py | 8 ++++---- tests/test_installer.py | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/hydra/installer.py b/hydra/installer.py index 14f2b91..cc50f79 100644 --- a/hydra/installer.py +++ b/hydra/installer.py @@ -509,10 +509,10 @@ def render_plan(request, target, root): ['mount', '-t', 'btrfs', '-o', 'subvol=@home', part, str(Path(root) / 'home')], ['mount', '-t', 'btrfs', '-o', 'subvol=@snapshots', part, str(Path(root) / '.snapshots')]]) else: - commands.append(['mount', part, str(root)]) + commands.append(['mount', '-t', 'ext4', part, str(root)]) commands += [ ['unsquashfs', '-f', '-d', str(root), request.payload], - ['mount', esp, str(Path(root) / 'boot/efi')], + ['mount', '-t', 'vfat', esp, str(Path(root) / 'boot/efi')], ['blkid', '-s', 'UUID', '-o', 'value', part], ['blkid', '-s', 'UUID', '-o', 'value', esp], ['mount', '--rbind', '/dev', str(Path(root) / 'dev')], @@ -744,7 +744,7 @@ def install(request, runner, probe, root, password, log: TextIO): (root / directory).mkdir() mount(['mount', '-t', 'btrfs', '-o', 'subvol=' + subvolume, part, str(root / directory)], root / directory) else: - mount(['mount', part, str(root)], root) + mount(['mount', '-t', 'ext4', part, str(root)], root) run(['unsquashfs', '-f', '-d', str(root), request.payload]) kernel = select_kernel(root, request.kernel) remove_live_files(root) @@ -753,7 +753,7 @@ def install(request, runner, probe, root, password, log: TextIO): raise InstallError('Timezone does not exist in payload: ' + request.timezone) for folder in ('boot/efi', 'dev', 'proc', 'sys'): target_path(root, folder).mkdir(parents=True, exist_ok=True) - mount(['mount', esp, str(root / 'boot/efi')], root / 'boot/efi') + mount(['mount', '-t', 'vfat', esp, str(root / 'boot/efi')], root / 'boot/efi') root_uuid = run(['blkid', '-s', 'UUID', '-o', 'value', part]).strip() esp_uuid = run(['blkid', '-s', 'UUID', '-o', 'value', esp]).strip() if any(not re.fullmatch(r'[A-Fa-f0-9-]+', value) for value in (root_uuid, esp_uuid)): diff --git a/tests/test_installer.py b/tests/test_installer.py index 847033c..77e758f 100644 --- a/tests/test_installer.py +++ b/tests/test_installer.py @@ -187,6 +187,17 @@ class PartitionGuardTests(unittest.TestCase): self.assertIn('/dev/vda3',topo.parents['/dev/loop0']) self.assertEqual(i.validate_request(partition_request(),probe),'/dev/vda2') + def test_dry_run_mounts_use_requested_root_and_validated_esp_types(self): + for request in (i.Request('/dev/vda', 'emil'), partition_request()): + with self.subTest(mode='disk' if request.disk else 'partitions'): + target='/dev/vda' if request.disk else '/dev/vda2' + plan=i.render_plan(request,target,'/mnt/target') + self.assertIn('mount -t ext4 /dev/vda2 /mnt/target',plan) + self.assertIn('mount -t vfat /dev/vda1 /mnt/target/boot/efi',plan) + btrfs_plan=i.render_plan(partition_request(root_fs='btrfs'),'/dev/vda2','/mnt/target') + self.assertIn('mount -t btrfs -o subvol=@root /dev/vda2 /mnt/target',btrfs_plan) + self.assertIn('mount -t vfat /dev/vda1 /mnt/target/boot/efi',btrfs_plan) + def test_partition_plan_formats_only_root_and_preserves_efi(self): req = partition_request() plan = i.render_plan(req, '/dev/vda2', '/mnt/target') @@ -279,6 +290,11 @@ class PartitionPipelineTests(unittest.TestCase): self.assertEqual(runner.calls, []) self.assertFalse((self.root/'etc/fstab').exists()) + def test_partition_execution_mounts_known_filesystem_types_explicitly(self): + runner=FakeRunner(self.root); self.install(runner) + self.assertIn(['mount','-t','ext4','/dev/vda2',str(self.root)],runner.calls) + self.assertIn(['mount','-t','vfat','/dev/vda1',str(self.root/'boot/efi')],runner.calls) + def test_existing_mode_formats_root_only_and_records_owned_layout(self): runner = FakeRunner(self.root) self.install(runner) @@ -518,6 +534,11 @@ class PipelineTests(unittest.TestCase): self.assertIn('6.12.1', dracut) self.assertEqual(runner.calls[-1], ['umount', str(self.root)]) + def test_whole_disk_execution_mounts_created_filesystem_types_explicitly(self): + runner=FakeRunner(self.root); self.install(runner) + self.assertIn(['mount','-t','ext4','/dev/vda2',str(self.root)],runner.calls) + self.assertIn(['mount','-t','vfat','/dev/vda1',str(self.root/'boot/efi')],runner.calls) + def test_whole_disk_installs_owned_loader_and_fallback(self): runner=FakeRunner(self.root); self.install(runner) boot_commands=[c for c in runner.calls if 'grub-install' in c]