From e72687b44b5968aa275f01a44c112e95a28121fb Mon Sep 17 00:00:00 2001 From: Gerald Elder-Vass Date: Fri, 26 Jul 2024 13:41:49 +0000 Subject: [PATCH] Ensure esp mount point is known before setting EFI boot entries --- restore.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/restore.py b/restore.py index 6da279cf..601891e4 100644 --- a/restore.py +++ b/restore.py @@ -84,10 +84,11 @@ def restoreFromBackup(backup, progress=lambda x: ()): 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: @@ -121,8 +122,6 @@ def restoreFromBackup(backup, progress=lambda x: ()): if m: bootlabel = m.group(1) - 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) @@ -149,7 +148,7 @@ def restoreFromBackup(backup, progress=lambda x: ()): 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()