Github Issue #885 - qubes-dom0-update could check whether /boot is mounted

OK. We have a working prototype. With some caveats. Here is the patch:

qubes-dom0-update patch
--- qubes-dom0-update.orig	2024-06-15 11:42:31.823712605 +0330
+++ qubes-dom0-update	2024-06-15 15:13:19.851313032 +0330
@@ -234,6 +234,43 @@
 fi
 rm -f /var/lib/qubes/updates/errors
 
+# Synopsis: check_mounted MOUNTPOINT
+check_mounted() {
+    local CHOICE
+    # No reason to check further if partition is not in fstab
+    awk -v PART="${1}" '!/^[ \t]*#/{ if ( $2 == PART ) { exit 0}} ENDFILE {exit -1}' < /etc/fstab
+    [[ ${?} -ne 0 ]] && return
+    # No reason to check further if partition is already mounted
+    awk -v PART="${1}" '{if ($2 == PART ) { exit 0 }} ENDFILE{exit -1}' < /proc/mounts
+    [[ ${?} -ne 0 ]] || return
+    # Ask user to manually mount partition if user is using GUI Updater
+    if [ ! -t 1 ]; then
+	echo "Could not decide about unmounted ${1} partition in non-interactive/GUI mode!"
+	echo "Please mount ${1} manually before proceeding with updates"
+	exit 1
+    fi
+    read -p "${1} partition is not mounted! mount it now? (y)es, (n)o, (a)bort operation " CHOICE
+    case ${CHOICE} in
+        y|Y)
+	    mount "${1}"
+	    if [[ ${?} -ne 0 ]]; then
+		echo "Mounting of ${1} was unsuccessful! aborting."
+		exit 1
+	    fi
+	    ;;
+	n|N) echo "Warning! Proceeding forward without mounting ${1}";;
+	a|A) echo Operation aborted!; exit 1;;
+	*) echo Invalid choice. Aborting!; exit 1;;
+    esac
+}
+
+if [ "$CHECK_ONLY" != "1" ]; then
+    # Check if /boot is mounted on split root systems
+    check_mounted "/boot"
+    # Check if efi partition is mounted on UEFI systems
+    [ -d /sys/firmware/efi ] && check_mounted "/boot/efi"
+fi
+
 echo "Using $UPDATEVM as UpdateVM to download updates for Dom0; this may take some time..." >&2
 
 # qvm-run by default auto-starts the VM if not running

We can not go interactive for GUI Updater. Since it needs zenity or something similar which is removed in R4.2. Here is the related Github issue. I guess aborting update with a warning is better than proceeding with update if user forgets to mount /boot & /boot/efi. Or Maybe force mount and then abort if fails in the GUI updater?

If qubes-dom0-update is aborted in GUI updater because of missing /boot (or /boot/efi), it still shows the green checkmark. This has nothing to do with this patch. GUI Updater does not check for subprocess.returncode of qubes-dom0-update (only does it for refresh). So unrelated bug and not our fault. It will show the green checkmark even if the actual update fails (maybe due to interrupted internet connection)

I could not understand the scenario of no entries in fstab but somehow needed to be mounted individually. I studied this scenario but it implies that boot resides within root. So no need to mount it.

1 Like