3

Sometime my external hard drive is dismounted even though I had configure ftsab correctly and using powered usb hub for the drive. I usually solve this this by rebooting the system.

Can someone provide a script to automatically reboot the Raspberry Pi if the drive is not mounted, or other solution to keep the drive mounted?

1
#!/bin/bash  
if [ ! $(find /mnt/point | wc -l) -gt 1 ]; then  
  reboot  
fi  

There's a really simple one. It finds the directory that you've mounted the hdd to, and checks to see if there are files under it.
If there aren't any files under the directory, it will reboot. Alternatively, rather than rebooting, you could make the script mount the hard drive again using mount -a

0
#!/bin/bash  
if [ ! $(find /mnt/point | wc -l) -gt 1 ]; then  
    reboot  
fi  

save this script as rebooter.sh. Then use crontab to run it every 5 minutes or so. Remember, this will automatically reboot your system, sometimes at inopportune times.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.