LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 11-15-2010, 09:58 AM   #1
algernon_z
Member
 
Registered: Apr 2006
Location: Amsterdam
Distribution: Solaris 9, Solaris 10, OpenIndiana, Cisco IOS, RedHat Linux, CentOS
Posts: 37

Rep: Reputation: 0
Udev problem on CentOS 4.8


I use a CentOS 4.8 server, which is mandatory to some database types & versions we run on it.
On this machine I do have a problem with udev.
I 've read quite some manuals and tips about udev, but in spite of this, the new rules I make in /etc/udev/rules.d/10-local.rules ... do nothing.

This is what I want to do:
Put a USB stick into the USB-plug and mount this automatically. Then, after a successful mount, i want some files copied from the stick to somewhere on the system.
So I first want to make sure that this device always mount at the right mountpoint:
BUS=="usb", KERNEL=="sd?1", SYSFS{manufacturer}="Kingston", SYSFS{product}="DataTraveler 2.0", ATTR{size}=="1952640", NAME="%k", SYMLINK="usbhdd1"

But I just can't get it to work. This symlink doesn't show up.
CentOS just shows its default behaviour, like /var/log/messages says:
Nov 15 15:53:44 prof004 fstab-sync[4664]: added mount point /media/usbdisk for /dev/sdb1

Version:
CentOS release 4.8 (Final)
udev version here is a little bit older (it is using the old commands, like udevinfo).

# uname -a
Linux 2.6.9-89.31.1.ELsmp #1 SMP Tue Oct 19 17:42:26 EDT 2010 i686 i686 i386 GNU/Linux

I hope that some udev-kabuki can shed some light on this.

Thanks, Alge
 
Old 11-15-2010, 11:14 AM   #2
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
In the rule shown there is nothing that tells to mount the device under a fixed mount point. It just creates a symbolic link /dev/usbhdd1 that points to /dev/sdb1. Indeed, this is useful since you don't know a priori which device is assigned to the disk's partition: it can be /dev/sda1, /dev/sdb1, /dev/sdc1 and having a symbolic link named always the same, let you manually mount the disk using always:
Code:
mount -o <mount_options> /dev/usbhdd1 /some/mount/point
Eventually you can write a /etc/fstab entry to specify where the device /dev/usbhdd1 will be mounted, together with the mount options.

Since udev usually tries to automatically mount a newly inserted disk in a directory named as the disk label, you can try to create/change the volume label using the appropriate command. For example, if it is a FAT16 or FAT32 volume, you can try with the command mlabel from the mtools package. Example:
Code:
mlabel -i /dev/sdb1 ::MY_LABEL
this will create/change the label of a FAT disk currently seen as /dev/sdb1 to MY_LABEL. Note that it's safe to change the label when the disk is unmounted, so the steps are: insert the disk, check the device name /dev/sd?1, unmount it, change the label.

In alternative there are ways to mount the device at a fixed mount point even if the volume label is not present. Here are some examples from the Arch wiki. Basically upon insertion you have to RUN the command mkdir to create the desired mount point and the command mount to actually mount it. Hope this helps.
 
Old 11-16-2010, 04:30 AM   #3
algernon_z
Member
 
Registered: Apr 2006
Location: Amsterdam
Distribution: Solaris 9, Solaris 10, OpenIndiana, Cisco IOS, RedHat Linux, CentOS
Posts: 37

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by colucix View Post
In the rule shown there is nothing that tells to mount the device under a fixed mount point. It just creates a symbolic link /dev/usbhdd1 that points to /dev/sdb1.

Hi, thanks for your answer.
You 're right to say that there is nothing that tells to mount the device under a fixed mountpoint. But that is of later concern.
The problem here starts with the symbolic link /dev/usbhdd1 NOT being created.
That was the very first real problem I ran into.

At this moment I use this rule:
KERNEL=="sd[a-z][0-9]", SYSFS{idVendor}="0951", SYSFS{idProduct}="1603", SYSFS{size}="1952640", NAME="%k", SYMLINK="usbkey%n"

With this rule, a symbolic link to /dev/usbkey1 is not created. I wonder why this is not working.
I distracted the data for the rule from

# udevinfo -a -p $(udevinfo -q path -n /dev/sdb1)

looking at the device chain at '/sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.1':
BUS="usb"
ID="2-1.1"
SYSFS{bConfigurationValue}="1"
SYSFS{bDeviceClass}="00"
SYSFS{bDeviceProtocol}="00"
SYSFS{bDeviceSubClass}="00"
SYSFS{bMaxPower}="100mA"
SYSFS{bNumConfigurations}="1"
SYSFS{bNumInterfaces}=" 1"
SYSFS{bcdDevice}="0200"
SYSFS{bmAttributes}="80"
SYSFS{detach_state}="0"
SYSFS{devnum}="5"
SYSFS{idProduct}="1603"
SYSFS{idVendor}="0951"
SYSFS{manufacturer}="Kingston"
SYSFS{maxchild}="0"
SYSFS{product}="DataTraveler 2.0"
SYSFS{serial}="001000000000000000000055"
SYSFS{speed}="480"
SYSFS{version}=" 2.00"


Regards, Alge

Last edited by algernon_z; 11-16-2010 at 04:32 AM.
 
Old 11-16-2010, 04:37 AM   #4
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,563
Blog Entries: 29

Rep: Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179
In udev rules == is the comparison operator and = is the assignment operator. The illustrated rule uses assignment where comparison is required.

Inciedntally, SYSFS{size} does not appear in the udevinfo output you show; presumably it is listed earlier ... ?
 
1 members found this post helpful.
Old 11-16-2010, 05:30 AM   #5
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
Charles, you nailed it on the head! I didn't notice it. Alge, after you've written the rule you can test it for quick debugging. For example by issuing the command
Code:
udevadm test /block/sdb   # udevtest /block/sdb for older versions
having the USB device inserted, you would get something like:
Code:
invalid SYSFS operation
and other notifications, making you suspect that something is wrong in the syntax about the SYSFS parameter.

Last edited by colucix; 11-16-2010 at 05:31 AM.
 
Old 11-16-2010, 08:49 AM   #6
algernon_z
Member
 
Registered: Apr 2006
Location: Amsterdam
Distribution: Solaris 9, Solaris 10, OpenIndiana, Cisco IOS, RedHat Linux, CentOS
Posts: 37

Original Poster
Rep: Reputation: 0
Catkin, Colucix
Thanks for your remarks.
I come back with my testresults tomorrow, since right now other disasters ask for my attention. :-)

Regards, Alge
 
Old 11-17-2010, 06:46 AM   #7
algernon_z
Member
 
Registered: Apr 2006
Location: Amsterdam
Distribution: Solaris 9, Solaris 10, OpenIndiana, Cisco IOS, RedHat Linux, CentOS
Posts: 37

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by catkin View Post
In udev rules == is the comparison operator and = is the assignment operator. The illustrated rule uses assignment where comparison is required.
Thanks for that.
I 've set the assignment operators right.
However, still no joy. I don't see a new "usbkey1" device appearing in /dev

This is the rule I use in the file "09--usbkey.rules".
KERNEL=="sd[a-z][0-9]", SYSFS{idVendor}=="0951", SYSFS{idProduct}=="1643", SYSFS{serial}=="0019E06B5889BA90B7F40099", NAME="%k", SYMLINK="usbkey%n"

This is udevinfo output from the device:
looking at the device chain at '/sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.1':
BUS="usb"
ID="2-1.1"
SYSFS{bConfigurationValue}="1"
SYSFS{bDeviceClass}="00"
SYSFS{bDeviceProtocol}="00"
SYSFS{bDeviceSubClass}="00"
SYSFS{bMaxPower}="200mA"
SYSFS{bNumConfigurations}="1"
SYSFS{bNumInterfaces}=" 1"
SYSFS{bcdDevice}="0100"
SYSFS{bmAttributes}="80"
SYSFS{detach_state}="0"
SYSFS{devnum}="14"
SYSFS{idProduct}="1643"
SYSFS{idVendor}="0951"
SYSFS{manufacturer}="Kingston"
SYSFS{maxchild}="0"
SYSFS{product}="DataTraveler G3"
SYSFS{serial}="0019E06B5889BA90B7F40099"
SYSFS{speed}="480"
SYSFS{version}=" 2.00"


(N.B. I use another USB-device as I did in the post above)

As you can see, for some reason the rule (in 09-usbkey.rules) is still being skipped, while another one (51-by-id.rules) is applied.
Am I using the right syntax for udev version 039 here?
# udevtest /sys/block/sdb/sdb1
version 039
looking at '/block/sdb/sdb1'
parse error /etc/udev/rules.d/09-usbkey.rules, line 1:0, rule skipped
parse error /etc/udev/rules.d/75-usbhd.rules, line 1:0, rule skipped
parse error /etc/udev/rules.d/90-ib.rules, line 1:0, rule skipped
parse error /etc/udev/rules.d/90-ib.rules, line 2:0, rule skipped
parse error /etc/udev/rules.d/90-ib.rules, line 3:0, rule skipped
parse error /etc/udev/rules.d/90-ib.rules, line 4:0, rule skipped
parse error /etc/udev/rules.d/90-ib.rules, line 5:0, rule skipped
parse error /etc/udev/rules.d/90-ib.rules, line 6:0, rule skipped
parse error /etc/udev/rules.d/90-ib.rules, line 7:0, rule skipped
parse error /etc/udev/rules.d/99-fuse.rules, line 1:0, rule skipped
configured rule in '/etc/udev/rules.d/51-by-id.rules' at line 11 applied, added symlink 'disk/by-path/%c'
creating device node '/dev/sdb1', major = '8', minor = '17', mode = '060660', uid = '0', gid = '6'


Thanks & regards, Alge
 
Old 11-17-2010, 06:56 AM   #8
algernon_z
Member
 
Registered: Apr 2006
Location: Amsterdam
Distribution: Solaris 9, Solaris 10, OpenIndiana, Cisco IOS, RedHat Linux, CentOS
Posts: 37

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by colucix View Post
For example, if it is a FAT16 or FAT32 volume, you can try with the command mlabel from the mtools package. Example:
Code:
mlabel -i /dev/sdb1 ::MY_LABEL
this will create/change the label of a FAT disk currently seen as /dev/sdb1 to MY_LABEL. Note that it's safe to change the label when the disk is unmounted, so the steps are: insert the disk, check the device name /dev/sd?1, unmount it, change the label.
I tried this, and at least this is working. :-)

Quote:
Originally Posted by colucix View Post
In alternative there are ways to mount the device at a fixed mount point even if the volume label is not present. Here are some examples from the Arch wiki. Basically upon insertion you have to RUN the command mkdir to create the desired mount point and the command mount to actually mount it. Hope this helps.
I understand the code and what is expected to happen.
When I put this code into a file, quite some parse errors are thrown back:

parse error /etc/udev/rules.d/09-usbkey.rules, line 3:0, rule skipped
parse error /etc/udev/rules.d/11-media-by-label-auto-mount.rules, line 1:22, rule skipped
parse error /etc/udev/rules.d/11-media-by-label-auto-mount.rules, line 4:45, rule skipped
parse error /etc/udev/rules.d/11-media-by-label-auto-mount.rules, line 7:0, rule skipped
parse error /etc/udev/rules.d/11-media-by-label-auto-mount.rules, line 8:0, rule skipped
parse error /etc/udev/rules.d/11-media-by-label-auto-mount.rules, line 11:0, rule skipped
parse error /etc/udev/rules.d/11-media-by-label-auto-mount.rules, line 13:0, rule skipped
parse error /etc/udev/rules.d/11-media-by-label-auto-mount.rules, line 16:0, rule skipped
parse error /etc/udev/rules.d/11-media-by-label-auto-mount.rules, line 19:0, rule skipped
parse error /etc/udev/rules.d/11-media-by-label-auto-mount.rules, line 22:37, rule skipped


Thanks, Alge
 
Old 11-17-2010, 07:00 AM   #9
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
Just out of curiosity, what is the rule applied in 51-by-id.rules? Regarding your rule I have some doubt about the KERNEL key. It should appear as sdb and not necessarily sdb1. I would modify it putting an asterisk after the numeric interval, so that zero or any number of occurrences will match the kernel name:
Code:
KERNEL=="sd[a-z][0-9]*"
 
Old 11-17-2010, 08:12 AM   #10
algernon_z
Member
 
Registered: Apr 2006
Location: Amsterdam
Distribution: Solaris 9, Solaris 10, OpenIndiana, Cisco IOS, RedHat Linux, CentOS
Posts: 37

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by colucix View Post
Just out of curiosity, what is the rule applied in 51-by-id.rules?
KERNEL="sd*", PROGRAM="/sbin/path_id", SYMLINK="disk/by-path/%c"
I hope this makes any sense to you?

Quote:
Originally Posted by colucix View Post
Regarding your rule I have some doubt about the KERNEL key. It should appear as sdb and not necessarily sdb1. I would modify it putting an asterisk after the numeric interval, so that zero or any number of occurrences will match the kernel name:
Code:
KERNEL=="sd[a-z][0-9]*"
I tried that, I also put KERNEL=="sdb", or KERNEL=="sdb1, or KERNEL=="sd[a-z][0-9]*".
I also tried BUS=="usb", KERNEL=="sd?1",

But it keeps skipping the rule and producing sdb and sdb1 devices in /dev in stead of "usbkey%n"...

Thanks, Alge

Last edited by algernon_z; 11-17-2010 at 08:13 AM. Reason: typo
 
Old 11-17-2010, 09:08 AM   #11
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,563
Blog Entries: 29

Rep: Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179
Trying to debug this rule:
Code:
KERNEL=="sd[a-z][0-9]", SYSFS{idVendor}=="0951", SYSFS{idProduct}=="1643", SYSFS{serial}=="0019E06B5889BA90B7F40099", NAME="%k", SYMLINK="usbkey%n"
on Slackware64 13.1 with a 2.6.33.4 kernel and udevadm version 153, using this test command:
Code:
 udevadm test "$( udevadm info --query=path --name=/dev/sdc1 )"
resulted in this output:
Code:
parse_file: reading '/etc/udev/rules.d/99-test.rules' as rules file
add_rule: SYSFS{}= will be removed in a future udev version, please use ATTR{}= to match the event device, or ATTRS{}= to match a parent device, in /etc/udev/rules.d/99-test.rules:1
add_rule: NAME="%k" is superfluous and breaks kernel supplied names, please remove it from /etc/udev/rules.d/99-test.rules:1
Might be worth removing your NAME="%k" ... ?
 
Old 11-17-2010, 09:39 AM   #12
algernon_z
Member
 
Registered: Apr 2006
Location: Amsterdam
Distribution: Solaris 9, Solaris 10, OpenIndiana, Cisco IOS, RedHat Linux, CentOS
Posts: 37

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by catkin View Post
Might be worth removing your NAME="%k" ... ?
I noticed this also, while testing on my notebook, which has Fedora 13: I removed the NAME="%k" and now it works here.

In CentOS 4.8 still the same problem.
However this version is somewhat older (works with udevinfo etc.), I nevertheless replaced SYSFS by ATTRS and removed the NAME attribute.
No dice ....

I am beginning to think that udev in CentOS 4.8 is broken.

Thx, Alge

Last edited by algernon_z; 11-17-2010 at 09:39 AM. Reason: typoz
 
Old 11-17-2010, 09:59 AM   #13
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,563
Blog Entries: 29

Rep: Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179
Quote:
Originally Posted by algernon_z View Post
II nevertheless replaced SYSFS by ATTRS and removed the NAME attribute.
Depending on whether you are matching an attribute from the device itself or from one of its parents you need either ATTR{} or ATTRS{} as illustrated about half way down this page.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Starting udev on CentOS problem Captain Civic Linux - Newbie 9 10-01-2012 01:14 PM
[SOLVED] CentOS 5.5 Starting udev Problem peridian Red Hat 5 07-27-2010 03:15 AM
How to load a firmware file in CentOS with udev / hotplug? ptemmerman Linux - Newbie 3 05-06-2009 03:56 PM
CentOS v5.2 - Unable to start udev Arty Ziff Linux - Server 3 12-03-2008 08:16 AM
My CentOS installation stops booting at udev service arijit_2404 Linux - Desktop 3 11-11-2007 11:09 AM


All times are GMT -5. The time now is 06:21 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration