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

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

Closed
marmarek opened this issue Mar 8, 2015 · 5 comments · Fixed by QubesOS/qubes-core-admin-linux#159
Closed
Labels
C: core P: minor Priority: minor. The lowest priority, below "default." pr submitted A pull request has been submitted for this issue. T: enhancement Type: enhancement. A new feature that does not yet exist or improvement of existing functionality.

Comments

@marmarek
Copy link
Member

marmarek commented Mar 8, 2015

Reported by marmarek on 27 Jul 2014 20:49 UTC
https://groups.google.com/d/topic/qubes-devel/28AYrjm-DgM

it might make sense to check before updates to /boot whether it is actually mounted by checking whether there are any files in /boot.

I just noticed that qubes-dom0-update wrote to /boot without it being mounted (i.e. it wrote to a previously empty folder on /). I usually don't mount /boot in fstab, because it tends to make the boot process faster by a couple of seconds (& grub doesn't really seem to need it as it is more low-level).

Migrated-From: https://wiki.qubes-os.org/ticket/885

@marmarek marmarek added this to the Release 2.1 (post R2) milestone Mar 8, 2015
@marmarek marmarek added T: enhancement Type: enhancement. A new feature that does not yet exist or improvement of existing functionality. C: core P: minor Priority: minor. The lowest priority, below "default." labels Mar 8, 2015
@marmarek
Copy link
Member Author

marmarek commented Mar 8, 2015

Modified by marmarek on 27 Jul 2014 20:52 UTC

@andrewdavidwong
Copy link
Member

@marmarek: What is the current recommended workaround for this? Just always remember to plug in your USB drive and mount /boot before running qubes-dom0-update? (And if you forget, you have to manually mv the new files from the disk's /boot to the USB's /boot?)

@marmarek
Copy link
Member Author

marmarek commented May 8, 2016

Yes, something like this. You may do that after downloading updates
(when yum wait for confirmation) and you see kernel/bootloader/aem
updates.

Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?

@marmarek marmarek modified the milestones: Far in the future, Release 2.0 updates Oct 5, 2016
@andrewdavidwong andrewdavidwong removed this from the Release TBD milestone Aug 13, 2023
@alimirjamali
Copy link

After discussing this on forum with some of users who have boot on USB sticks, we came up with the following patch. No interactive query to mount the boot partition if updated via Qubes Update GUI as we do not want to introduce zenity to the workflow.

diff --git a/dom0-updates/qubes-dom0-update b/dom0-updates/qubes-dom0-update
index 01c4d6d..f0faa3e 100755
--- a/dom0-updates/qubes-dom0-update
+++ b/dom0-updates/qubes-dom0-update
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/bash
 
 has_template () {
     local arg
@@ -234,6 +234,43 @@ if [ -n "$CLEAN" ]; then
 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 or update via CLI."
+	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

@alimirjamali
Copy link

Patch is submitted:

QubesOS/qubes-core-admin-linux#159

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: core P: minor Priority: minor. The lowest priority, below "default." pr submitted A pull request has been submitted for this issue. T: enhancement Type: enhancement. A new feature that does not yet exist or improvement of existing functionality.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants