FAQ
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 at crc.dk Homepage: http://www.crc.dk

Search Discussions

  • Mogens Kjaer at Feb 4, 2010 at 1:37 pm
    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
  • Eero Volotinen at Feb 4, 2010 at 1:41 pm

    2010/2/4 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?
    how about mounting that drive on rc.local ?

    --
    Eero
  • Mogens Kjaer at Feb 4, 2010 at 2:10 pm
    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 at crc.dk Homepage: http://www.crc.dk
  • Warren Young at Feb 4, 2010 at 2:57 pm

    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.
  • Stephen Harris at Feb 4, 2010 at 1:54 pm

    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
  • Robert Nichols at Feb 4, 2010 at 2:36 pm

    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.
  • Mogens Kjaer at Feb 4, 2010 at 2:57 pm
    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 at crc.dk Homepage: http://www.crc.dk
  • Kenneth Porter at Feb 4, 2010 at 10:19 pm
    --On Thursday, February 04, 2010 8:36 AM -0600 Robert Nichols
    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/>
  • Ian Forde at Feb 4, 2010 at 11:05 pm

    On Thu, 2010-02-04 at 14:19 -0800, Kenneth Porter wrote:
    --On Thursday, February 04, 2010 8:36 AM -0600 Robert Nichols
    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/>
    Since the OP is looking to have their USB drive mounted before mythtv's
    backend process starts up, I'd recommend disabling the mythbackend
    startup script:

    chkconfig mythbackend off

    Then doing a manual mount in /etc/rc.local, followed by starting
    mythbackend.

    /sbin/mount /dev/sdb1 /wherever
    /sbin/service mythbackend start

    Of course, I wouldn't recommend using a USB drive for storing myth
    recordings, as it eventually bite you due to USB2's limited bandwidth...

    -I (also a mythtv user!)
  • John Doe at Feb 5, 2010 at 4:43 pm
    From: Ian Forde <ianforde at gmail.com>
    On Thu, 2010-02-04 at 14:19 -0800, Kenneth Porter wrote:
    --On Thursday, February 04, 2010 8:36 AM -0600 Robert Nichols
    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.
    Since the OP is looking to have their USB drive mounted before mythtv's
    backend process starts up, I'd recommend disabling the mythbackend
    startup script:

    chkconfig mythbackend off

    Then doing a manual mount in /etc/rc.local, followed by starting
    mythbackend.

    /sbin/mount /dev/sdb1 /wherever
    /sbin/service mythbackend start

    Of course, I wouldn't recommend using a USB drive for storing myth
    recordings, as it eventually bite you due to USB2's limited bandwidth...

    -I (also a mythtv user!)
    Hum... hoping in in the middle of the conversation but...
    I am mounting a usb disk through fstab; and the daemon (bacula) using it never complained...
    Aren't the filesystems mounted (rc.sysinit?) before most daemons...?
    Otherwise, just create a mounting init script with a starting priority lower than mythbackend.

    JD
  • Robert Nichols at Feb 6, 2010 at 12:34 am

    John Doe wrote:
    From: Ian Forde <ianforde at gmail.com>
    On Thu, 2010-02-04 at 14:19 -0800, Kenneth Porter wrote:
    --On Thursday, February 04, 2010 8:36 AM -0600 Robert Nichols
    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.
    Since the OP is looking to have their USB drive mounted before mythtv's
    backend process starts up, I'd recommend disabling the mythbackend
    startup script:

    chkconfig mythbackend off

    Then doing a manual mount in /etc/rc.local, followed by starting
    mythbackend.

    /sbin/mount /dev/sdb1 /wherever
    /sbin/service mythbackend start

    Of course, I wouldn't recommend using a USB drive for storing myth
    recordings, as it eventually bite you due to USB2's limited bandwidth...

    -I (also a mythtv user!)
    Hum... hoping in in the middle of the conversation but...
    I am mounting a usb disk through fstab; and the daemon (bacula) using it never complained...
    Aren't the filesystems mounted (rc.sysinit?) before most daemons...?
    Otherwise, just create a mounting init script with a starting priority lower than mythbackend.
    There lie the perils of jumping in late. The issue was not with mounting, but
    rather the boot-time fsck, which occurs earlier.

    --
    Bob Nichols "NOSPAM" is really part of my email address.
    Do NOT delete it.
  • Robert C Wittig at Feb 4, 2010 at 2:29 pm

    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/
    .
  • Jobst Schmalenbach at Feb 11, 2010 at 12:26 am
    There is a kernel option you can give to solve
    this problem, in /boot/grub/grub.con add to the end
    of the kernel line:

    rootdelay Xs

    where x is the amounty of time to wait before
    /root is mounted, however this is valid for
    everything else as well.

    play with X until you get it right.

    Jobst


    On Thu, Feb 04, 2010 at 02:15:25PM +0100, Mogens Kjaer (mk at crc.dk) wrote:
    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 at crc.dk Homepage: http://www.crc.dk
    _______________________________________________
    CentOS mailing list
    CentOS at centos.org
    http://lists.centos.org/mailman/listinfo/centos
    --
    Diplomacy: The art of saying, "Nice Doggy," until you can find a stick.
    0| | Jobst Schmalenbach, jobst at barrett.com.au, General Manager
    0| Barrett Consulting Group P/L & The Meditation Room P/L
    0|0|0| +61 3 9532 7677, POBox 277, Caulfield South, 3162, Australia
  • Mogens Kjaer at Feb 11, 2010 at 8:44 am

    On 02/11/2010 01:26 AM, Jobst Schmalenbach wrote:
    There is a kernel option you can give to solve
    this problem, in /boot/grub/grub.con add to the end
    of the kernel line:

    rootdelay Xs

    where x is the amounty of time to wait before
    /root is mounted, however this is valid for
    everything else as well.

    play with X until you get it right.
    I've tried changing grub.conf into:

    default=0
    timeout=5
    splashimage=(hd0,0)/grub/splash.xpm.gz
    hiddenmenu
    title CentOS (2.6.18-164.11.1.el5.centos.plus)
    root (hd0,0)
    kernel /vmlinuz-2.6.18-164.11.1.el5.centos.plus ro
    rootdelay 0 root=LABEL=/
    initrd /initrd-2.6.18-164.11.1.el5.centos.plus.img
    title CentOS (2.6.18-164.11.1.el5)
    root (hd0,0)
    kernel /vmlinuz-2.6.18-164.11.1.el5 ro rootdelay 0 root=LABEL=/
    initrd /initrd-2.6.18-164.11.1.el5.img

    but there's no delay at all (the "kernel" lines may have wrapped,
    they are on one line in the file).

    The kernel source has:

    static unsigned int __initdata root_delay;
    static int __init root_delay_setup(char *str)
    {
    root_delay = simple_strtoul(str, NULL, 0);
    return 1;
    }
    ...
    __setup("rootdelay=", root_delay_setup);

    and later:
    if (root_delay) {
    printk(KERN_INFO "Waiting %dsec before mounting root
    device...\n",
    root_delay);
    ssleep(root_delay);
    }

    The message "Waiting 200sec before mounting root device..." is never
    printed.

    Putting rootdelay= after root= makes no difference.

    Strange...

    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
  • Jobst Schmalenbach at Feb 11, 2010 at 11:38 pm
    Rather weird, could be that the delay is too long, it should be more like 10!

    http://codtech.com/wiki/index.php/CULT:_Kernel_command_line_parameters#rootdelay

    I have had a similar problem ... on one server I use USB backup disks
    which I swap on a regular base. On the occasion when I had to reboot
    it halted with the fsck not being able to check it ... so I put
    it in and nver looked back.


    Jobst


    On Thu, Feb 11, 2010 at 09:44:41AM +0100, Mogens Kjaer (mk at crc.dk) wrote:
    On 02/11/2010 01:26 AM, Jobst Schmalenbach wrote:

    There is a kernel option you can give to solve
    this problem, in /boot/grub/grub.con add to the end
    of the kernel line:

    rootdelay Xs

    where x is the amounty of time to wait before
    /root is mounted, however this is valid for
    everything else as well.

    play with X until you get it right.
    I've tried changing grub.conf into:

    default=0
    timeout=5
    splashimage=(hd0,0)/grub/splash.xpm.gz
    hiddenmenu
    title CentOS (2.6.18-164.11.1.el5.centos.plus)
    root (hd0,0)
    kernel /vmlinuz-2.6.18-164.11.1.el5.centos.plus ro
    rootdelay 0 root=LABEL=/
    initrd /initrd-2.6.18-164.11.1.el5.centos.plus.img
    title CentOS (2.6.18-164.11.1.el5)
    root (hd0,0)
    kernel /vmlinuz-2.6.18-164.11.1.el5 ro rootdelay 0 root=LABEL=/
    initrd /initrd-2.6.18-164.11.1.el5.img

    but there's no delay at all (the "kernel" lines may have wrapped,
    they are on one line in the file).

    The kernel source has:

    static unsigned int __initdata root_delay;
    static int __init root_delay_setup(char *str)
    {
    root_delay = simple_strtoul(str, NULL, 0);
    return 1;
    }
    ...
    __setup("rootdelay=", root_delay_setup);

    and later:
    if (root_delay) {
    printk(KERN_INFO "Waiting %dsec before mounting root
    device...\n",
    root_delay);
    ssleep(root_delay);
    }

    The message "Waiting 200sec before mounting root device..." is never
    printed.

    Putting rootdelay= after root= makes no difference.

    Strange...

    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
    _______________________________________________
    CentOS mailing list
    CentOS at centos.org
    http://lists.centos.org/mailman/listinfo/centos
    --
    People who fight may lose. People who do not fight have already lost. - Bertolt Brecht
    0| | Jobst Schmalenbach, jobst at barrett.com.au, General Manager
    0| Barrett Consulting Group P/L & The Meditation Room P/L
    0|0|0| +61 3 9532 7677, POBox 277, Caulfield South, 3162, Australia

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcentos @
categoriescentos
postedFeb 4, '10 at 1:15p
activeFeb 11, '10 at 11:38p
posts16
users10
websitecentos.org
irc#centos

People

Translate

site design / logo © 2021 Grokbase