Skip to content

Commit 9797570

Browse files
committed
Improve mounting
1 parent e73b332 commit 9797570

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

atomic-update.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,12 +304,14 @@ def sigint_handler(signum, frame):
304304
shell_exec(f"snapper -c {snapper_root_config} delete {atomic_snap}")
305305
sys.exit(7)
306306
# find the device where root fs resides
307-
rootfs_device, ret = shell_exec("LC_ALL=C mount -l | grep 'on / type btrfs' | awk '{print $1}'")
307+
out, ret = shell_exec("LC_ALL=C findmnt --json /")
308308
if ret != 0:
309-
logging.error(f"Could not find root filesystem device from mountpoints. Discarding snapshot {atomic_snap}")
309+
logging.error(f"Could not find root filesystem device. Discarding snapshot {atomic_snap}")
310310
shell_exec(f"snapper -c {snapper_root_config} delete {atomic_snap}")
311311
sys.exit(8)
312-
logging.debug(f"Btrfs root FS device: {rootfs_device}")
312+
out = json.loads(out)["filesystems"][0]
313+
rootfs_device = out["source"].split("[")[0]
314+
logging.debug(f"Btrfs root device: {rootfs_device}")
313315
# populate temp dir with atomic snapshot mounts
314316
logging.info("Setting up temp mounts...")
315317
commands = f"""
@@ -395,12 +397,20 @@ def sigint_handler(signum, frame):
395397
command = f"mount -o subvol={subvol} {rootfs_device} {subdir}"
396398
logging.debug(command)
397399
os.system(command)
400+
# mount ESP if it exists
401+
out, ret = shell_exec("LC_ALL=C findmnt --json /boot/efi")
402+
if ret == 0:
403+
out = json.loads(out)["filesystems"][0]
404+
command = f"mount {out['source']} {out['target']}"
405+
logging.debug(command)
406+
os.system(command)
398407
logging.info("Executing systemctl daemon-reexec...")
399408
os.system("systemctl daemon-reexec")
400409
logging.info("Executing systemd-tmpfiles --create...")
401410
os.system("systemd-tmpfiles --create")
402411
logging.info("Applied default snapshot as new base for running system")
403412
logging.info("Running processes will not be restarted automatically")
413+
logging.info("Until the next reboot, bootloader changes must be made from a new atomic snapshot")
404414
sys.exit()
405415

406416
# Handle command: rollback

0 commit comments

Comments
 (0)