Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
UDEV Primer for 2.6 Kernel
View unanswered posts
View posts from last 24 hours

Goto page Previous  1, 2, 3, 4  Next  
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
tatesworld
n00b
n00b


Joined: 25 Oct 2003
Posts: 67

PostPosted: Fri Feb 20, 2004 10:59 pm    Post subject: Reply with quote

my /dev was always empty when I used devfs when booting from rescue cd
so It dont like empty /dev (mind you I always had to tick automatically mount at boot devfs option before when configuring kernels) and since udev is user space it must need an initial console I suppose
Back to top
View user's profile Send private message
Decibels
Veteran
Veteran


Joined: 16 Aug 2002
Posts: 1598
Location: U.S.A.

PostPosted: Fri Feb 20, 2004 11:38 pm    Post subject: Reply with quote

After testing this back and forth. Udev populates /dev after the system wants console and null. So if have an empty /dev folder then lack of console or null will cause system to fail.

If anyone doubts this, boot from another system or cd and check you /dev on the partition in question. If your not having any problems with console or null, then you will see the devices in there. If you are, then you will see a blank folder or at least one without console or null in it.

Solution is to have at least console and null in root /dev folder as static devices.
_________________
Support bacteria – they’re the only culture some people have.”

– Steven Wright
Back to top
View user's profile Send private message
water
Guru
Guru


Joined: 19 Jun 2002
Posts: 387
Location: Zierikzee, The Netherlands

PostPosted: Sun Feb 22, 2004 1:49 pm    Post subject: Reply with quote

Decibels: little typo in your UDEV-primer?

Paragraph 10 (GRUB/LiLo): sometimes devsf instead off devfs

EDIT: Corrected within five minutes, after posting. :D
_________________
Groeten uit Holland
Back to top
View user's profile Send private message
beandog
Bodhisattva
Bodhisattva


Joined: 04 May 2003
Posts: 2066
Location: /usa/utah

PostPosted: Sun Feb 22, 2004 7:40 pm    Post subject: Reply with quote

So can I unmerge sys-fs/devfsd now, or do I still need it?
_________________
If it ain't broke, tweak it. dvds | blurays | blog | wiki
Back to top
View user's profile Send private message
Decibels
Veteran
Veteran


Joined: 16 Aug 2002
Posts: 1598
Location: U.S.A.

PostPosted: Sun Feb 22, 2004 8:29 pm    Post subject: Reply with quote

Don't need it unless going to be using devfs for some other kernel. If you have a problem let me know.
_________________
Support bacteria – they’re the only culture some people have.”

– Steven Wright
Back to top
View user's profile Send private message
Decibels
Veteran
Veteran


Joined: 16 Aug 2002
Posts: 1598
Location: U.S.A.

PostPosted: Tue Feb 24, 2004 12:23 am    Post subject: Reply with quote

Made some more updates. Started a little part near the top showing recent changes also, so will know at a quicker glance if something added/changed.

Also like to thank dsd for all his help. For those got udev working, also check out dsd's Writing Udev Rules page: http://www.reactivated.net/udevrules.php
_________________
Support bacteria – they’re the only culture some people have.”

– Steven Wright
Back to top
View user's profile Send private message
beekman001
n00b
n00b


Joined: 16 Nov 2003
Posts: 3

PostPosted: Thu Feb 26, 2004 4:09 am    Post subject: Reply with quote

i've been looking at your page & some other udev stuff. and i had a thought.
would it be practical to create a script to generate /dev nodes at bootup from a config file

i was thinking something along the lines of
1) get a listing of modules known not to work with udev, and their major / minor numbers etc
2) have the script go through that listing and generate device files at boot up
results:
1) it eliminates the devices.tar.bz2 kludge
2) as drivers are made compatable, they can be removed from the list
3) comments could be implemented so say, people who dont have an nvidia video card could simply comment the nvidia stuff out of the config file
Back to top
View user's profile Send private message
rockfly
Apprentice
Apprentice


