使用UDEV绑定设备名

UUID的获取方法:
1、 ls -l /dev/disk/by-uuid/ 
2、 blkid 
3、scsi_id -g -s /block/sdc

Red Hat Enterprise Linux ES 4 (x86) - How To Create Persistent Device Names Using UDEV

Information

In cases where we need to assign a persistent device name to a LUN or a tape device, udev comes handy. Applicable to RHEL4 only as udev is found in RHEL4 and later.

Details

Instead of udev assigning a device name at the time of booting, we can assign persistent device name using the UUID of the device. Steps are as follows:

- To allow udev to acquire the UUIDs for device,

edit /etc/scsi_id.config and change the "options=-b" line to:"options=-g"

This tells udev to assume that all the SCSI devices on the system will return a UUID. 

- To get the UUID, run this command:

  
 # scsi_id -g -s /block/sdc   

The output will look something like the following:

       
[root@devices]# scsi_id -g -s /block/sdc   
3600a0b800013275100000015427b625e     

The result (the long string of characters) will be the UUID. Verify that the UUID ID is the same for each path to the device. The UUID is what the device names will be keyed off of. UUIDs do not change if a device is added to the system. 

- Now, rules need to be created for naming the device. Create the /etc/udev/rules.d/20-names.rules file.

Within this file, the naming rule will be added. Any subsequent rules will be added in this file with the same format. 

Rules should have the following format: 

  
KERNEL="sd*", BUS="scsi", PROGRAM="/sbin/scsi_id", RESULT="UUID", NAME="devicename%n"   

Replace UUID and device-name with the UUID retrieved above, and the desired name for the device. In the example, the rule would look as follows: 

  
KERNEL="sd*", BUS="scsi", PROGRAM="/sbin/scsi_id", RESULT="3600a0b800013275100000015427b625e", NAME="mydevice"   

This will cause the system to check all devices which match /dev/sd* to be checked for the given UUID. When it finds a matching device, it will create a device node named /dev/devicename. In this example, the device node would be /dev/mydevice. 

To confirm that the rule is working correctly, run 

The device should appear as /dev/mydevice

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/22531473/viewspace-742483/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/22531473/viewspace-742483/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值