FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > CentOS > CentOS

 
 
LinkBack Thread Tools
 
Old 02-04-2010, 12:15 PM
Mogens Kjaer
 
Default Mount USB disk at startup?

I have a CentOS 5 machine with an external 500G USB disk,
formatted with JFS.

How do I get this to mount automatically at boot time?

If I add to /etc/fstab:

/dev/sdb1 /var/video jfs defaults 1 2

fsck.jfs complains at boot time:

Error: Cannot open device /dev/sdb1

Usage: fsck.jfs ...

...

Give root password for maintenance
...

If I log in with the root password, /dev/sdb1
is present, and I can run

fsck.jfs -f /dev/sdb1

without problems. After ctrl-D it reboots, and gives
the above error again.

I have to log in as root, remount,rw / and remove
the /dev/sdb1 line from /etc/fstab to get it to boot.

The problem is not related to JFS; it occurs with
an external ext3 file system as well.

How do I mount /dev/sdb1 automatically at boot?

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@crc.dk Homepage: http://www.crc.dk
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 02-04-2010, 12:37 PM
Mogens Kjaer
 
Default Mount USB disk at startup?

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@crc.dk Homepage: http://www.crc.dk
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 02-04-2010, 12:41 PM
Eero Volotinen
 
Default Mount USB disk at startup?

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
 
Old 02-04-2010, 12:54 PM
Stephen Harris
 
Default 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
 
Old 02-04-2010, 01:10 PM
Mogens Kjaer
 
Default 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

--
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@crc.dk Homepage: http://www.crc.dk
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 02-04-2010, 01:29 PM
Robert C Wittig
 
Default Mount USB disk at startup?

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Mogens Kjaer wrote:

>
> How do I mount /dev/sdb1 automatically at boot?
>
> Mogens
>


Try adding 'user' to the 'options' field in /etc/fstab:

http://www.tuxfiles.org/linuxhelp/fstab.html

- --
- -wittig
http://www.robertwittig.com/
http://robertwittig.net/
http://robertwittig.org/
.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)
Comment: Using GnuPG with CentOS - http://enigmail.mozdev.org/

iQEVAwUBS2rZzf9qkhAVPSgqAQIoiwf8Dkmq/PDXToqQJN470lAY/ssky3FukAu5
RTFPfqPolGNXOTorrXIanxWsued7vYT4MexOBeYFPWHl+auaGP awp21OIOWlXVJa
NcWjNZIepml+P6WLPeEQMwLQXiv7E03FdImmVyjQm9gUVsrEGX VoBt1GAz9A5L+F
W70az7LVA9iO7RTvOua0RdhdKYr1K1lrmefUjQJ6TaN2Ie4Ejf 4aV03LTeeUX9Xo
u8bYjBBynvM1KK4d2e9O32PU9KW2V85OJF3Jo5nMuHtcBQcJzD E1J7TzNyEIkEne
a0+08JhND73yjFqzHjkasiuIYKlDcHbLb7hUtloCXFP0hqz9Qd/TXg==
=0p4M
-----END PGP SIGNATURE-----
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 02-04-2010, 01:36 PM
Robert Nichols
 
Default Mount USB disk at startup?

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
 
Old 02-04-2010, 01:57 PM
Mogens Kjaer
 
Default 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.

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@crc.dk Homepage: http://www.crc.dk
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 02-04-2010, 01:57 PM
Warren Young
 
Default Mount USB disk at startup?

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
 
Old 02-04-2010, 09:19 PM
Kenneth Porter
 
Default 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
 

Thread Tools




All times are GMT. The time now is 07:38 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org