Joined: 27 Apr 2003
Posts: 179

PostPosted: Fri Feb 27, 2004 2:59 pm    Post subject: Reply with quote

the page :

http://www.reactivated.net/udevrules.php

does not work, is it broken?
Back to top
View user's profile Send private message
Decibels
Veteran
Veteran


Joined: 16 Aug 2002
Posts: 1598
Location: U.S.A.

PostPosted: Fri Feb 27, 2004 3:05 pm    Post subject: Reply with quote

Check it again. It isn't my site, it is dsd's and just went there. Must have been down for maintenance. Works now.
_________________
Support bacteria – they’re the only culture some people have.”

– Steven Wright
Back to top
View user's profile Send private message
d3c3it
l33t
l33t


Joined: 01 Mar 2003
Posts: 765
Location: Manchester, UK

PostPosted: Sat Feb 28, 2004 3:27 pm    Post subject: Reply with quote

how do you change node permissions? ie changing /dev/lp0 so a user can use it. atm only root has access
_________________
Some people go to counselling,
others use linux
Back to top
View user's profile Send private message
OneOfOne
Guru
Guru


Joined: 28 May 2003
Posts: 368
Location: Alexandria, Egypt

PostPosted: Sat Feb 28, 2004 6:53 pm    Post subject: Reply with quote

thanks to mattthebaker on #gentoo i've found a fix for the weird alsa perm problems.
the file /etc/security/console.perms some how rechmods the nodes the first time after udev creates them but not the 2nd time.
personally i just removed the file (after making a backup ;)).

peace
Back to top
View user's profile Send private message
Decibels
Veteran
Veteran


Joined: 16 Aug 2002
Posts: 1598
Location: U.S.A.

PostPosted: Sat Feb 28, 2004 8:21 pm    Post subject: Reply with quote

It changes them once, then what the next time your reboot, it doesn't?
I was thinking my /etc/security folder was empty anyway.
Have to look when get home.
_________________
Support bacteria – they’re the only culture some people have.”

– Steven Wright
Back to top
View user's profile Send private message
OneOfOne
Guru
Guru


Joined: 28 May 2003
Posts: 368
Location: Alexandria, Egypt

PostPosted: Sat Feb 28, 2004 9:44 pm    Post subject: Reply with quote

beekman001 wrote:
i've been looking at your page & some other udev stuff. and i had a thought.
would it be practical to create a script to generate /dev nodes at bootup from a config file

i was thinking something along the lines of
1) get a listing of modules known not to work with udev, and their major / minor numbers etc
2) have the script go through that listing and generate device files at boot up
results:
1) it eliminates the devices.tar.bz2 kludge
2) as drivers are made compatable, they can be removed from the list
3) comments could be implemented so say, people who dont have an nvidia video card could simply comment the nvidia stuff out of the config file

i shameless stole your idea and made a very simple script to do what you were thinking about, kinda.
first you supply a file with simple rules, if the "module X" is loaded and the node doesnt exist it'll create it.
simple configuration file :
Code:

# udh.conf
# this is just an example
#kernel_module, dev and node are required.
#kernel_module can be set to none if the module is built in.
kernel_module=ppp_generic,dev=/dev/ppp,perm=660,group=dialout,user=root,node=108 0
kernel_module=none,dev=/dev/test-test,perm=660,group=users,user=oneofone,node=1 3,symlink=/dev/test2
kernel_module=none,dev=/dev/fb/0,perm=660,group=video,user=root,node=29 0,dir=/dev/fb,synlink=/dev/fb0

Actual script :
Code:

