Redhat Linux 7 创建UDEV设备

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Redhat Linux 7 创建UDEV设备相关的知识,希望对你有一定的参考价值。

RHEL7下的udev管理与之前的版本有一定的区别,下面简单介绍了基于LVM的UDEV配置。
1、创建逻辑卷

[[email protected] ~]# pvcreate /dev/sdb
[[email protected] ~]# vgcreate datavg /dev/sdb
[[email protected] ~]# for id in catbs ustbs tmtbs;do lvcreate -n $id -L +512M datavg;done
[[email protected] ~]# lvcreate -n tbs01 -L +20G datavg
[[email protected] ~]# for id in stbs1 utbs1;do lvcreate -n $id -L +1G datavg;done
[[email protected] ~]# ll /dev/dm-{2..7}
brw-rw---- 1 root disk 249, 2 Jul 19 11:49 /dev/dm-2
brw-rw---- 1 root disk 249, 3 Jul 19 11:49 /dev/dm-3
brw-rw---- 1 root disk 249, 4 Jul 19 11:49 /dev/dm-4
brw-rw---- 1 root disk 249, 5 Jul 19 11:49 /dev/dm-5
brw-rw---- 1 root disk 249, 6 Jul 19 11:49 /dev/dm-6
brw-rw---- 1 root disk 249, 7 Jul 19 11:49 /dev/dm-7

2、获取UUID

[[email protected] ~]# for i in {2..7};do udevadm info --query=all --name=/dev/dm-$i | grep -i DM_UUID;done
E: DM_UUID=LVM-F5TLuj05MSbaG40MlW1YJnvwLdGrZd7YfWXcy2QJ0N17L2HuAsEzTlfWBTMyXMjX
E: DM_UUID=LVM-F5TLuj05MSbaG40MlW1YJnvwLdGrZd7YIVnlrSdMdMe6MrdpzT1oWR4oGVYjLgTP
E: DM_UUID=LVM-F5TLuj05MSbaG40MlW1YJnvwLdGrZd7YA6DF2S7gHxiWwonFFnGskv8oqn09ehuJ
E: DM_UUID=LVM-F5TLuj05MSbaG40MlW1YJnvwLdGrZd7YX43yw6FLWfDYGKQ4iCMQYoj5CCaWsO0z
E: DM_UUID=LVM-F5TLuj05MSbaG40MlW1YJnvwLdGrZd7YV5Ft9f0ld7QjxASNgvkHFqoSWfgJqvsT
E: DM_UUID=LVM-F5TLuj05MSbaG40MlW1YJnvwLdGrZd7YJwktSMWrevmXvzi4DwzYvswwtOuu1U9o

对应的udev规则文件内容如下:

[[email protected] ~]# cat /etc/udev/rules.d/99-db2disk-owner.rules 
ACTION=="add|change", ENV{DM_UUID}=="LVM-F5TLuj05MSbaG40MlW1YJnvwLdGrZd7YfWXcy2QJ0N17L2HuAsEzTlfWBTMyXMjX", NAME="catbs",  OWNER="abcinst", GROUP="db2iadm", MODE="0660"
ACTION=="add|change", ENV{DM_UUID}=="LVM-F5TLuj05MSbaG40MlW1YJnvwLdGrZd7YIVnlrSdMdMe6MrdpzT1oWR4oGVYjLgTP", NAME="ustbs",  OWNER="abcinst", GROUP="db2iadm", MODE="0660"
ACTION=="add|change", ENV{DM_UUID}=="LVM-F5TLuj05MSbaG40MlW1YJnvwLdGrZd7YA6DF2S7gHxiWwonFFnGskv8oqn09ehuJ", NAME="tmtbs", OWNER="abcinst", GROUP="db2iadm", MODE="0660"
ACTION=="add|change", ENV{DM_UUID}=="LVM-F5TLuj05MSbaG40MlW1YJnvwLdGrZd7YX43yw6FLWfDYGKQ4iCMQYoj5CCaWsO0z", NAME="tbs01", OWNER="abcinst", GROUP="db2iadm", MODE="0660"
ACTION=="add|change", ENV{DM_UUID}=="LVM-F5TLuj05MSbaG40MlW1YJnvwLdGrZd7YV5Ft9f0ld7QjxASNgvkHFqoSWfgJqvsT", NAME="stbs1", OWNER="abcinst", GROUP="db2iadm", MODE="0660"
ACTION=="add|change", ENV{DM_UUID}=="LVM-F5TLuj05MSbaG40MlW1YJnvwLdGrZd7YJwktSMWrevmXvzi4DwzYvswwtOuu1U9o", NAME="utbs1", OWNER="abcinst", GROUP="db2iadm", MODE="0660"

3、启动UDEV

[[email protected] ~]# /usr/sbin/udevadm trigger
[[email protected] ~]# ll /dev/dm-{2..7}
brw-rw---- 1 abcinst db2iadm 249, 2 Jul 19 14:46 /dev/dm-2
brw-rw---- 1 abcinst db2iadm 249, 3 Jul 19 14:46 /dev/dm-3
brw-rw---- 1 abcinst db2iadm 249, 4 Jul 19 14:46 /dev/dm-4
brw-rw---- 1 abcinst db2iadm 249, 5 Jul 19 14:46 /dev/dm-5
brw-rw---- 1 abcinst db2iadm 249, 6 Jul 19 14:46 /dev/dm-6
brw-rw---- 1 abcinst db2iadm 249, 7 Jul 19 14:46 /dev/dm-7

以上是关于Redhat Linux 7 创建UDEV设备的主要内容,如果未能解决你的问题,请参考以下文章

linux下udev

udev

udev

定义磁盘设备的名称 linux udev

详解udev

Linux设备文件自动生成