Udev creates and removes device nodes in /dev, based on events the kernel sends out on device discovery or removal. In other words, Udev is the system that maps hardware devices to files you can interact with in the /dev directory. It’s only been around since 2003/2004. All modern distributions use udev instead of the now depreciated hotplug or devfs.

The Linux kernel assigns a major and minor number to a hardware device and so files can be created in /dev using this number pair with names such as sda, ttyS0, ttyUSB0, etc., to allow for interaction with the hardware from user space. In the past, device nodes were created for everything supported by the kernel, so you can imagine it would be hard to figure out which devices were actually connected at any given time, especially if you’re using a generic kernel.
Udev runs in user space and creates points in /dev when the kernel detects and recognizes new hardware as it’s attached.
When you plug in two USB devices, whichever one is recognized first by the kernel gets the next device name. The same goes for SATA block devices. The first disk will be referred to as “sda” while the next disk will be “sdb”. Interchange the devices the next time you boot, and the names will be swapped. Udev lets you ignore this so you can refer to a device by an identifier. The identifiers made by udev are soft links that point to the right underlying device name.
$ ls -l /dev/disk/by-id/
total 0 lrwxrwxrwx 1 root root 9 03:45 ata-ST590915AS_7RN1NJA1 -> ../../sda lrwxrwxrwx 1 root root 10 03:45 ata-ST590915AS_7RN1NJA1-part1 -> ../../sda1 lrwxrwxrwx 1 root root 10 03:45 ata-ST590915AS_7RN1NJA1-part2 -> ../../sda2 lrwxrwxrwx 1 root root 10 03:45 ata-ST590915AS_7RN1NJA1-part3 -> ../../sda3
You can find devices using several different identifiers in the /dev/disk directory. The following four identifiers all point to the same /dev/sda2 device.
by-id : ata-ST590915AS_7RN1NJA1-part1 -> ../../sda2
by-label : SWAP-sda2 -> ../../sda2
by-path : pci-0000:00:1f.2-scsi-0:0:0:0-part1 -> ../../sda2
by-uuid : 1181329b-3198-4753-a408-ca46978ddd59 -> ../../sda2
You can write your own rules to control how devices are recognized by udev and to create custom events such as running a specific program when a device shows up.
SUBSYSTEM=="memstick", RUN+="/sbin/modprobe --all ms_block mspro_block"
SUBSYSTEM=="mmc", RUN+="/sbin/modprobe mmc_block"
SUBSYSTEM=="i2o", RUN+="/sbin/modprobe i2o_block"
SUBSYSTEM=="ide", ATTR{media}=="tape", RUN+="/sbin/modprobe ide-scsi"
SUBSYSTEM=="scsi_device", TEST!="[module/sg]", RUN+="/sbin/modprobe sg"
Proc must be mounted at /proc and sysfs must be mounted at /sys. The basic prerequisites you’ll need are olibacl, libglib2, libusb, usbutils, pciutils, and gperf, but if you want to build it from scratch, good luck working with a generic distribution such as Ubuntu or Fedora. Most distributions have their own customized versions of udev that may be relied on for some of their specific features to work properly. You may be able to get away with building your own and using the files from their /etc tree.
$ ls -l /etc/udev/
total 24 drwxr-xr-x 2 root root 4096 2009-09-29 09:41 makedev.d drwxr-xr-x 2 root root 4096 2009-09-29 09:51 rules.d -rw-r--r-- 1 root root 226 2008-01-10 10:00 udev.conf
* /dev is mounted in tmpfs during the boot process.
* Udev copies static devices from /lib/udev/devices to /dev.
* Udev gets uevents from the kernel for all connected devices.
* Udev runs through its rules in rules.d and creates nodes and links in /dev.
* If any rules are changed, udev receives an inotify event and updates accordingly.