Package: partman-efi
Severity: important
Tags: d-i

Some installation processes (e.g. The installation of vanilla Debian ARM64 on a Raspberry Pi 4 in UEFI mode) greatly benefit from extracting the Debian installation files from mini.iso or netinst.iso into an ESP and then using that same ESP for the final system.

On the Raspberry Pi, the reason one might want to do that, outside of enabling the use of a single media as both the source and the target for the installation (which is a good enough reason per se, that applies to more that the Pi platform), is that it alleviates having to manually duplicate the necessary bootloader files and UEFI firmware that are necessary for the platform to boot, into a different target ESP.

However, since this results in /cdrom and /boot/efi sharing the same underlying device, and /cdrom is mounted read-only, the attempt to mount the ESP as /boot/efi in partman returns a fatal error (with the message: "The attempt to mount a file system with type vfat in SCSI1 (0,0,0), partition #1 (sda) at /boot/efi failed") due to the Linux kernel not allowing the same device to be mounted both ro and rw at the same time.

This patch fixes this in the script that sets the /boot/efi mount by:
* Detecting the underlying device used by the /cdrom mountpoint.
* Remounting /cdrom rw if that device is the same as the one that will
  be used to mount /boot/efi.

This patch was tested by modifying the partman-efi_84_arm64.udeb package from a recent nestinst testing ISO, and proceeding through an installation.

Also please note that, as per https://github.com/pftf/RPi4/issues/76, this is one of the very last showstopper we have to enable the use of *vanilla* Debian 11 installation ISOs to install the OS on the Raspberry Pi 4. As such so we would greatly appreciate if this patch could be reviewed and applied quickly.

Thank you,

/Pete
From dff3328ce6243956254e1d71e7b72dc93ce0c103 Mon Sep 17 00:00:00 2001
From: Pete Batard <p...@akeo.ie>
Date: Wed, 5 Aug 2020 00:12:40 +0100
Subject: [PATCH] Remount /cdrom read-write if it also happens to be used as
 /boot/efi

---
 fstab.d/efi | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
 mode change 100755 => 100644 fstab.d/efi

diff --git a/fstab.d/efi b/fstab.d/efi
old mode 100755
new mode 100644
index 14b6696..8fe688c
--- a/fstab.d/efi
+++ b/fstab.d/efi
@@ -12,6 +12,15 @@ case $ARCH in
        ;;
 esac
 
+# Resolve the device that is mounted as /cdrom
+cdrom_device=
+while IFS=" " read -r f1 f2 f3 f4 f5 f6
+do
+       if [ $f2 == "/cdrom" ]; then
+               cdrom_device=$f1
+       fi
+done < /proc/mounts
+
 seen_efi=
 for dev in $DEVICES/*; do
        [ -d $dev ] || continue
@@ -23,6 +32,13 @@ for dev in $DEVICES/*; do
                [ -f "$id/method" ] || continue
                method=$(cat $id/method)
                [ "$method" = efi ] || continue
+               # If the device we are mounting as /boot/efi also happens to
+               # be the /cdrom device, we must remount it read-write, else
+               # the mounting of /boot/efi fails.
+               if [ "$path" == "$cdrom_device" ]; then
+                       log "Remounting /cdrom read-write for use as ESP"
+                       mount -o remount,rw "$path" /cdrom
+               fi
                echo "$path" /boot/efi vfat umask=0077 0 1
                seen_efi=1
        done
-- 
2.21.0.windows.1

Reply via email to