From 1bd93d66790075403ca193417b11e21d2eb2447b Mon Sep 17 00:00:00 2001 From: Matt DeVillier Date: Wed, 19 Feb 2020 22:16:39 -0600 Subject: [PATCH] Eliminate use of CONFIG_USB_BOOT_DEV mount-usb switched to dynamic USB device detection a while back, so eliminate instances of CONFIG_BOOT_USB_DEV, and derive the mounted USB device from /etc/mtab in the one place where it's actually needed (usb-scan). Clean up areas around calls to mount-usb for clarity/readability. Addresses issue #673 Test: Build Librem 13v4, boot ISO file on USB Signed-off-by: Matt DeVillier --- boards/kgpe-d16/kgpe-d16.config | 1 - boards/leopard/leopard.config | 1 - boards/librem13v2/librem13v2.config | 1 - boards/librem13v4/librem13v4.config | 1 - boards/librem15v3/librem15v3.config | 1 - boards/librem15v4/librem15v4.config | 1 - boards/qemu-coreboot/qemu-coreboot.config | 1 - boards/qemu-linuxboot/qemu-linuxboot.config | 1 - boards/r630/r630.config | 1 - boards/s2600wf/s2600wf.config | 1 - boards/t420/t420.config | 1 - boards/tioga/tioga.config | 1 - boards/winterfell/winterfell.config | 1 - boards/x220/x220.config | 1 - boards/x230-flash/x230-flash.config | 1 - boards/x230/x230.config | 1 - initrd/bin/flash-gui.sh | 12 +++++------- initrd/bin/gpg-gui.sh | 12 +++++------- initrd/bin/usb-scan | 4 +++- initrd/init | 3 --- 20 files changed, 13 insertions(+), 34 deletions(-) diff --git a/boards/kgpe-d16/kgpe-d16.config b/boards/kgpe-d16/kgpe-d16.config index d34aa60c..072f36ac 100644 --- a/boards/kgpe-d16/kgpe-d16.config +++ b/boards/kgpe-d16/kgpe-d16.config @@ -28,7 +28,6 @@ export CONFIG_BOOT_REQ_ROLLBACK=n export CONFIG_BOOT_KERNEL_ADD="nohz=on console=ttyS1,115200n8 " export CONFIG_BOOT_KERNEL_REMOVE="" export CONFIG_BOOT_DEV="/dev/sda1" -export CONFIG_USB_BOOT_DEV="/dev/sdb1" export CONFIG_BOOT_RECOVERY_SERIAL="/dev/ttyS0" export CONFIG_FLASHROM_OPTIONS="--force --noverify -p internal" #export CONFIG_BOOT_STATIC_IP=192.168.1.2 diff --git a/boards/leopard/leopard.config b/boards/leopard/leopard.config index d0471623..672ed47f 100644 --- a/boards/leopard/leopard.config +++ b/boards/leopard/leopard.config @@ -42,7 +42,6 @@ export CONFIG_TPM=n export CONFIG_BOOT_REQ_HASH=n export CONFIG_BOOT_REQ_ROLLBACK=n export CONFIG_BOOT_DEV="/dev/sda1" -export CONFIG_USB_BOOT_DEV="/dev/sdb1" $(build)/$(BOARD)/linuxboot.rom: linuxboot.intermediate diff --git a/boards/librem13v2/librem13v2.config b/boards/librem13v2/librem13v2.config index 515bd773..2d3f3aca 100644 --- a/boards/librem13v2/librem13v2.config +++ b/boards/librem13v2/librem13v2.config @@ -32,7 +32,6 @@ export CONFIG_BOOT_KERNEL_ADD="intel_iommu=on" export CONFIG_BOOT_KERNEL_REMOVE="" export CONFIG_BOOT_DEV="/dev/nvme0n1p1" export CONFIG_BOOT_GUI_MENU_NAME="Purism Librem 13v2 Heads Boot Menu" -export CONFIG_USB_BOOT_DEV="/dev/sdb1" export CONFIG_WARNING_BG_COLOR="--background-gradient 0 0 0 150 125 0" export CONFIG_ERROR_BG_COLOR="--background-gradient 0 0 0 150 0 0" export CONFIG_FLASHROM_OPTIONS="-p internal:laptop=force_I_want_a_brick,ich_spi_mode=hwseq" diff --git a/boards/librem13v4/librem13v4.config b/boards/librem13v4/librem13v4.config index ece2fc5c..e1a4bbc0 100644 --- a/boards/librem13v4/librem13v4.config +++ b/boards/librem13v4/librem13v4.config @@ -32,7 +32,6 @@ export CONFIG_BOOT_KERNEL_ADD="intel_iommu=on" export CONFIG_BOOT_KERNEL_REMOVE="" export CONFIG_BOOT_DEV="/dev/nvme0n1p1" export CONFIG_BOOT_GUI_MENU_NAME="Purism Librem 13v2 Heads Boot Menu" -export CONFIG_USB_BOOT_DEV="/dev/sdb1" export CONFIG_WARNING_BG_COLOR="--background-gradient 0 0 0 150 125 0" export CONFIG_ERROR_BG_COLOR="--background-gradient 0 0 0 150 0 0" export CONFIG_FLASHROM_OPTIONS="-p internal:laptop=force_I_want_a_brick,ich_spi_mode=hwseq" diff --git a/boards/librem15v3/librem15v3.config b/boards/librem15v3/librem15v3.config index 9174b50c..2580e15b 100644 --- a/boards/librem15v3/librem15v3.config +++ b/boards/librem15v3/librem15v3.config @@ -34,7 +34,6 @@ export CONFIG_BOOT_KERNEL_ADD="intel_iommu=on" export CONFIG_BOOT_KERNEL_REMOVE="" export CONFIG_BOOT_DEV="/dev/nvme0n1p1" export CONFIG_BOOT_GUI_MENU_NAME="Purism Librem 15v3 Heads Boot Menu" -export CONFIG_USB_BOOT_DEV="/dev/sdb1" export CONFIG_WARNING_BG_COLOR="--background-gradient 0 0 0 150 125 0" export CONFIG_ERROR_BG_COLOR="--background-gradient 0 0 0 150 0 0" export CONFIG_FLASHROM_OPTIONS="-p internal:laptop=force_I_want_a_brick,ich_spi_mode=hwseq" diff --git a/boards/librem15v4/librem15v4.config b/boards/librem15v4/librem15v4.config index cd922461..107be032 100644 --- a/boards/librem15v4/librem15v4.config +++ b/boards/librem15v4/librem15v4.config @@ -34,7 +34,6 @@ export CONFIG_BOOT_KERNEL_ADD="intel_iommu=on" export CONFIG_BOOT_KERNEL_REMOVE="" export CONFIG_BOOT_DEV="/dev/nvme0n1p1" export CONFIG_BOOT_GUI_MENU_NAME="Purism Librem 15v4 Heads Boot Menu" -export CONFIG_USB_BOOT_DEV="/dev/sdb1" export CONFIG_WARNING_BG_COLOR="--background-gradient 0 0 0 150 125 0" export CONFIG_ERROR_BG_COLOR="--background-gradient 0 0 0 150 0 0" export CONFIG_FLASHROM_OPTIONS="-p internal:laptop=force_I_want_a_brick,ich_spi_mode=hwseq" diff --git a/boards/qemu-coreboot/qemu-coreboot.config b/boards/qemu-coreboot/qemu-coreboot.config index 1dc02569..aeb57c78 100644 --- a/boards/qemu-coreboot/qemu-coreboot.config +++ b/boards/qemu-coreboot/qemu-coreboot.config @@ -49,7 +49,6 @@ export CONFIG_BOOTSCRIPT=/bin/generic-init export CONFIG_TPM=n export CONFIG_BOOT_DEV="/dev/sda1" -export CONFIG_USB_BOOT_DEV="/dev/sdb1" #run: coreboot.intermediate run: diff --git a/boards/qemu-linuxboot/qemu-linuxboot.config b/boards/qemu-linuxboot/qemu-linuxboot.config index 730ce633..4a9a3317 100644 --- a/boards/qemu-linuxboot/qemu-linuxboot.config +++ b/boards/qemu-linuxboot/qemu-linuxboot.config @@ -36,7 +36,6 @@ export CONFIG_BOOTSCRIPT_NETWORK=/bin/network-init-recovery export CONFIG_BOOT_REQ_HASH=n export CONFIG_BOOT_REQ_ROLLBACK=n export CONFIG_BOOT_DEV="/dev/sda1" -export CONFIG_USB_BOOT_DEV="/dev/sdb1" export CONFIG_BOOT_STATIC_IP=10.0.2.15 # You can ssh into the qemu instance by running diff --git a/boards/r630/r630.config b/boards/r630/r630.config index 23c8d43b..8f24f057 100644 --- a/boards/r630/r630.config +++ b/boards/r630/r630.config @@ -28,4 +28,3 @@ export CONFIG_BOOTSCRIPT=/bin/generic-init export CONFIG_BOOT_REQ_HASH=n export CONFIG_BOOT_REQ_ROLLBACK=n export CONFIG_BOOT_DEV="/dev/sda1" -export CONFIG_USB_BOOT_DEV="/dev/sdb1" diff --git a/boards/s2600wf/s2600wf.config b/boards/s2600wf/s2600wf.config index 8af98511..2c810da0 100644 --- a/boards/s2600wf/s2600wf.config +++ b/boards/s2600wf/s2600wf.config @@ -40,4 +40,3 @@ export CONFIG_BOOTSCRIPT=/bin/generic-init export CONFIG_BOOT_REQ_HASH=n export CONFIG_BOOT_REQ_ROLLBACK=n export CONFIG_BOOT_DEV="/dev/sda1" -export CONFIG_USB_BOOT_DEV="/dev/sdb1" diff --git a/boards/t420/t420.config b/boards/t420/t420.config index 7d436d91..ea440642 100644 --- a/boards/t420/t420.config +++ b/boards/t420/t420.config @@ -31,7 +31,6 @@ export CONFIG_BOOT_KERNEL_ADD="intel_iommu=on intel_iommu=igfx_off" export CONFIG_BOOT_KERNEL_REMOVE="quiet" export CONFIG_BOOT_DEV="/dev/sda1" export CONFIG_BOOT_GUI_MENU_NAME="ThinkPad T420 Heads Boot Menu" -export CONFIG_USB_BOOT_DEV="/dev/sdb1" export CONFIG_WARNING_BG_COLOR="--background-gradient 0 0 0 150 125 0" export CONFIG_ERROR_BG_COLOR="--background-gradient 0 0 0 150 0 0" export CONFIG_FLASHROM_OPTIONS="--force --noverify-all -p internal:laptop=force_I_want_a_brick,ich_spi_mode=hwseq --ifd --image bios" diff --git a/boards/tioga/tioga.config b/boards/tioga/tioga.config index f1144254..af16c1ce 100644 --- a/boards/tioga/tioga.config +++ b/boards/tioga/tioga.config @@ -43,7 +43,6 @@ export CONFIG_TPM=n export CONFIG_BOOT_REQ_HASH=n export CONFIG_BOOT_REQ_ROLLBACK=n export CONFIG_BOOT_DEV="/dev/sda1" -export CONFIG_USB_BOOT_DEV="/dev/sdb1" $(build)/$(BOARD)/linuxboot.rom: linuxboot.intermediate diff --git a/boards/winterfell/winterfell.config b/boards/winterfell/winterfell.config index 8e457c6b..b49421c2 100644 --- a/boards/winterfell/winterfell.config +++ b/boards/winterfell/winterfell.config @@ -42,7 +42,6 @@ export CONFIG_TPM=n export CONFIG_BOOT_REQ_HASH=n export CONFIG_BOOT_REQ_ROLLBACK=n export CONFIG_BOOT_DEV="/dev/sda1" -export CONFIG_USB_BOOT_DEV="/dev/sdb1" #$(build)/$(BOARD)/linuxboot.rom: $(build)/$(linuxboot_dir)/ diff --git a/boards/x220/x220.config b/boards/x220/x220.config index 5840d872..3af04149 100644 --- a/boards/x220/x220.config +++ b/boards/x220/x220.config @@ -31,7 +31,6 @@ export CONFIG_BOOT_KERNEL_ADD="intel_iommu=on intel_iommu=igfx_off" export CONFIG_BOOT_KERNEL_REMOVE="quiet" export CONFIG_BOOT_DEV="/dev/sda1" export CONFIG_BOOT_GUI_MENU_NAME="ThinkPad X220 Heads Boot Menu" -export CONFIG_USB_BOOT_DEV="/dev/sdb1" export CONFIG_WARNING_BG_COLOR="--background-gradient 0 0 0 150 125 0" export CONFIG_ERROR_BG_COLOR="--background-gradient 0 0 0 150 0 0" export CONFIG_FLASHROM_OPTIONS="--force --noverify-all -p internal:laptop=force_I_want_a_brick,ich_spi_mode=hwseq --ifd --image bios" diff --git a/boards/x230-flash/x230-flash.config b/boards/x230-flash/x230-flash.config index 0cce6673..5530ba27 100644 --- a/boards/x230-flash/x230-flash.config +++ b/boards/x230-flash/x230-flash.config @@ -15,7 +15,6 @@ CONFIG_LINUX_CONFIG=config/linux-x230-flash.config CONFIG_LINUX_USB=y CONFIG_LINUX_E1000E=y -export CONFIG_USB_BOOT_DEV="/dev/sdb1" export CONFIG_BOOTSCRIPT=/bin/x230-flash.init export CONFIG_FLASHROM_OPTIONS="--force --noverify-all -p internal:laptop=force_I_want_a_brick,ich_spi_mode=hwseq --ifd --image bios" diff --git a/boards/x230/x230.config b/boards/x230/x230.config index f800b6a8..ad49270e 100644 --- a/boards/x230/x230.config +++ b/boards/x230/x230.config @@ -31,7 +31,6 @@ export CONFIG_BOOT_KERNEL_ADD="intel_iommu=on intel_iommu=igfx_off" export CONFIG_BOOT_KERNEL_REMOVE="quiet" export CONFIG_BOOT_DEV="/dev/sda1" export CONFIG_BOOT_GUI_MENU_NAME="Thinkpad X230 Heads Boot Menu" -export CONFIG_USB_BOOT_DEV="/dev/sdb1" export CONFIG_WARNING_BG_COLOR="--background-gradient 0 0 0 150 125 0" export CONFIG_ERROR_BG_COLOR="--background-gradient 0 0 0 150 0 0" export CONFIG_FLASHROM_OPTIONS="--force --noverify-all -p internal:laptop=force_I_want_a_brick,ich_spi_mode=hwseq --ifd --image bios" diff --git a/initrd/bin/flash-gui.sh b/initrd/bin/flash-gui.sh index 8a4e05b9..c8cbd364 100755 --- a/initrd/bin/flash-gui.sh +++ b/initrd/bin/flash-gui.sh @@ -7,16 +7,14 @@ set -e -o pipefail mount_usb(){ # Mount the USB boot device if ! grep -q /media /proc/mounts ; then - mount-usb "$CONFIG_USB_BOOT_DEV" && USB_FAILED=0 || USB_FAILED=1 + mount-usb && USB_FAILED=0 || USB_FAILED=1 if [ $USB_FAILED -ne 0 ]; then - if [ ! -e "$CONFIG_USB_BOOT_DEV" ]; then - whiptail --title 'USB Drive Missing' \ - --msgbox "Insert your USB drive and press Enter to continue." 16 60 USB_FAILED=0 - mount-usb "$CONFIG_USB_BOOT_DEV" || USB_FAILED=1 - fi + whiptail --title 'USB Drive Missing' \ + --msgbox "Insert your USB drive and press Enter to continue." 16 60 + mount-usb && USB_FAILED=0 || USB_FAILED=1 if [ $USB_FAILED -ne 0 ]; then whiptail $CONFIG_ERROR_BG_COLOR --title 'ERROR: Mounting /media Failed' \ - --msgbox "Unable to mount $CONFIG_USB_BOOT_DEV" 16 60 + --msgbox "Unable to mount USB device" 16 60 fi fi fi diff --git a/initrd/bin/gpg-gui.sh b/initrd/bin/gpg-gui.sh index c7d179e3..9ab70b6c 100755 --- a/initrd/bin/gpg-gui.sh +++ b/initrd/bin/gpg-gui.sh @@ -7,16 +7,14 @@ set -e -o pipefail mount_usb(){ # Mount the USB boot device if ! grep -q /media /proc/mounts ; then - mount-usb "$CONFIG_USB_BOOT_DEV" || USB_FAILED=1 + mount-usb && USB_FAILED=0 || USB_FAILED=1 if [ $USB_FAILED -ne 0 ]; then - if [ ! -e "$CONFIG_USB_BOOT_DEV" ]; then - whiptail --title 'USB Drive Missing' \ - --msgbox "Insert your USB drive and press Enter to continue." 16 60 USB_FAILED=0 - mount-usb "$CONFIG_USB_BOOT_DEV" || USB_FAILED=1 - fi + whiptail --title 'USB Drive Missing' \ + --msgbox "Insert your USB drive and press Enter to continue." 16 60 + mount-usb && USB_FAILED=0 || USB_FAILED=1 if [ $USB_FAILED -ne 0 ]; then whiptail $CONFIG_ERROR_BG_COLOR --title 'ERROR: Mounting /media Failed' \ - --msgbox "Unable to mount $CONFIG_USB_BOOT_DEV" 16 60 + --msgbox "Unable to mount USB device" 16 60 fi fi fi diff --git a/initrd/bin/usb-scan b/initrd/bin/usb-scan index 4d576555..a9debdf5 100755 --- a/initrd/bin/usb-scan +++ b/initrd/bin/usb-scan @@ -15,6 +15,8 @@ if ! grep -q /media /proc/mounts ; then mount-usb "$CONFIG_USB_BOOT_DEV" \ || die "Unable to mount /media" fi +# Get USB boot device +USB_BOOT_DEV=$(grep "/media" /etc/mtab | cut -f 1 -d' ') # Check for ISO first get_menu_option() { @@ -72,7 +74,7 @@ if [ `cat /tmp/iso_menu.txt | wc -l` -gt 0 ]; then if [ -n "$option" ]; then MOUNTED_ISO=$option ISO=${option:7} # remove /media/ to get device relative path - kexec-iso-init $MOUNTED_ISO $ISO $CONFIG_USB_BOOT_DEV + kexec-iso-init $MOUNTED_ISO $ISO $USB_BOOT_DEV die "Something failed in iso init" fi diff --git a/initrd/init b/initrd/init index 509024bf..40063dea 100755 --- a/initrd/init +++ b/initrd/init @@ -97,9 +97,6 @@ combine_configs if [ ! -z "$CONFIG_BOOT_DEV" ]; then echo >> /etc/fstab "$CONFIG_BOOT_DEV /boot auto defaults,ro 0 0" fi -if [ ! -z "$CONFIG_USB_BOOT_DEV" ]; then - echo >> /etc/fstab "$CONFIG_USB_BOOT_DEV /media auto defaults,ro 0 0" -fi if [ ! -x "$CONFIG_BOOTSCRIPT" -a ! -x "$CONFIG_BOOTSCRIPT_NETWORK" ]; then recovery 'Boot script missing? Entering recovery shell'