Skip to content

Commit

Permalink
Ensure esp mount point is known before setting EFI boot entries
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerald Elder-Vass authored and GeraldEV committed Oct 4, 2024
1 parent f1331f1 commit 5e10dc7
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions restore.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand All @@ -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()
Expand Down

0 comments on commit 5e10dc7

Please sign in to comment.