5

Running Raspbian on RPi 2B:

Perhaps foolishly I've chosen the RPi for a significant development that needs much more than its internal flash storage, so have attached a terabyte USB drive as sda1. During power-on boot the following is reported:

[10.872768] sd 0:0:0:0 [sda] 1953525168 512-byte logical blocks: (1.00 TB/931 GiB) / failed

This is despite the following line having been inserted to /etc/fstab:

/dev/sda1 /mnt auto defaults,exec 0 2

Thereafter the drive cannot be accessed except by performing a commanded mount. Or a reboot. Obviously the problem occurs because the Western Digital "Bookcase" drive becomes operational from power-on slower than the RPi. A few seconds "sleep" added to the boot process almost anywhere before that failure would synchronize the two.

The question is, where and how to issue the sleep? Progress through the Raspbian boot sequence scripts in /etc is not at all clear.

4
  • have you considered powering the drive from a usb hub that is always on? Jun 30, 2015 at 15:31
  • Thanks for the suggestion. That would work, but I'm congenitally opposed to leaving powered devices up all night.
    – rlsj
    Jun 30, 2015 at 15:42
  • so plug the hub in and count to 20. Jun 30, 2015 at 15:45
  • 2
    I'm asking where to install a "sleep," thank you.
    – rlsj
    Jun 30, 2015 at 15:46

4 Answers 4

11

There are two entries you can add to /boot/config.txt to delay boot.

boot_delay=x
Wait for x seconds in start.elf before loading kernel.
Default 1.

boot_delay_ms=x
Wait for x milliseconds in start.elf before loading kernel.
Default 0.

Boot delay = 1000 * boot_delay + boot_delay_ms.

See http://elinux.org/RPiconfig#Boot

2
  • Joan, I was wrong apparently. Adding "boot_delay=16" (after trying 4 and 8) didn't make a difference. Bootup still reports "/dev/sda1 not available / failed." But I defintely notice the slower startup. You gave me what I asked for.
    – rlsj
    Jun 30, 2015 at 19:05
  • @rlsj Thanks for the update. Strange that it does not make a difference, perhaps the drive has to be accessed before it starts to spin-up.
    – joan
    Jun 30, 2015 at 19:47
3

To my knowledge, there's no way in which you can put a sleep mode in your fstab entry. If it's not possible to leave the RPi on all the time, I would mount the drive using the root user's crontab and the @reboot flag.

The key part you'll need is bash's sleep command.

Steps:

  1. sudo crontab -e
  2. add the line @reboot sleep {time in seconds} ; {mount cmd here}
  3. save
  4. exit
  5. test it

Warning: Do not try to use a sleep call in an init script. Init scripts are processed sequentially, and if you sleep in one, all others will wait until that one finishes.

1

I think what you're looking for is a way to automatically mount a USB drive, see if usbmount works for you. Installation is:

sudo apt-get install -y usbmount

For more info, check out this answer.

0

I had the same problem. I wrote a quick and dirty "delay" (5 seconds) program in C. I called the program in rc.local, then ran mount -a (mount -a re-runs fstab) on the next line of rc.local. this allowed time for my hdd to spin up on my raspberry minidlna server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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