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?
2010/2/4 Mogens Kjaer <mk@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?
how about mounting that drive on rc.local ?
--
Eero
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
02-04-2010, 12:54 PM
Stephen Harris
Mount USB disk at startup?
On Thu, Feb 04, 2010 at 02:37:06PM +0100, Mogens Kjaer wrote:
> It turns out to be some sort of race condition:
The problem with USB disks is that they aren't always "ready" as quickly
as the rest of the OS, so the kernel hasn't been able to detect them yet.
What you might be able to do is use autofs to mount the disk for you
when you try to access the mount point. As long as that's not part
of the boot sequence (ie it's something someone does when they login)
then there's a good chance the disk will be detected.
Alternatively, don't set it to mount in fstab and then create an rc script
which does a poll-wait for the disk to appear and runs the mount command
for you.
--
rgds
Stephen
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
02-04-2010, 01:10 PM
Mogens Kjaer
Mount USB disk at startup?
On 02/04/2010 02:41 PM, Eero Volotinen wrote:
...
> how about mounting that drive on rc.local ?
That's too late; I need it before /etc/init.d/mythbackend
starts.
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.
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
02-04-2010, 01:57 PM
Mogens Kjaer
Mount USB disk at startup?
On 02/04/2010 03:36 PM, Robert Nichols wrote:
...
> Be sure to put a timeout in that loop lest it hang
> forever if that external device is absent.
>
Yes, I have added the following:
for (( times = 1; times < 120; times++ )); do
echo Wait for /dev/sdb1 $times
if [ -b /dev/sdb1 ]; then
break;
fi
sleep 1
done
I should perhaps add some more lines that
comments out the /dev/sdb1 line from fstab
if the drive doesn't show up in 120 secs.
On 2/4/2010 7:10 AM, Mogens Kjaer wrote:
> On 02/04/2010 02:41 PM, Eero Volotinen wrote:
> ...
>> how about mounting that drive on rc.local ?
>
> That's too late; I need it before /etc/init.d/mythbackend
> starts.
# ls /etc/rc`runlevel | cut -c3`.d/*myth*
Then write a script in /etc/init.d to wait for the USB drive to appear,
and link it to an "S" value one less than used by mythbackend for your
runlevel. That is, if you find mythbackend is S42mythbackend in your
normal starting runlevel, you link /etc/init.d/mydrivewaiter to
S41mydrivewaiter.
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
02-04-2010, 09:19 PM
Kenneth Porter
Mount USB disk at startup?
--On Thursday, February 04, 2010 8:36 AM -0600 Robert Nichols
<rnicholsNOSPAM@comcast.net> wrote:
> 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.
Even better would be to make the script event-driven and launched by the
hotplug process. Then there's no busy-wait.
This page has some info:
<http://linux.die.net/man/8/hotplug>
The detail links on this page aren't working for me but look promising:
<http://linux-hotplug.sourceforge.net/>
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos