clix
Posts: 18
Joined: Fri Jun 27, 2014 4:51 pm

[Solved] Raspberry Pi USB Boot

Thu Aug 28, 2014 2:06 pm

Basically I have code in init.d to check at boottime that a certain memory pen is plugged in. Once I see that it works, I'll configure it to shutdown again if the pen is not detected. Unfortuantely it won't work. I have made it executable and tested it with bash usbboot start, when it works then, but still it doesn't work at boot. I think it even causes two of the "Starting this..." lines near the end to merge into one.

Code: Select all

#!/bin/bash
# /etc/init.d/usbboot
 
### BEGIN INIT INFO
# Provides:             USB Secure Booting
# Required-Start:       $remote_fs $syslog
# Required-Stop:        $remote_fs $syslog
# Default-Start         2 3 4 5
# Default-Stop:         0 1 6
#END INIT INFO
 
 
id="USB ID HERE"
 
case "$1" in
 start)
  if [ -z 'lsusb | grep "$id"' ]
  then
        echo "USB Key Not Found"
  else
        echo "USB Key Found"
  fi
  ;;
 stop)
  ;;
 *)
  echo "Usage /etc/init.d/usbboot {start|stop}"
  exit 1
  ;;
esac
 
exit 0
Last edited by clix on Fri Aug 29, 2014 1:19 pm, edited 1 time in total.

User avatar
DougieLawson
Posts: 39120
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Raspberry Pi USB Boot

Thu Aug 28, 2014 7:06 pm

Try using blkid /dev/sda.

You can also use those blkids in your /etc/fstab to ensure that the wrong USB pen drive can't be mounted.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

clix
Posts: 18
Joined: Fri Jun 27, 2014 4:51 pm

Re: [Solved] Raspberry Pi USB Boot

Fri Aug 29, 2014 1:20 pm

Solved. Needed update-rc.d to actually run it. Thanks for the suggestion Dougie, I'll try that out if I have time.

Return to “Advanced users”