What is a Udev rule?

Linux identifies everything in the system as a file, even devices. A device attached to a system is listed under /dev/. Managing these devices (renaming, persistent naming, permission modifications) requires a manager.
Udev is one such manager. A device in Linux is recognised by the system under /sys. e.g.

:/sys/block# ls -l
total 0
lrwxrwxrwx 1 root root 0 Sep 22 17:13 dm-0 -> ../devices/virtual/block/dm-0
lrwxrwxrwx 1 root root 0 Sep 22 17:13 dm-1 -> ../devices/virtual/block/dm-1
lrwxrwxrwx 1 root root 0 Sep 22 17:13 dm-2 -> ../devices/virtual/block/dm-2
lrwxrwxrwx 1 root root 0 Sep 22 17:13 dm-3 -> ../devices/virtual/block/dm-3
lrwxrwxrwx 1 root root 0 Sep 22 17:13 dm-4 -> ../devices/virtual/block/dm-4
lrwxrwxrwx 1 root root 0 Sep 22 17:13 dm-5 -> ../devices/virtual/block/dm-5
lrwxrwxrwx 1 root root 0 Sep 22 17:13 vda -> ../devices/pci0000:00/0000:00:1e.0/0000:01:01.0/0000:02:03.0/virtio1/block/vda
lrwxrwxrwx 1 root root 0 Sep 22 17:13 vdb -> ../devices/pci0000:00/0000:00:1e.0/0000:01:01.0/0000:02:04.0/virtio2/block/vdb

Udev rules acts as an interface between user space programs and devices listed under /sysfs. Udev rules map a device under /sysfs to a device ‘expected’ by the user program.

Written with StackEdit.

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.