Browse Source

Auto detect boot partition

Bohan Yang 5 years ago
parent
commit
a60ae20642
2 changed files with 13 additions and 4 deletions
  1. 1 1
      README.md
  2. 12 3
      debi.sh

+ 1 - 1
README.md

@@ -77,7 +77,7 @@ To **revert** all changes, run
  * `--hold` Don't reboot or power off after installation
  * `--power-off` Power off after installation rather than reboot
  * `--architecture <string>` e.g. `amd64`, `i386`, `arm64`, `armhf`, etc.
- * `--boot-partition` Should be used if `/boot` directory is mounted from a dedicated partition like a LVM setup
+ * `--boot-directory <string>`
  * `--firmware` Load additional [non-free firmwares](https://wiki.debian.org/Firmware#Firmware_during_the_installation)
  * `--force-efi-extra-removable` [See](https://wiki.debian.org/UEFI#Force_grub-efi_installation_to_the_removable_media_path). **Useful on Oracle Cloud**
  * `--grub-timeout 5` How many seconds the GRUB menu shows before entering the installer

+ 12 - 3
debi.sh

@@ -84,7 +84,7 @@ bbr=false
 hold=false
 power_off=false
 architecture=
-boot_directory=/boot/
+boot_directory=
 firmware=false
 force_efi_extra_removable=false
 grub_timeout=5
@@ -235,8 +235,9 @@ while [ $# -gt 0 ]; do
             architecture=$2
             shift
             ;;
-        --boot-partition)
-            boot_directory=/
+        --boot-directory)
+            boot_directory=$2
+            shift
             ;;
         --firmware)
             firmware=true
@@ -598,6 +599,14 @@ EOF
     save_grub_cfg="tee -a $grub_cfg"
 fi
 
+if [ -z "$boot_directory" ]; then
+    if grep -q '\s/boot\s' /proc/mounts; then
+        boot_directory=/
+    else
+        boot_directory=/boot/
+    fi
+fi
+
 installer_directory="$boot_directory$installer"
 
 # shellcheck disable=SC2034