Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

restore.py/restoreFromBackup(): Ensure esp mount point is known before setting EFI boot entries #161

Merged
merged 1 commit into from
Oct 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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