#!/usr/bin/python -O
# Distributed under the terms of the GNU General Public License v2
#UDev Device Helper
#Changes :
#   fixed permissions problem and misc tweaks
import sys,os,grp,pwd,commands,stat
default_perm = '660'
loaded_modules = commands.getoutput("lsmod | awk '{print $1'}").splitlines()[1:]
loaded_modules.append('none');
def parse_config(conf_file='udh.conf'):
   if not os.access(conf_file,os.F_OK) and len(sys.argv) > 1 and os.access(sys.argv[1], os.F_OK) :
      conf_file = sys.argv[1]
   f = file(conf_file,"r"); lines = f.readlines(); f.close()
   final_conf = []
   for line in lines:
      if not line.startswith('#'):
         conf = line.strip().split(',')
         temp_dict = {}
         for c in conf:
            cc = c.strip().split('=')
            temp_dict[cc[0].strip()] = cc[1].strip()
         final_conf.append(temp_dict)
   return final_conf
conf = parse_config()
for line in conf:
   try:
      if 'kernel_module' in line and line['kernel_module'] in loaded_modules and not os.access(line['dev'],os.F_OK):
         print "Making node : " + line['dev']
         if 'perm' in line : line['perm'] = default_perm
         if 'dir' in line : print "\t Making Directory : " + line['dir'] + ' ' + os.mkdir(line['dir'])
         n = line['node'].split(' ')
         os.mknod(line['dev'], stat.S_IFCHR, os.makedev( int(n[0]), int(n[1]) ) )
         #fix this...
         commands.getoutput("chmod %(p)s %(f)s" % {'p':line['perm'], 'f': line['dev']} )
         #commands.getoutput( 'mknod -m '+line['perm']+' '+line['dev']+' c '+line['node'])
         gid , uid = 0 , 0
         if 'group' in line : gid = grp.getgrnam(line['group'])[2]
         if 'user' in line : uid = pwd.getpwnam(line['user'])[2]
         os.chown(line['dev'], uid, gid)
         if 'symlink' in line :
            print "\tCreating Symlink from %(src)s to %(dst)s" % {'src':line['dev'], 'dst':line['symlink']}
            os.symlink(line['dev'], line['symlink'])
      else:
         print 'Error : [%(e)s] isn\'t currently loaded or device already exists.' % {'e':line["kernel_module"]}
   except:
      print "Configuration : "+ str(line)+" is invalid, please check your syntax!"

either put udh.conf in the same directory or call the script with the full path name to the .conf file, example :
Code:

[11:40:21][~/programming/python/udh]-> chmod +x udh.py
[11:40:21][~/programming/python/udh] -> ./udh.py ~/programming/python/udh/udh.conf
Error : [ppp_generic] isn't currently loaded or device already exists.
Making node : /dev/test-test
        Creating Symlink from /dev/test-test to /dev/test2
Error : [none] isn't currently loaded or device already exists.
[11:40:23][~/programming/python/udh] -> l /dev/test* && rm /dev/test* -f
c-w----r-T    1 oneofone users      1,   3 Feb 28 23:40 /dev/test-test
lrwxrwxrwx    1 root     root           14 Feb 28 23:40 /dev/test2 -> /dev/test-test
[11:40:25][~/programming/python/udh] ->

i hope this helps someone.
a good place to put it is either local.start or edit /sbin/rc and append /path/to/udh.py /path/to/udh.conf before the "return 0" line in populate_udev().
fixed a problem with the perm, for some reason os.chmod() hates me and submited a bug https://bugs.gentoo.org/show_bug.cgi?id=43225
peace


Last edited by OneOfOne on Sat Feb 28, 2004 10:23 pm; edited 1 time in total
Back to top
View user's profile Send private message
OneOfOne
Guru
Guru


Joined: 28 May 2003
Posts: 368
Location: Alexandria, Egypt

PostPosted: Sat Feb 28, 2004 9:50 pm    Post subject: Reply with quote

Decibels wrote:
It changes them once, then what the next time your reboot, it doesn't?
I was thinking my /etc/security folder was empty anyway.
Have to look when get home.

no, i use pure udev so when i reboot it used to do the same thing all over again.
if you delete the file it won't do that and it'll create the devices with right perm from /etc/udev/udev.permissions.

peace
Back to top
View user's profile Send private message
Decibels
Veteran
Veteran


Joined: 16 Aug 2002
Posts: 1598
Location: U.S.A.

PostPosted: Sat Feb 28, 2004 10:37 pm    Post subject: Reply with quote

Code:
# /etc/security/console.perms
#
# This file determines the permissions that will be given to priviledged
# users of the console at login time, and the permissions to which to
# revert when the users log out.


Okay, must have been thinking of something else when said it was empty. Home now and it's not. Weird, haven't noticed any strange permission problems on my system that I know of. I seem to own all my alsa devices in snd and group audio.

Is there something you think I should make a not of on the Primer. Or is it something that probably isn't affecting many people?

PS. Running a pure udev system also.
_________________
Support bacteria – they’re the only culture some people have.”

– Steven Wright
Back to top
View user's profile Send private message
Decibels
Veteran
Veteran


Joined: 16 Aug 2002
Posts: 1598
Location: U.S.A.

PostPosted: Sat Feb 28, 2004 10:42 pm    Post subject: Reply with quote

d3c3it wrote:
how do you change node permissions? ie changing /dev/lp0 so a user can use it. atm only root has access


You could edit udev.permissions.
Code:
# lp devices
lp*:root:lp:0660
parport*:root:lp:0660
irlpt*:root:lp:0660
usblp*:root:lp:0660
usb/lp*:root:lp:0660


That should be correct and mine is like that. Better yet, I would just add the user to the 'lp' group. That would be better than changing the owner in udev.permissions. IMHO
_________________
Support bacteria – they’re the only culture some people have.”

– Steven Wright
Back to top
View user's profile Send private message
Cerement
Guru
Guru


Joined: 14 Jun 2003
Posts: 404

PostPosted: Sat Feb 28, 2004 11:20 pm    Post subject: Reply with quote

Now running a pure udev system thanks to Debibels' guide and Gentoo's new baselayout package:

kernel config without devfs
in /etc/conf.d/rc disabled devices.tar.bz and loading devfs at boot
(and overly redundant devfs=nomount gentoo=nodevfs on kernel line)

then did as tatesworld did,
rebooted with gentoo cd, mounted my HD,
cleaned out /dev completely,
created console and null,

rebooted,
needed to emerge nvidia-kernel
and everything runs just fine

Thanks to everyone here and in the support thread for a great job!
Back to top
View user's profile Send private message
tecknojunky
Veteran
Veteran


Joined: 19 Oct 2002
Posts: 1937
Location: Montréal

PostPosted: Sat Feb 28, 2004 11:22 pm    Post subject: Reply with quote

Decibels, thank you.

Thanks to your most excellent and crystal clear howto, I now have a pure udev running system and it worked right out of the box.

I still have to go around to check for any permissions problems, but for now, /dev/null and /dev/console got created automagically without any intervention on my part, sound seem ok, I can mount cdrom, really, quite trivial.

Good job. You should be elected president of the entire world.
_________________
(7 of 9) Installing star-trek/species-8.4.7.2::talax.
Back to top
View user's profile Send private message
OneOfOne
Guru
Guru


Joined: 28 May 2003
Posts: 368
Location: Alexandria, Egypt

PostPosted: Sun Feb 29, 2004 12:00 am    Post subject: Reply with quote

Decibels wrote:
d3c3it wrote:
how do you change node permissions? ie changing /dev/lp0 so a user can use it. atm only root has access


You could edit udev.permissions.
Code:
# lp devices
lp*:root:lp:0660
parport*:root:lp:0660
irlpt*:root:lp:0660
usblp*:root:lp:0660
usb/lp*:root:lp:0660


That should be correct and mine is like that. Better yet, I would just add the user to the 'lp' group. That would be better than changing the owner in udev.permissions. IMHO

