Linux - DistributionsThis forum is for Distribution specific questions.
Red Hat, Slackware, Debian, Novell, LFS, Mandriva, Ubuntu, Fedora - the list goes on and on...
Note: An (*) indicates there is no official participation from that distribution here at LQ.
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.
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.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
When a USB device is inserted into a linux system a device node is created in /deb. I need to know the following information:
1) Who creates this node, is it USBcore?
2) Why it takes 4-5 seconds to be created?
3) Is there any other location apart from /dev where the device node corresponding to the same USB device is created?
Thanks in advance.
1) All the /dev entries in recent-ish Linux systems are handled by 'udev'. This is a userland daemon that the kernel notifies every time there's a hardware change. It creates the appropriate node in /dev according to some built in rules, and the rules in /etc/udev/rules.d
2) Some (all?) USB devices take a few seconds to 'settle' before they are probed. Some devices also require firmware which has to be uploaded to the device before it'll work, which may take a couple of seconds.
3) Nope, not as far as I can see. There's nothing stopping you creating your own device node wherever you like, with the right major and minor numbers, though. 'mknod' is the command.
Thanks a lot for your information. It really helpful. I do have some queries:
1) If UDEV creates the device node, then if I change the udev rule then I hope this device node will not be created.
2) In Windows, file system has been created instantly after USB device insertion, but in Linux it takes bit longer time, is there any other mechanism to create the device node faster?
3) Can I stop UDEV from creating the device node, instead my application will create the device node as I have seen that SYSFS contains all the information regarding a USB device?
Is there a particular reason you need devices to be available very quickly after attachment?
How are you measuring the time it takes between insertion and the device being available?
If you /really/ want to you can abandon udev and use the old static /dev directory. You'd have to create all the device nodes in /dev manually, and stop the udev daemon from starting. There might be some kernel reconfiguration required too.
For the third question of your original post, there are other device nodes created. Look in /dev/disk/by-path and /dev/disk/by-id. These are also created by udev. You can have entries in /etc/fstab files that allow you to mount filesystems by UUID or LABEL. This allows you to use particular options like uid,gid,fmask & dmask based on the filesystem and not the mode. Using the same computer, this could allow one user to have exclusive access to a pen drive. The permissions and ownership are determined (for vfat & ntfs) in the mount command. Another user may be able to mount it but can be denied read or write access, depending on the option values given.
Also look at PolicyKit. You can have rules that allow mounting of removable media, restrict it to the user of an active session, or deny mounting removable media all together.
Yes I need to get the device node should come up very fast. If UDEV will take long then my application will create separate device node, as my application will get the major & minor number form the sysfs.
When a device is inserted, an entry in usbfs has immediately created, also all the USB related information is updated in SYSFS immediately, but the device node is not created that fast, it takes almost 4-5 seconds.
If my application can create the device node apart from the device node created by UDEV, then I don't need to remove the UDEV.
Yes the entries are created in /dev/disk/by-id and /dev/disk/by-path, but these two are not the separate device nodes, these are the soft links to the device node created in /dev (i.e. sdb, sdc) by UDEV.