09/06/2005
the right way to enable udev in gentoo
I know there are numerous postings and wiki articles on the net on how to enable udev on a linux distribution and specifically for Gentoo. Because I did not find anything complete here’s my version on doing all that. The were 2 reasons I started looking around for udev support, first reason was to have a special device for my olympus c70z so I did not have to “fdisk -l” every time I wanted to check on what device it was, and secondly to improve the usb_key+hotplug+xlockmore stuff I had done earlier.
BEWARE!!!
I am not writing this guide for complete newbies to linux and kernel stuff…I am not going to explain how to compile a kernel and where to put it and and and and…cause it would never end.
First thing to do check your kernel settings!!
Device Drivers -> USB Support
< *> Support for Host-side USB
[*] USB device filesystem
< *> EHCI HCD (USB 2.0) support
< *> OHCI HCD support
For SCSI support
Device Drivers -> SCSI device support
[*] legacy /proc/scsi/ support
< *> SCSI disk support
< *> SCSI generic support
For vfat file system support
File systems -> DOS/FAT/NT Filesystems
< *> MSDOS fs support
< *> VFAT (Windows-95) fs support
Remove devfs support (If you want...)
File systems -> Pseudo filesystems
[ ] /dev file system support (OBSOLETE)
BUT YOU MUST REMOVE !!!! below devfs support.
[ ] Automatically mount at boot (SAY NO TO THIS!!!!)
Then emerge the proper packages:
emerge -uDv udev hotplug baselayout
Edit your /etc/conf.d/rc:
You must have settings like that:
RC_DEVICES="udev"
RC_DEVICE_TARBALL="yes"
RC_DEVFSD_STARTUP="no"
then:
sysctl -w kernel.hotplug="/sbin/udev"
rc-update add hotplug boot
In lilo.conf change the append line of your kernel adding this:
append="gentoo=nodevfs"
and then type lilo to make the proper changes.
If you rebooted now your system with the new kernel it should have been udev enabled.
You might encounter mouse problems, because the old /dev/mouse symlink is lost with udev. Edit /etc/conf.d/gpm and /etc/X11/xorg.conf to replace /dev/mouse with /dev/input/mouse0
What’s next ? udev rules. You must make some rules for udev to properly find your devices.
I am going to explain how I wrote 3 simple rules for my digital camera, my usb stick and my usb-hdd.
1) DIGITAL CAMERA
When plugged in the usb port go check your dmesg. You should see something like:
Attached scsi removable disk sdb at scsi7, channel 0, id 0, lun 0
Attached scsi generic sg1 at scsi7, channel 0, id 0, lun 0, type 0
now do this: udevinfo -a -p /sys/class/scsi_generic/sg1
and a bunch of info like that will appear in front of you:
looking at the device chain at '/sys/devices/pci0000:00/0000:00:10.0/usb2/2-2':
BUS="usb"
ID="2-2"
DRIVER="usb"
SYSFS{bConfigurationValue}="1"
SYSFS{bDeviceClass}="00"
SYSFS{bDeviceProtocol}="00"
SYSFS{bDeviceSubClass}="00"
SYSFS{bMaxPower}=" 0mA"
SYSFS{bNumConfigurations}="1"
SYSFS{bNumInterfaces}=" 1"
SYSFS{bcdDevice}="0100"
SYSFS{bmAttributes}="c0"
SYSFS{detach_state}="0"
SYSFS{devnum}="6"
SYSFS{idProduct}="0109"
SYSFS{idVendor}="07b4"
SYSFS{manufacturer}="OLYMPUS"
SYSFS{maxchild}="0"
SYSFS{product}="C70Z,C7000Z"
SYSFS{serial}="1234567890"
SYSFS{speed}="12"
SYSFS{version}=" 2.00"
We just need the italic ones.
edit /etc/udev/rules.d/10-local.rules
and add something like this:
BUS="usb", KERNEL="sd?1", SYSFS{manufacturer}="OLYMPUS", SYSFS{serial}="1234567890", SYSFS{product}="C70Z,C7000Z", NAME="%k", SYMLINK="c70z"
YOUR VALUES WILL DEFER!!!
now “mkdir -p /mnt/digicam” and add something like this in your /etc/fstab:
/dev/c70z /mnt/digicam vfat noatime,user,rw,sync,uid=1000 0 0
mount /mnt/digicam and your camera is ready to extract the pictures from it!
2) USB KEY
same as above…but the rule and fstab entry will defer slightly:
udev rule:
BUS="usb", SYSFS{serial}="23DE746790310A9B", NAME="%k", SYMLINK="mykey"
fstab entry:
/dev/mykey /mnt/usbkey vfat noatime,user,rw,sync,uid=1000 0 0
3) USB HDD
udev rule:
BUS="scsi", SYSFS{model}="00JB-32EVA0", NAME{all_partitions}="wd-usb"
fstab entry:
/dev/wd-usb1 /mnt/usbdisk ext3 noatime,users 0 0
Remember my old post on pam_usb ? It gets a lot better with udev!
edit /etc/pam.d/login
and change the rule into something like this now:
auth sufficient /lib/security/pam_usb.so proc_basename=/proc/scsi/usb-storage/1 !check_device force_device=/dev/mykey allow_remote=1 fs=vfat debug=1 log_file=/var/log/pam_usb.log
where /dev/mykey is created by udev so it does not matter where the real device is…it will always symlink to mykey!
You can’t make it work ? Read these links…they might help you:
Gentoo udev Guide
Gentoo Wiki – HOWTO_Install_a_digital_camera
UDEV Primer
Using udev for Static Device Naming
Writing UDEV rules
Filed by kargig at 01:58 under General,Linux
1 Comment | 7,497 views