i believe his problem is the same like mine.
also it works for some people although the permissions are wrong, no idea how.
if you do ls -l /dev/sound/* you'll find them 600 not 660.
it probably works for them because they edit udev.permissions and change root: to user-name:.
and i also think it's totally harmless to remove that console.perms file, atleast make a back up of it and if anything goes wrong the root will always be able to restore it.

peace
Back to top
View user's profile Send private message
Decibels
Veteran
Veteran


Joined: 16 Aug 2002
Posts: 1598
Location: U.S.A.

PostPosted: Sun Feb 29, 2004 12:28 am    Post subject: Reply with quote

Code:
bash-2.05b$ ls -l /dev/sound*
total 0
crw-------    1 decibels    audio     14,  12 Feb 27 07:36 adsp
crw-------    1 decibels    audio     14,   4 Feb 27 07:36 audio
crw-------    1 decibels    audio     14,   3 Feb 27 07:36 dsp
crw-------    1 decibels    audio     14,   0 Feb 27 07:36 mixer


Your certainly right about the permissions changing. Overwrites udev.permissions of 660. Not that I doubted you, just like to see it for myself.
Guess it doesn't really matter on a single user system. Does anyone have a multi-user system and let's say something like the first user owns the devices and when another user comes on they don't get any?

Busy keeping the Primer updated and some things like this require others to bring it to the fore front.

Just noticed the same thing on my hdc (cdwriter).
_________________
Support bacteria – they’re the only culture some people have.”

– Steven Wright
Back to top
View user's profile Send private message
OneOfOne
Guru
Guru


Joined: 28 May 2003
Posts: 368
Location: Alexandria, Egypt

PostPosted: Sun Feb 29, 2004 1:01 am    Post subject: Reply with quote

well, i know its good for 1 user system but i run as root most of the time, except programs that use the internet (xchat, firefox, etc). and they can't play sounds for example.
same goes to "links" and /dev/fb/0
i think you really should add a comment about it in your great howto, after all if it wasn't for your howto i wouldnt be using udev now :)

peace
Back to top
View user's profile Send private message
Decibels
Veteran
Veteran


Joined: 16 Aug 2002
Posts: 1598
Location: U.S.A.

PostPosted: Sun Feb 29, 2004 1:12 am    Post subject: Reply with quote

I'll see what can do. Now battling a weird problem where can't use kdesu, kuser, or a lot of other su X programs. Can't even login as root, but can su in terminal. Weird.
_________________
Support bacteria – they’re the only culture some people have.”

– Steven Wright
Back to top
View user's profile Send private message
tecknojunky
Veteran
Veteran


Joined: 19 Oct 2002
Posts: 1937
Location: Montréal

PostPosted: Sun Feb 29, 2004 2:26 am    Post subject: Reply with quote

OneOfOne wrote:
...and /dev/fb/0
Hum, me too. Anything using /dev/fb* is doomed. I guess I'll have to use the device tarball after all :(
_________________
(7 of 9) Installing star-trek/species-8.4.7.2::talax.
Back to top
View user's profile Send private message
OneOfOne
Guru
Guru


Joined: 28 May 2003
Posts: 368
Location: Alexandria, Egypt

PostPosted: Sun Feb 29, 2004 2:36 am    Post subject: Reply with quote

tecknojunky wrote:
OneOfOne wrote:
...and /dev/fb/0
Hum, me too. Anything using /dev/fb* is doomed. I guess I'll have to use the device tarball after all :(

well, latest love sources include a patch to make fb generate the /dev/fb* stuff.
Decibels: i dont have the problem, sorry.
peace
Back to top
View user's profile Send private message
tecknojunky
Veteran
Veteran


Joined: 19 Oct 2002
Posts: 1937
Location: Montréal

PostPosted: Sun Feb 29, 2004 3:01 am    Post subject: Reply with quote

oh, and one more thing. I just updated mm-sources and there is no more "Support for hot-pluggable devices" entry: http://www.tecknojunky.com/images/mm4.png

What is to be shoosen?
_________________
(7 of 9) Installing star-trek/species-8.4.7.2::talax.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Goto page Previous  1, 2, 3, 4  Next
Page 3 of 4

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum