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?

Jivings
  • 22,538
  • 11
  • 90
  • 139
user163125
  • 31
  • 1

2 Answers2

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

Lawrence
  • 2,672
  • 14
  • 14
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.

Joseph
  • 123
  • 1
  • 3