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
Signed-off-by: Gerald Elder-Vass <[email protected]>
  • Loading branch information
Gerald Elder-Vass authored and GeraldEV committed Oct 18, 2024
1 parent 0d91e2d commit 819ed35
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 @@ -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:
Expand Down Expand Up @@ -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)
Expand All @@ -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()
Expand Down

0 comments on commit 819ed35

Please sign in to comment.