LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   slackware 12.0, udev rules for usb-dev works, but mounting does not work correct (http://www.linuxquestions.org/questions/linux-general-1/slackware-12-0-udev-rules-for-usb-dev-works-but-mounting-does-not-work-correct-798613/)

paalmarker 03-29-2010 05:52 AM

slackware 12.0, udev rules for usb-dev works, but mounting does not work correct
 
Slackware 12.0 , kernel 2.6.21.5-smp

I have a system that is going to handle different usb sticks for different purposes. Files are to be copied to the usb stick managed by perl script inside a web interface, i.e apache is the executing user. Now I have 3 usb-sticks to handle, I label the usb_sticks : ak_install1, ak_install2. ak_install3. Each stick has its entry in /etc/fstab, and each usb-stick has its own rule in /etc/udev/rules.d/10-local.rules

If I start /etc/rc.d/udev with the rules active mounting fails:
mount: wrong fs type, bad option, bad superblock on /dev/ak_install3,
missing codepage or other error

dmesg shows :
FAT: bogus number of reserved sectors
VFS: Can't find a valid FAT filesystem on dev sdc2.


I have made udev rules for making them mount with these entries in /etc/fstab:
/dev/ak_install1 / mnt/ak_install1 vfat rw,users,owner,noauto,uid=apache,gid=apache 0 0
/dev/ak_install2 /mnt/ak_install2 vfat rw,users,owner,noauto,uid=apache,gid=apache 0 0
/dev/ak_install3 /mnt/ak_install3 vfat rw,users,owner,noauto,uid=apache,gid=apache 0 0



Udev rules:
/etc/udev/rules.d/10-local.rules:
ATTRS{serial}=="0019E02CCA0EA910095A40FD", NAME="ak_install1", OWNER="apache", GROUP="apache", MODE="0777"
ATTRS{serial}=="001372997D4BA91009629318", NAME="ak_install2", OWNER="apache", GROUP="apache", MODE="0777"
ATTRS{serial}=="0013729B6F4BA9100961E067", NAME="ak_install3", OWNER="apache", GROUP="apache", MODE="0777"

User permitions should absolutely be ok, for being sure that is not the problem I have set to wide open everywhere.

ls -lh /dev/ak_install*
brwxrwxrwx 1 apache plugdev 8, 34 2010-03-29 09:53 /dev/ak_install2

I have tried out different ways to restart udev to get a clue of what is going on here:
If for instance 'mount /mnt/ak_install3' fails;
mount: wrong fs type, bad option, bad superblock on /dev/ak_install3,
missing codepage or other error
if I deactivate the udev-rules in /etc/udev/rules.d/10-local.rules with # in front of the lines, then '/etc/rc.d/rc.udev restart', then open /etc/udev/rules.d/10-local.rules again and activate the rules by uncommenting, then again /etc/rc.d/rc.udev restart , the 'mount /mnt/ak_install3 mounts fine. But then if I change stick and 'mount /mnt/ak_install2 it fails. If I repeat the procedure of twice restarting udev with deactivated and then activated rules in /etc/udev/rules.d/10-local.rules and mount /mnt/ak_install2 it works for that stick, but not for the others.

I have tried to also with hal-daemon turned off, does not help.

If I deactivate the rules in /etc/udev/rules.d/10-local.rules and mount with 'mount -t vfat /dev/sdc1 /mnt/ak_install<1,2 or 3>' , all the sticks mounts fine, no problem. So I guessed the problem had to be the udev rules I made. But if I put in the sticks and run ''udevinfo -a -p $(udevinfo -q path -n /dev/ak_install<1,2 or 3) I get the correct output for each stick. So the rules are working fine, concerning recognition.

The problem excist weather I mount as apache or root.

Could anyone please give me a clue of where I can go from here?

Paal Marker

catkin 03-29-2010 06:21 AM

Quote:

Originally Posted by paalmarker (Post 3916533)
ls -lh /dev/ak_install*
brwxrwxrwx 1 apache plugdev 8, 34 2010-03-29 09:53 /dev/ak_install2
This shows the GROUP= is not effective

I have tried out different ways to restart udev to get a clue of what is going on here:
If for instance 'mount /mnt/ak_install3' fails;
mount: wrong fs type, bad option, bad superblock on /dev/ak_install3,
missing codepage or other error
if I deactivate the udev-rules in /etc/udev/rules.d/10-local.rules with # in front of the lines, then '/etc/rc.d/rc.udev restart', then open /etc/udev/rules.d/10-local.rules again and activate the rules by uncommenting, then again /etc/rc.d/rc.udev restart , the 'mount /mnt/ak_install3 mounts fine. But then if I change stick and 'mount /mnt/ak_install2 it fails. If I repeat the procedure of twice restarting udev with deactivated and then activated rules in /etc/udev/rules.d/10-local.rules and mount /mnt/ak_install2 it works for that stick, but not for the others.
I'm not clear at what points in that test the devices are plugged and unplugged. A list would be easier to understand.

I would try:
  1. Moving the rules file to 90-local.rules (so it is processed last and its intended effect is not removed by later rules)
  2. Simplify the rules to only set the name (that is the thing least likely to cause breakage).
  3. Test. If the mount works OK, add the USER= and retest, if that works add the GROUP= and retest.
  4. Update this thread :)

