Jump to content

Johnclark

Validating
  • Posts

    1
  • Joined

  • Last visited

  1. #!/bin/sh echo "Start script create MBR and filesystem" hasdrives=$(lsblk | grep -oE '(mmcblk[0-9])' | sort | uniq) if [ "$hasdrives" = "" ] then echo "UNABLE TO FIND ANY EMMC OR SD DRIVES ON THIS SYSTEM!!! " exit 1 fi avail=$(lsblk | grep -oE '(mmcblk[0-9]|sda[0-9])' | sort | uniq) if [ "$avail" = "" ] then echo "UNABLE TO FIND ANY DRIVES ON THIS SYSTEM!!!" exit 1 fi # Unmount /var/log.hdd so logic below can find the root partition umount /var/log.hdd # Use mount instead of lsblk to find the root device runfrom=$(mount | grep ' / ' | awk '{print $1}') # Ensure we found the root device if [ "$runfrom" = "" ] then echo " UNABLE TO FIND ROOT OF THE RUNNING SYSTEM!!! " exit 1 fi # Extract only the base device name (e.g., mmcblk0 instead of mmcblk0p2) runfrom_base=$(echo "$runfrom" | sed 's/[0-9]//g') # List available eMMC/SD devices and remove the root device from the list avail=$(lsblk | grep -oE '(mmcblk[0-9]|sda[0-9])' | sort | uniq | grep -v "$runfrom_base") # Ensure we found some available drives after excluding the root device if [ "$avail" = "" ] then echo "UNABLE TO FIND ANY DRIVES ON THIS SYSTEM!!!" exit 1 fi # Now identify the target eMMC (mmcblk1) emmc=$(echo "$avail" | grep 'mmcblk1') # Ensure mmcblk1 is found and that we're not running from it if [ "$emmc" = "" ] then echo " UNABLE TO FIND YOUR EMMC DRIVE OR YOU ARE ALREADY RUNNING FROM EMMC!!!" exit 1 fi DEV_EMMC="/dev/$emmc" echo "Target eMMC device is: $DEV_EMMC" # Rest of your script logic continues from here... try changing the script to this it worked for me (the suggestion is made by chatgpt, no guarantee it will work and contains details that probably only applies to my device)
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines