[CentOS] Mount USB disk at startup?

Thu Feb 4 14:36:38 UTC 2010
Robert Nichols <rnicholsNOSPAM at comcast.net>

Mogens Kjaer wrote:
> On 02/04/2010 02:15 PM, Mogens Kjaer wrote:
> ...
>> How do I mount /dev/sdb1 automatically at boot?
> 
> It turns out to be some sort of race condition:
> 
> If I modify /etc/rc.d/rc.sysinit:
> 
> ...
>          STRING=$"Checking filesystems"
>          echo $STRING
>          sleep 2
>          echo ls 1
>          ls -l /dev/sdb*
>          sleep 1
>          echo ls 2
>          ls -l /dev/sdb*
>          sleep 1
>          echo ls 3
>          ls -l /dev/sdb*
>          sleep 1
>          echo ls 4
>          ls -l /dev/sdb*
> 
> then I get the following on startup:
> 
> Checking filesystems
> ls 1
> ls: /dev/sdb*: No such file or directory
> ls 2
> ls: /dev/sdb*: No such file or directory
> ls 3
> brw-r----- 1 root disk 8, 16 Feb  4 14:28 /dev/sdb
> brw-r----- 1 root disk 8, 17 Feb  4 14:28 /dev/sdb1
> ls 4
> brw-r----- 1 root disk 8, 16 Feb  4 14:28 /dev/sdb
> brw-r----- 1 root disk 8, 17 Feb  4 14:28 /dev/sdb1
> 
> Then the machine boots normally.
> 
> I'll add a sleep loop to rc.sysinit that waits until /dev/sdb1 is
> available, unless someone has a better suggestion?

Looks like that's about all you can do.  USB devices aren't available until
hotplug discovers them, and that's proceeding in parallel with the rest
of the boot sequence.  Be sure to put a timeout in that loop lest it hang
forever if that external device is absent.

-- 
Bob Nichols     "NOSPAM" is really part of my email address.
                 Do NOT delete it.