Linux redhat7 udev Configuration __linux

Source: Internet
Author: User
Tags builtin chmod symlink uuid

This article mainly describes how to use Udev to set user-defined device names in Oracle Linux 7. The Setup method in Oracle Linux 7 is significantly different from previous Linux versions.

The following example pairs the/DEV/SDB,/DEV/SDC by setting the Udev rules to create a user-defined device name
1. View Linux Version
[Root@linuxidc.com ~]# Uname-a
Linux linuxidc.com 3.8.13-55.1.6.el7uek.x86_64 #2 SMP Wed Feb 14:18:22 PST 2015 x86_64 x86_64 x86_64

2. Find the device's UUID
[Root@linuxidc.com ~]# Fdisk-l

disk/dev/sdb:5368 MB, 5368709120 bytes, 10485760 sectors
Units = sectors of 1 * the bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk label Type:dos
Disk identifier:0x41b4373b

Device Boot Start End Blocks Id System

disk/dev/sda:53.7 GB, 53687091200 bytes, 104857600 sectors
Units = sectors of 1 * the bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk label Type:dos
Disk IDENTIFIER:0X000209AA

Device Boot Start End Blocks Id System
/DEV/SDA1 * 2048 1026047 512000 Linux
/dev/sda2 1026048 104857599 51915776 8e Linux LVM

disk/dev/sdc:5368 MB, 5368709120 bytes, 10485760 sectors
Units = sectors of 1 * the bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes


disk/dev/mapper/ol-root:47.7 GB, 47747956736 bytes, 93257728 sectors
Units = sectors of 1 * the bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes


disk/dev/mapper/ol-swap:5368 MB, 5368709120 bytes, 10485760 sectors
Units = sectors of 1 * the bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes

[Root@linuxidc.com dev]#/usr/lib/udev/scsi_id-g-u/dev/sdb
36000c294ae49672e100c14f8d1708ba0
[Root@linuxidc.com dev]#/usr/lib/udev/scsi_id-g-U/DEV/SDC
36000c2952e94e2262a0c351bbb9817eb

Note: If you are using the Vmvare virtual machine, then the display UUID needs to add disk.enableuuid = "TRUE" in the Vmx file, where I use the vmvare virtual machine, vmx file in the corresponding virtual machine adds Disk.enableuuid = " TRUE "
~ # VI/VMFS/VOLUMES/581C05D5-12B526B2-F04F-5C260AFD5108/ORACLE_LINUX7_1/ORACLE_LINUX7_1.VMX
. Encoding = "UTF-8"
Disk. Enableuuid= "TRUE"
... Omitted...

3. Create a new Udev rule
[Root@linuxidc.com dev]# Vi/etc/udev/rules.d/99-my-asmdevices.rules

kernel== "sd*[!0-9]", env{devtype}== "Disk", subsystem== "block", program== "/usr/lib/udev/scsi_id-g-u-d $devnode", result== "36000c294ae49672e100c14f8d1708ba0", run+= "/bin/sh-c ' mknod/dev/asmdisk01 b $major $minor; Chown grid:oinstall/dev/asmdisk01; chmod 0660/dev/asmdisk01 ' "

kernel== "sd*[!0-9]", env{devtype}== "Disk", subsystem== "block", program== "/usr/lib/udev/scsi_id-g-u-d $devnode", result== "36000c2952e94e2262a0c351bbb9817eb", run+= "/bin/sh-c ' mknod/dev/asmdisk02 b $major $minor; Chown grid:oinstall/dev/asmdisk02; chmod 0660/dev/asmdisk02 ' "

4. Test the new Udev rule
Perform the following command or reboot to verify the new Udev rule
4.1 Check the new device name:
[root@linuxidc.com dev]#/sbin/udevadm Trigger--type=devices--action=change

[Root@linuxidc.com dev]# LS-LRT asm*
BRW-RW----. 1 grid Oinstall 8, Dec 18:32 asmdisk02
BRW-RW----. 1 grid Oinstall 8, Dec 18:32 asmdisk01

4.2 To reload Udev rule execute the following command:
[root@linuxidc.com dev]#/sbin/udevadm Control--reload

4.3 In order to diagnose Udev rule, execute the following command:
[Root@linuxidc.com dev]#/sbin/udevadm Test/sys/block/sdb
Calling:test
Version 208
This are for debugging only, it does the not run no program
specified by a RUN key. It may show incorrect results, because
Some values may is different, or not available at a simulation run.

= = = Trie On-disk = =
Tool version:208
File size:6376691 bytes
Header size bytes
Strings 1401963 bytes
Nodes 4974648 bytes
Load Module Index
Read rules file:/usr/lib/udev/rules.d/10-dm.rules
Read rules file:/usr/lib/udev/rules.d/100-balloon.rules
Read rules file:/usr/lib/udev/rules.d/11-dm-lvm.rules
Read rules file:/usr/lib/udev/rules.d/11-dm-mpath.rules
Read rules file:/usr/lib/udev/rules.d/13-dm-disk.rules
Read rules file:/usr/lib/udev/rules.d/40-libgphoto2.rules
IMPORT found Builtin ' usb_id--export%%p ', replacing/usr/lib/udev/rules.d/40-libgphoto2.rules:11
Read rules file:/usr/lib/udev/rules.d/40-redhat.rules
Read rules file:/usr/lib/udev/rules.d/40-usb-media-players.rules
Read rules file:/usr/lib/udev/rules.d/40-usb_modeswitch.rules
Read rules file:/usr/lib/udev/rules.d/42-usb-hid-pm.rules
Read rules file:/usr/lib/udev/rules.d/50-rbd.rules
Read rules file:/usr/lib/udev/rules.d/50-udev-default.rules
Read rules file:/usr/lib/udev/rules.d/56-hpmud.rules
Read rules file:/usr/lib/udev/rules.d/60-alias-kmsg.rules
Read rules file:/usr/lib/udev/rules.d/60-cdrom_id.rules
Read rules file:/usr/lib/udev/rules.d/60-fprint-autosuspend.rules
Read rules file:/usr/lib/udev/rules.d/60-keyboard.rules
Read rules file:/usr/lib/udev/rules.d/60-net.rules
Read rules file:/usr/lib/udev/rules.d/60-persistent-alsa.rules
Read rules file:/usr/lib/udev/rules.d/60-persistent-input.rules
Read rules file:/usr/lib/udev/rules.d/60-persistent-serial.rules
Read rules file:/usr/lib/udev/rules.d/60-persistent-storage-tape.rules
Read rules file:/usr/lib/udev/rules.d/60-persistent-storage.rules
Read rules file:/usr/lib/udev/rules.d/60-persistent-v4l.rules
Read rules file:/usr/lib/udev/rules.d/60-raw.rules
Read rules file:/usr/lib/udev/rules.d/61-accelerometer.rules
Read rules file:/usr/lib/udev/rules.d/61-gnome-bluetooth-rfkill.rules
Read rules file:/usr/lib/udev/rules.d/62-multipath.rules
Read rules file:/usr/lib/udev/rules.d/63-md-raid-arrays.rules
Read rules file:/usr/lib/udev/rules.d/64-btrfs.rules
Read rules file:/usr/lib/udev/rules.d/65-libwacom.rules
Read rules file:/usr/lib/udev/rules.d/65-md-incremental.rules
Read rules file:/usr/lib/udev/rules.d/65-sane-backends.rules
Read rules file:/usr/lib/udev/rules.d/69-cd-sensors.rules
IMPORT found Builtin ' usb_id--export%p ', replacing/usr/lib/udev/rules.d/69-cd-sensors.rules:89
Read rules file:/usr/lib/udev/rules.d/69-dm-lvm-metad.rules
Read rules file:/usr/lib/udev/rules.d/69-libmtp.rules
Read rules file:/usr/lib/udev/rules.d/69-xorg-vmmouse.rules
Read rules file:/etc/udev/rules.d/70-persistent-ipoib.rules
Read rules file:/usr/lib/udev/rules.d/70-power-switch.rules
Read rules file:/usr/lib/udev/rules.d/70-printers.rules
Read rules file:/usr/lib/udev/rules.d/70-spice-vdagentd.rules
Read rules file:/usr/lib/udev/rules.d/70-touchpad-quirks.rules
Read rules file:/usr/lib/udev/rules.d/70-uaccess.rules
Read rules file:/usr/lib/udev/rules.d/70-wacom.rules
Read rules file:/usr/lib/udev/rules.d/71-biosdevname.rules
Read rules file:/usr/lib/udev/rules.d/71-seat.rules
Read rules file:/usr/lib/udev/rules.d/73-idrac.rules
Read rules file:/usr/lib/udev/rules.d/73-seat-late.rules
Read rules file:/usr/lib/udev/rules.d/75-net-description.rules
Read rules file:/usr/lib/udev/rules.d/75-probe_mtd.rules
Read rules file:/usr/lib/udev/rules.d/75-tty-description.rules
Read rules file:/usr/lib/udev/rules.d/77-mm-ericsson-mbm.rules
Read rules file:/usr/lib/udev/rules.d/77-mm-huawei-net-port-types.rules
Read rules file:/usr/lib/udev/rules.d/77-mm-longcheer-port-types.rules
Read rules file:/usr/lib/udev/rules.d/77-mm-nokia-port-types.rules
Read rules file:/usr/lib/udev/rules.d/77-mm-pcmcia-device-blacklist.rules
Read rules file:/usr/lib/udev/rules.d/77-mm-platform-serial-whitelist.rules
Read rules file:/usr/lib/udev/rules.d/77-mm-simtech-port-types.rules
Read rules file:/usr/lib/udev/rules.d/77-mm-telit-port-types.rules
Read rules file:/usr/lib/udev/rules.d/77-mm-usb-device-blacklist.rules
Read rules file:/usr/lib/udev/rules.d/77-mm-usb-serial-adapters-greylist.rules
Read rules file:/usr/lib/udev/rules.d/77-mm-x22x-port-types.rules
Read rules file:/usr/lib/udev/rules.d/77-mm-zte-port-types.rules
Read rules file:/usr/lib/udev/rules.d/77-nm-olpc-mesh.rules
Read rules file:/usr/lib/udev/rules.d/78-sound-card.rules
Read rules file:/usr/lib/udev/rules.d/80-drivers.rules
Read rules file:/usr/lib/udev/rules.d/80-kvm.rules
Read rules file:/usr/lib/udev/rules.d/80-mm-candidate.rules
Read rules file:/usr/lib/udev/rules.d/80-net-name-slot.rules
Read rules file:/usr/lib/udev/rules.d/80-udisks2.rules
Read rules file:/usr/lib/udev/rules.d/81-kvm-rhel.rules
Read rules file:/usr/lib/udev/rules.d/85-regulatory.rules
Read rules file:/usr/lib/udev/rules.d/85-usbmuxd.rules
Read rules file:/usr/lib/udev/rules.d/90-alsa-restore.rules
Read rules file:/usr/lib/udev/rules.d/90-alsa-tools-firmware.rules
Read rules file:/usr/lib/udev/rules.d/90-iprutils.rules
Read rules file:/usr/lib/udev/rules.d/90-pulseaudio.rules
Read rules file:/usr/lib/udev/rules.d/90-vconsole.rules
Read rules file:/usr/lib/udev/rules.d/91-drm-modeset.rules
Read rules file:/usr/lib/udev/rules.d/95-cd-devices.rules
Read rules file:/usr/lib/udev/rules.d/95-dm-notify.rules
Read rules file:/usr/lib/udev/rules.d/95-udev-late.rules
Read rules file:/usr/lib/udev/rules.d/95-upower-battery-recall-dell.rules
Read rules file:/usr/lib/udev/rules.d/95-upower-battery-recall-fujitsu.rules
Read rules file:/usr/lib/udev/rules.d/95-upower-battery-recall-gateway.rules
Read rules file:/usr/lib/udev/rules.d/95-upower-battery-recall-ibm.rules
Read rules file:/usr/lib/udev/rules.d/95-upower-battery-recall-lenovo.rules
Read rules file:/usr/lib/udev/rules.d/95-upower-battery-recall-toshiba.rules
Read rules file:/usr/lib/udev/rules.d/95-upower-csr.rules
Read rules file:/usr/lib/udev/rules.d/95-upower-hid.rules
Read rules file:/usr/lib/udev/rules.d/95-upower-wup.rules
Read rules file:/usr/lib/udev/rules.d/97-bluetooth-serial.rules
Read rules file:/usr/lib/udev/rules.d/98-kexec.rules
Read rules file:/usr/lib/udev/rules.d/98-rdma.rules
Read rules file:/etc/udev/rules.d/99-my-asmdevices.rules
Read rules file:/usr/lib/udev/rules.d/99-qemu-guest-agent.rules
Read rules file:/usr/lib/udev/rules.d/99-systemd.rules
Rules contain 393216 bytes tokens (32768 * bytes), 38852 bytes
30460 strings (257150 bytes), 27006 de-duplicated (221753 bytes), 3455 trie nodes
GROUP 6/usr/lib/udev/rules.d/50-udev-default.rules:51
IMPORT ' scsi_id--export--whitelisted-d/dev/sdb '/usr/lib/udev/rules.d/60-persistent-storage.rules:40
Starting ' scsi_id--export--whitelisted-d/dev/sdb '
' scsi_id--export--whitelisted-d/dev/sdb ' (out) ' Id_scsi=1 '
' scsi_id--export--whitelisted-d/dev/sdb ' (out) ' Id_vendor=vmware '
' scsi_id--export--whitelisted-d/dev/sdb ' (out) ' id_vendor_enc=vmware\x20\x20 '
' scsi_id--export--whitelisted-d/dev/sdb ' (out) ' Id_model=virtual_disk '
' scsi_id--export--whitelisted-d/dev/sdb ' (out) ' Id_model_enc=virtual\x20disk \x20\x20\x20\x20 '
' scsi_id--export--whitelisted-d/dev/sdb ' (out) ' id_revision=1.0 '
' scsi_id--export--whitelisted-d/dev/sdb ' (out) ' Id_type=disk '
' scsi_id--export--whitelisted-d/dev/sdb ' (out) ' id_serial=36000c294ae49672e100c14f8d1708ba0 '
' scsi_id--export--whitelisted-d/dev/sdb ' (out) ' id_serial_short=6000c294ae49672e100c14f8d1708ba0 '
' scsi_id--export--whitelisted-d/dev/sdb ' (out) ' id_wwn=0x6000c294ae49672e '
' scsi_id--export--whitelisted-d/dev/sdb ' (out) ' id_wwn_vendor_extension=0x100c14f8d1708ba0 '
' scsi_id--export--whitelisted-d/dev/sdb ' (out) ' id_wwn_with_extension=0x6000c294ae49672e100c14f8d1708ba0 '
' scsi_id--export--whitelisted-d/dev/sdb ' (out) ' id_scsi_serial=6000c294ae49672e100c14f8d1708ba0 '
' scsi_id--export--whitelisted-d/dev/sdb ' [24105] exit with return code 0
LINK ' disk/by-id/scsi-36000c294ae49672e100c14f8d1708ba0 '/usr/lib/udev/rules.d/60-persistent-storage.rules:42
IMPORT builtin ' path_id '/usr/lib/udev/rules.d/60-persistent-storage.rules:58
LINK ' disk/by-path/pci-0000:02:01.0-scsi-0:0:0:0 '/usr/lib/udev/rules.d/60-persistent-storage.rules:59
IMPORT builtin ' Blkid '/usr/lib/udev/rules.d/60-persistent-storage.rules:73
Probe/dev/sdb raid offset=0
LINK ' disk/by-id/wwn-0x6000c294ae49672e100c14f8d1708ba0 '/usr/lib/udev/rules.d/60-persistent-storage.rules:83
Program '/usr/lib/udev/scsi_id-g-u-d/dev/sdb '/etc/udev/rules.d/99-my-asmdevices.rules:2
Starting '/usr/lib/udev/scsi_id-g-u-d/dev/sdb '
'/usr/lib/udev/scsi_id-g-u-d/dev/sdb ' (out) ' 36000c294ae49672e100c14f8d1708ba0 '
'/usr/lib/udev/scsi_id-g-u-d/dev/sdb ' [24106] exit with return code 0
RUN '/bin/sh-c ' mknod/dev/asmdisk01 b $major $minor; Chown grid:oinstall/dev/asmdisk01; chmod 0660/dev/asmdisk01 '/etc/udev/rules.d/99-my-asmdevices.rules:2
Program '/usr/lib/udev/scsi_id-g-u-d/dev/sdb '/etc/udev/rules.d/99-my-asmdevices.rules:4
Starting '/usr/lib/udev/scsi_id-g-u-d/dev/sdb '
'/usr/lib/udev/scsi_id-g-u-d/dev/sdb ' (out) ' 36000c294ae49672e100c14f8d1708ba0 '
'/usr/lib/udev/scsi_id-g-u-d/dev/sdb ' [24107] exit with return code 0
Handling Device node '/dev/sdb ', devnum=b8:16, mode=0660, Uid=0, gid=6
Set Permissions/dev/sdb, 060660, Uid=0, gid=6
Preserve already existing symlink '/dev/block/8:16 ' to '. /sdb '
Found ' b8:16 ' claiming '/run/udev/links/\x2fdisk\x2fby-id\x2fscsi-36000c294ae49672e100c14f8d1708ba0 '
Creating link '/dev/disk/by-id/scsi-36000c294ae49672e100c14f8d1708ba0 ' to '/dev/sdb '
Preserve already existing symlink '/dev/disk/by-id/scsi-36000c294ae49672e100c14f8d1708ba0 ' to '. /.. /sdb '
Found ' b8:16 ' claiming '/run/udev/links/\x2fdisk\x2fby-id\x2fwwn-0x6000c294ae49672e100c14f8d1708ba0 '
Creating link '/dev/disk/by-id/wwn-0x6000c294ae49672e100c14f8d1708ba0 ' to '/dev/sdb '
Preserve already existing symlink '/dev/disk/by-id/wwn-0x6000c294ae49672e100c14f8d1708ba0 ' to '. /.. /sdb '
Found ' b8:16 ' claiming '/run/udev/links/\x2fdisk\x2fby-path\x2fpci-0000:02:01.0-scsi-0:0:0:0 '
Creating link '/dev/disk/by-path/pci-0000:02:01.0-scsi-0:0:0:0 ' to '/dev/sdb '
Preserve already existing symlink '/dev/disk/by-path/pci-0000:02:01.0-scsi-0:0:0:0 ' to '. /.. /sdb '
. id_fs_type_new=
Action=add
devlinks=/dev/disk/by-id/scsi-36000c294ae49672e100c14f8d1708ba0/dev/disk/by-id/wwn- 0x6000c294ae49672e100c14f8d1708ba0/dev/disk/by-path/pci-0000:02:01.0-scsi-0:0:0:0
Devname=/dev/sdb
DEVPATH=/DEVICES/PCI0000:00/0000:00:11.0/0000:02:01.0/HOST3/TARGET3:0:0/3:0:0:0/BLOCK/SD b
Devtype=disk
Id_bus=scsi
Id_fs_type=
Id_model=virtual_disk
id_model_enc=virtual\x20disk\x20\x20\x20\x20
Id_part_table_type=dos
id_path=pci-0000:02:01.0-scsi-0:0:0:0
Id_path_tag=pci-0000_02_01_0-scsi-0_0_0_0
id_revision=1.0
Id_scsi=1
Id_scsi_serial=6000c294ae49672e100c14f8d1708ba0
Id_serial=36000c294ae49672e100c14f8d1708ba0
Id_serial_short=6000c294ae49672e100c14f8d1708ba0
Id_type=disk
Id_vendor=vmware
id_vendor_enc=vmware\x20\x20
id_wwn=0x6000c294ae49672e
Id_wwn_vendor_extension=0x100c14f8d1708ba0
Id_wwn_with_extension=0x6000c294ae49672e100c14f8d1708ba0
Major=8
Minor=16
Mpath_sbin_path=/sbin
Subsystem=block
TAGS=:SYSTEMD:
usec_initialized=545736
Run: '/bin/sh-c ' mknod/dev/asmdisk01 b 8 16; Chown grid:oinstall/dev/asmdisk01; chmod 0660/dev/asmdisk01 '
Unload Module Index

4.4 You can delete device files manually if you no longer need device
[Root@linuxidc.com dev]#/bin/rm/dev/asmdisk01
[Root@linuxidc.com dev]#/bin/rm/dev/asmdisk02
[Root@linuxidc.com dev]# LS-LRT asm*
Ls:cannot Access asm*: No such file or directory

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.