[CentOS] Mount USB disk at startup?

Thu Feb 4 13:37:06 UTC 2010
Mogens Kjaer <mk at crc.dk>

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?

Mogens

-- 
Mogens Kjaer, Carlsberg A/S, Computer Department
Gamle Carlsberg Vej 10, DK-2500 Valby, Denmark
Phone: +45 33 27 53 25, Mobile: +45 22 12 53 25
Email: mk at crc.dk Homepage: http://www.crc.dk