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
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
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
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
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.
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.
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.
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
--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:
On Thu, 2010-02-04 at 14:19 -0800, Kenneth Porter wrote:
--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:
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!)
From: Ian Forde ianforde@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
John Doe wrote:
From: Ian Forde ianforde@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.
-----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/ .
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@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@crc.dk Homepage: http://www.crc.dk _______________________________________________ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
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=200 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=200 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
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#rootd...
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@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=200 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=200 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@crc.dk Homepage: http://www.crc.dk _______________________________________________ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos