Linux - Server This forum is for the discussion of Linux Software used in a server related context. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
11-15-2010, 08:58 AM
|
#1
|
Member
Registered: Apr 2006
Location: Amsterdam
Distribution: Solaris 9, Solaris 10, OpenIndiana, Cisco IOS, RedHat Linux, CentOS
Posts: 39
Rep:
|
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
|
|
|
11-15-2010, 10:14 AM
|
#2
|
LQ Guru
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509
|
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.
|
|
|
11-16-2010, 03:30 AM
|
#3
|
Member
Registered: Apr 2006
Location: Amsterdam
Distribution: Solaris 9, Solaris 10, OpenIndiana, Cisco IOS, RedHat Linux, CentOS
Posts: 39
Original Poster
Rep:
|
Quote:
Originally Posted by colucix
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 03:32 AM.
|
|
|
11-16-2010, 03:37 AM
|
#4
|
LQ 5k Club
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
|
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.
|
11-16-2010, 04:30 AM
|
#5
|
LQ Guru
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509
|
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 04:31 AM.
|
|
|
11-16-2010, 07:49 AM
|
#6
|
Member
Registered: Apr 2006
Location: Amsterdam
Distribution: Solaris 9, Solaris 10, OpenIndiana, Cisco IOS, RedHat Linux, CentOS
Posts: 39
Original Poster
Rep:
|
Catkin, Colucix
Thanks for your remarks.
I come back with my testresults tomorrow, since right now other disasters ask for my attention. :-)
Regards, Alge
|
|
|
11-17-2010, 05:46 AM
|
#7
|
Member
Registered: Apr 2006
Location: Amsterdam
Distribution: Solaris 9, Solaris 10, OpenIndiana, Cisco IOS, RedHat Linux, CentOS
Posts: 39
Original Poster
Rep:
|
Quote:
Originally Posted by catkin
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
|
|
|
11-17-2010, 05:56 AM
|
#8
|
Member
Registered: Apr 2006
Location: Amsterdam
Distribution: Solaris 9, Solaris 10, OpenIndiana, Cisco IOS, RedHat Linux, CentOS
Posts: 39
Original Poster
Rep:
|
Quote:
Originally Posted by colucix
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
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
|
|
|
11-17-2010, 06:00 AM
|
#9
|
LQ Guru
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509
|
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]*"
|
|
|
11-17-2010, 07:12 AM
|
#10
|
Member
Registered: Apr 2006
Location: Amsterdam
Distribution: Solaris 9, Solaris 10, OpenIndiana, Cisco IOS, RedHat Linux, CentOS
Posts: 39
Original Poster
Rep:
|
Quote:
Originally Posted by colucix
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
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 07:13 AM.
Reason: typo
|
|
|
11-17-2010, 08:08 AM
|
#11
|
LQ 5k Club
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
|
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" ... ?
|
|
|
11-17-2010, 08:39 AM
|
#12
|
Member
Registered: Apr 2006
Location: Amsterdam
Distribution: Solaris 9, Solaris 10, OpenIndiana, Cisco IOS, RedHat Linux, CentOS
Posts: 39
Original Poster
Rep:
|
Quote:
Originally Posted by catkin
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 08:39 AM.
Reason: typoz
|
|
|
11-17-2010, 08:59 AM
|
#13
|
LQ 5k Club
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
|
Quote:
Originally Posted by algernon_z
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.
|
|
|
All times are GMT -5. The time now is 06:40 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|