From 1157f8f191ae60d02753d37f0e916b2a2fff8662 Mon Sep 17 00:00:00 2001 From: Gerald Elder-Vass Date: Fri, 18 Oct 2024 08:25:19 +0000 Subject: [PATCH] Ensure esp mount point is known before setting EFI boot entries Signed-off-by: Gerald Elder-Vass --- restore.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/restore.py b/restore.py index 3da45cc9..7209a250 100644 --- a/restore.py +++ b/restore.py @@ -150,10 +150,11 @@ def restore_partitions(): dest_fs = util.TempMount(restore_partition, 'restore-dest-') efi_mounted = False try: + mounts = {'root': dest_fs.mount_point, 'boot': os.path.join(dest_fs.mount_point, 'boot')} if efi_boot: - esp = os.path.join(dest_fs.mount_point, 'boot', 'efi') - os.makedirs(esp) - util.mount(boot_device, esp) + mounts['esp'] = os.path.join(dest_fs.mount_point, 'boot', 'efi') + os.makedirs(mounts['esp']) + util.mount(boot_device, mounts['esp']) efi_mounted = True # copy files from the backup partition to the restore partition: @@ -199,8 +200,6 @@ def restore_partitions(): (tool, restore_partition) = restore_partitions() dest_fs = util.TempMount(restore_partition, 'restore-dest-') - mounts = {'root': dest_fs.mount_point, 'boot': os.path.join(dest_fs.mount_point, 'boot')} - # prepare extra mounts for installing bootloader: util.bindMount("/dev", "%s/dev" % dest_fs.mount_point) util.bindMount("/sys", "%s/sys" % dest_fs.mount_point) @@ -224,7 +223,7 @@ def restore_partitions(): util.umount("%s/sys" % dest_fs.mount_point) util.umount("%s/dev" % dest_fs.mount_point) if efi_mounted: - util.umount(esp) + util.umount(mounts['esp']) dest_fs.unmount() finally: backup_fs.unmount()