LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Udev creates the external usb hard disk device node too late (https://www.linuxquestions.org/questions/linux-software-2/udev-creates-the-external-usb-hard-disk-device-node-too-late-809438/)

pastoreerrante 05-22-2010 04:24 AM

Udev creates the external usb hard disk device node too late
 
Hi all,

on my debian lenny OS I have an external usb hard disk I would like to automount it at boot.

So I edited the /etc/fstab file in order to automount /dev/sdb1. It worked without problem.

Then I recompiled the kernel and, as consequence, /dev/sdb1 changed to /dev/sdc1. I started playing with udev in order to match the now called /dev/sdc1 and to change its name in /dev/maxtor (being maxtor the brand of the hard disk). Obviously I edited also /etc/fstab: /dev/sdb1 is now /dev/maxtor.

The boot automount doesn't work anymore. On the boot sequence I can read the message "Mounting local filesystem...mount: special device /dev/maxtor does not exist FAILED".

But when I log into the system I can run the command "mount /dev/maxtor /mnt/maxtor" and it works! So, IMHO, my udev rule is correct otherwise also the manual mount wouldn't work, right?

How can I fix this? I have to tell to udev to create /dev/maxtor BEFORE the boot automount process.

Thank you in advance,

Daniele

Update: I tried to delete my udev rule and to edit /etc/fstab changing /dev/maxtor in /dev/sdc1 (the name udev gave to my hard disk after kernel recompile, before was /dev/sdb1) and it didn't work: on boot process I always see the "Mounting local filesystem...mount: special device /dev/sdc1 does not exist FAILED".

Then I tried to change /dev/sdc1 in /dev/sdb1 in /etc/fstab and to reboot with the old original kernel and int this way it works. This is a weird problem, now it seems related to kernel change. With my compiled kernel, the OS seems to have lost the capacity to detect my device node correctly...any clues???

Shadow_7 05-22-2010 07:39 AM

Two workarounds IMO.

1) Change the point in the boot sequence that udev loads. Or repeat that step by adding a second entry for it.

ls /etc/rc2.d/*

the S## is the start order. K## are termination order. rc#.d is the run level. Debian defaults to run level 2, see inittab. So it should be the only one you HAVE to change on a typical system.

or

2) Add a step at the end of the boot sequence to try again.

# echo "mount /dev/sdc1" >> /etc/rc2.d/S99z_custom
# chmod +x /etc/rc2.d/S99z_custom

And various other ways. You could try to reconfigure udev.

# dpkg-reconfigure udev

But if you didn't use debian tools make-kpkg in relation to your new kernel it might not do much. You might also try adding usb module loading to /etc/modules (old school), or just use an initrd image or include usb support in the kernel and not as a module. Things have to load in a particular sequence. Which doesn't always go as planned if you deviate from the script (custom kernel).

If you need to compile against a distro kernel you can always install the headers. Make the module(s) and copy or move them into the tree manually and run depmod. One way to work around wireless drivers and proprietary video drivers and the likes while still running a distro supplied kernel. And therefor staying within the confines of the script.

pastoreerrante 05-24-2010 12:42 AM

Thank you for the reply.

I solved putting the following script in /etc/init.d/

Code:

#! /bin/sh
# /etc/init.d/mountmaxtor.sh
#

case "$1" in
  start)
    echo "Mounting Maxtor Hard Disk"
    mount /dev/sdc1 /mnt/maxtor
    ;;
  stop)
    echo "Umounting Maxtor Hard Disk"
    umount /dev/sdc1 /mnt/maxtor
    ;;
  *)
    echo "Usage: /etc/init.d/mountmaxtor.sh {start|stop}"
    exit 1
    ;;
esac

exit 0

Then I gave the command "update-rc.d mountmaxtor.sh defaults" to create the simbolic links to my script in the /etc/rcX.d/ directories. This is the best practise in debian world to add a script at boot time AFAIK.

Regards, Daniele


All times are GMT -5. The time now is 09:07 AM.