From 299977926c31d7bc04345b44c43a61c5198b0a71 Mon Sep 17 00:00:00 2001 From: Thierry Laurion Date: Thu, 26 Jan 2023 15:03:03 -0500 Subject: [PATCH] usb-scan->media-scan: usb-init calling media-scan usb media-scan accepts direct input of existing blkid and mount that passed device to /media --- initrd/bin/{usb-scan => media-scan} | 15 +++++++++++++-- initrd/bin/usb-init | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) rename initrd/bin/{usb-scan => media-scan} (82%) diff --git a/initrd/bin/usb-scan b/initrd/bin/media-scan similarity index 82% rename from initrd/bin/usb-scan rename to initrd/bin/media-scan index 91a6447b..9cea4fea 100755 --- a/initrd/bin/usb-scan +++ b/initrd/bin/media-scan @@ -11,8 +11,19 @@ if grep -q /boot /proc/mounts ; then || die "Unable to unmount /boot" fi -# Mount the USB boot device -mount_usb || die "Unable to mount /media" +available_partitions="$(blkid | while read line; do echo $line | awk -F ":" {'print $1'}; done )" + +if [ "$1" == "usb" ]; then + # Mount the USB boot device + mount_usb || die "Unable to mount /media" +elif $(echo $available_partitions | grep -q "$1"); then + if grep -q /media /proc/mounts; then + umount /media \ + || die "Unable to unmount /media" + fi + mount "$1" /media \ + || die "Unable to mount $1 to /media" +fi # Get USB boot device USB_BOOT_DEV=$(grep "/media" /etc/mtab | cut -f 1 -d' ') diff --git a/initrd/bin/usb-init b/initrd/bin/usb-init index 4a52b262..bc0abaf4 100755 --- a/initrd/bin/usb-init +++ b/initrd/bin/usb-init @@ -9,5 +9,5 @@ if [ "$CONFIG_TPM" = "y" ]; then tpm extend -ix 4 -ic usb fi -usb-scan +media-scan usb recovery "Something failed during USB boot"