• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

The Geek Diary

CONCEPTS | BASICS | HOWTO

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • Linux Services
    • VCS
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
    • Data Guard
  • DevOps
    • Docker
    • Shell Scripting
  • Interview Questions
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to Configure Device File owner/group with udev rules

By admin

What is udev and udev rules

Udev is the mechanism used to create and name /dev device nodes corresponding to the devices that are present in the system. Udev uses matching information provided by sysfs with rules provided by the user to dynamically add the required device nodes.

There are no static files under /dev directory for devices, devices are created/removed dynamically by udev(or udevd) which is a daemon monitoring what devices are connected/disconnected on to the kernel, and run additional appropriate scripts accordingly. Manually creating files under /dev directory or changing its file attributions does no effect, manually modifications would be ignored or could be revised automatically.

This post describes how to configure attributions of device files under /dev directory via udev. The common configuration files for udev are under /etc/udev/rules.d directory, which describes rules for creating device files. The files must have .rules extension/suffix and unique names, others would be ignored. These files are referred in lexical order, thus 60-raw.rules is referred before 70-persistent-net.rules, and the later rules overwrite the previous ones unless you specify an exemption in the later rules file.

Note: The syntax of .rules files are described in udev man page.

Changing file owner/group using udev rules

Let us see an example to change the owner/group to oracle/oinstall of device /dev/sdx using udev rules.
1. Add a file with name /etc/udev/rules.d/99-perm.rules which includes the below line. The file name can be anything with prefix of appropriate number like 99.

# vi /etc/udev/rules.d/99-perm.rules
KERNEL=="sdx", OWNER="oracle", GROUP="oinstall"

2. Test the new rule with “udevadm” command. As shown in the output below the rule is applied for the device /dev/sdx.

# udevadm test /block/sdx 2>&1 | grep "OWNER\|GROUP"
udev_rules_apply_to_event: OWNER ## /etc/udev/rules.d/99-perm.rules
udev_rules_apply_to_event: GROUP ## /etc/udev/rules.d/99-perm.rules

where ## shows UID/GID of oracle/oinstall.

3. Run udevadm to activate the new rule and check the changes:

# udevadm control –reload-rules
# udevadm trigger /block/sdx

4. Verify the permissions of the /dev/sdx device.

# ls -al /dev/sdx
brw-rw----. 1 oracle oinstall 202, 0 Feb  9 14:20 /dev/sdx
Note: It is not required to reboot the system after configuring the udev rules, But its recommended

Filed Under: ASM, CentOS/RHEL 6, CentOS/RHEL 7, Linux, oracle

Some more articles you might also be interested in …

  1. Upgrading to Oracle 12c using RMAN DUPLICATE with “NOOPEN” clause and “BACKUP LOCATION”
  2. How to move a datafile from file system to ASM
  3. How to Disable “Predictable Network Interface Device Names” in CentOS/RHEL 7
  4. 5 Useful Examples of firewall-cmd command
  5. How to Schedule Tasks Using at in Linux
  6. CentOS / RHEL 7 : How to Change the machine-id
  7. Beginners guide to Kernel Module Configuration in Linux
  8. How to Install and Configure Kerberos in CentOS/RHEL 7
  9. How to Recover DROPPED PDB After Flashback of CDB
  10. How to extract RPM package without installing it

You May Also Like

Primary Sidebar

Recent Posts

  • Oracle Database – Configuring Secure Application Roles
  • Extend rule sets by using factors in Oracle Database Vault
  • What are Command Rules in oracle Database
  • Using Rule Sets in Oracle Database Vault
  • Archives
  • Contact Us
  • Copyright

© 2021 · The Geek Diary