paalmarker 03-29-2010 07:59 AM

Seems that by putting the local rules to last, 90-local.rules I am overriding some rules in the file 50-udev.rules. I can not see anything in that file though, that should be overruled by the rules in 90-local.rules:
ATTRS{serial}=="0019E02CCA0EA910095A40FD", NAME="ak_install1"
ATTRS{serial}=="001372997D4BA91009629318", NAME="ak_install2"
ATTRS{serial}=="0013729B6F4BA9100961E067", NAME="ak_install3"


By mounting now I get constant output message "mount: /dev/ak_install3 is not a block device" . Overriding /etc/fstab entries by .mount -t vfat /dev/ak_install2 /mnt/ak_install2 gives the same result.

catkin 03-29-2010 08:22 AM

Quote:

Originally Posted by paalmarker (Post 3916658)
Seems that by putting the local rules to last, 90-local.rules I am overriding some rules in the file 50-udev.rules. I can not see anything in that file though, that should be overruled by the rules in 90-local.rules:
ATTRS{serial}=="0019E02CCA0EA910095A40FD", NAME="ak_install1"
ATTRS{serial}=="001372997D4BA91009629318", NAME="ak_install2"
ATTRS{serial}=="0013729B6F4BA9100961E067", NAME="ak_install3"


By mounting now I get constant output message "mount: /dev/ak_install3 is not a block device" . Overriding /etc/fstab entries by .mount -t vfat /dev/ak_install2 /mnt/ak_install2 gives the same result.

At least the experiments are having some effect! Keep poking it in different ways and study the outcome in the hope of gaining understanding -- same as CERN but a lot cheaper!

Might be worth examining the rules in /lib/udev/rules.d for possible inter-action. Might be worth changing your rule to set only USER and see what happens.

What little knowledge I have about udev comes from tinkering with Slackware 13.0 so details may vary.

paalmarker 03-29-2010 09:50 AM

Thank you very much for your replies.

OK, plugging in and out usb sticks to test....editing the rules files....restarting /etc/rc.d/rc.udev sometimes.... and I find that there is something very strange here.

I put in a usb-stick, try to mount it and get failure message: mount: wrong fs type, bad option, bad superblock on /dev/ak_install1,
missing codepage or other error
In some cases useful info is found in syslog - try
dmesg | tail or so

Dmesg again:
FAT: bogus number of reserved sectors
VFS: Can't find a valid FAT filesystem on dev sdc2.

But now I discover that if I unplug the usb-stick, and then put it in again, try to mount, if failed then try again, then at last it mount successfully. But this is not due to failing hardware, as this problem I have only when udev rules are active.

paalmarker 03-30-2010 01:51 AM

All experiments done in udev since I started to work with it, seems to have made a salad of whole the udev configuration. During a reboot of the server I got lots of messages from udev showing that configuration is not correct, and after reboot the udevinfo command does not work either. Anyway, this server is to be reinstalled anyway in a couple of weeks. So until then I let this problem rest.


All times are GMT -5. The time now is 01:04 PM.