Commit 57c01bb7 authored by mntmn's avatar mntmn
Browse files

reform-boot-config: add support for eMMC

parent 61a21894
......@@ -5,44 +5,51 @@ if [ "$EUID" -ne 0 ]
exit
fi
echo "This script selects your preferred boot medium. It writes your choice to the file /reform-boot-medium on the SD card. This file is interpreted by /sbin/reform-init at boot."
echo "If the preferred boot medium is not available at boot time, reform-init will fall back to booting from the SD card."
echo "This script selects your preferred boot medium. It writes your choice to the file /reform-boot-medium on the SD card (or eMMC). This file is interpreted by /sbin/reform-init at boot."
echo "If the preferred boot medium is not available at boot time, reform-init will fall back to booting from the SD card (or eMMC)."
echo
BOOTPREF=""
BOOTPREF="$1"
BOOTPART="mmcblk1p1"
BOOTDISK="SD card"
case "$1" in
sd) BOOTPREF="sd";;
nvme) BOOTPREF="nvme";;
usb) BOOTPREF="usb";;
esac
if [[ "--emmc" == "$1" ]]
then
BOOTPREF="$2"
BOOTPART="mmcblk0p1"
BOOTDISK="eMMC"
fi
if [[ "x$BOOTPREF" == "x" ]]
if [[ "$BOOTPREF" != "sd" && "$BOOTPREF" != "nvme" && "$BOOTPREF" != "usb" ]]
then
echo "Usage: "
echo " reform-boot-config sd Boot from SD card (default)."
echo " reform-boot-config nvme Boot from NVMe SSD (encrypted or plain)."
echo " reform-boot-config usb Boot from USB storage device (encrypted or plain)."
exit
echo " reform-boot-config sd Boot from SD card or eMMC (default)."
echo " reform-boot-config nvme Boot from NVMe SSD (encrypted or plain)."
echo " reform-boot-config usb Boot from USB storage device (encrypted or plain)."
echo ""
echo " reform-boot-config --emmc nvme|usb Record boot preference on eMMC instead of SD card."
echo " This is only useful with SoM dip switch turned off."
exit 1
fi
MOUNTED_AT=$(mount | grep mmcblk1p1 | grep "on /" | cut -d ' ' -s -f 3)
MOUNTED_AT=$(mount | grep $BOOTPART | grep "on /" | cut -d ' ' -s -f 3)
if [[ "x$MOUNTED_AT" != "x" ]]
then
echo "Found SD card mounted at $MOUNTED_AT."
echo "Found $BOOTDISK mounted at $MOUNTED_AT."
echo "$BOOTPREF" > "${MOUNTED_AT}/reform-boot-medium"
echo "Boot medium choice $BOOTPREF recorded in ${MOUNTED_AT}/reform-boot-medium."
echo "Restart MNT Reform (type: reboot) after saving your work to activate the changes."
exit
fi
echo "Assuming your system is not running from SD card. Mounting /dev/mmcblk1p1 on /boot."
echo "Assuming your system is not running from $BOOTDISK. Mounting /dev/$BOOTPART on /boot."
mount /dev/mmcblk1p1 /boot
mount /dev/$BOOTPART /boot
if [ $? -eq 0 ]
then
echo "$BOOTPREF" > "/boot/reform-boot-medium"
echo "Boot medium choice $BOOTPREF recorded in /boot/reform-boot-medium."
echo "Boot medium choice $BOOTPREF recorded in /reform-boot-medium on $BOOTPART."
echo "Restart MNT Reform (type: reboot) after saving your work to activate the changes."
umount /boot
exit
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment