LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   what dictates which devices gets an entry in /dev? (https://www.linuxquestions.org/questions/linux-newbie-8/what-dictates-which-devices-gets-an-entry-in-dev-4175502731/)

david_8274 04-23-2014 01:54 PM

what dictates which devices gets an entry in /dev?
 
Hi,

When kernel boots up, there are a number of devices list in /dev. My question is, through what mechanism do we tell the kernel which device to be add to/remove from /dev on power up? (I am not talking about creating/deleting a node at run time)

Thanks,
Wei Xu

Smokey_justme 04-23-2014 02:27 PM

That depends on the distribution... Modern ones use udev or variants..

jefro 04-23-2014 03:37 PM

It's possible that some get there from init and from kernel too.

david_8274 04-23-2014 05:48 PM

Thanks for the response!
@Smokey_justme, so some scripts are executed to call udev (or its variants) to populate /dev at boot time? Could you provide a bit more details?

Thanks,
Wei

david_8274 04-23-2014 05:49 PM

@jefro, Thanks for your reply! Could you provide with a bit more details? I am a newbie:)

Thanks,
Wei

Smokey_justme 04-24-2014 04:07 AM

Pff, basically after udev is started, it will load all devices, populate dev according to found devices (or newly connected), load the module, if one exists, execute custom scripts if needed, etc..

While in general udev does the same thing, the location of the files and the moment it populates /dev depends from distribution to distribution..

Also, on some distributions, you might run an initial initrd image (basically, before everything is booted, a small image is used containing the necessary modules/drivers that need preloaded in order for the system to boot -- think RAID, LVM, encrypted partitions --- at that point no udev is loaded, so the /dev is "manually" pre-populated with a minimal set of devices)

jpollard 04-24-2014 08:16 AM

During the initrd startup, the command "mount -t devtmpfs none /dev" is done. devtmpfs is built into the kernel and provides a map of the indentified devices during hardware initialization. The identified devices are already present in /dev at that point. udevd can add updates (by loading drivers based on events from controllers).


All times are GMT -5. The time now is 11:05 AM.