2020-12-15

1、获取硬盘uuid

ls -l /dev/disk/by-uuid/

 sudo blkid /dev/sda1

2、、建立udev规则文件。

编辑/etc/udev/rules.d/20-names.rules

 添加如下内容:

KERNEL="sd*", BUS="scsi", PROGRAM="/sbin/scsi_id", RESULT="uuid", NAME="sda%n"重新启动系统

 

 

https://www.thegeekdiary.com/how-to-set-custom-device-names-using-udev-in-centos-rhel-7/

1. Find UUID of device

First, find the the UUID of the device with the scsi_id command as shown below.

 

# /usr/lib/udev/scsi_id -g -u /dev/sdb

1IET_00020002

Save this UUID, as this ID will be used later.

2. Create new udev rule

Create new udev rule file in appropriate location as below:

# vi /etc/udev/rules.d/99-my-asmdevices.rules

Add below content in 99-mydevices.rules file:

KERNEL=="sd*[!0-9]", ENV{DEVTYPE}=="disk", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d $devnode", RESULT=="1IET_00020002", RUN+="/bin/sh -c 'mknod /dev/asmdisk01p1 b $major $minor; chown grid:dba /dev/asmdisk01p1; chmod 0660 /dev/asmdisk01p1'"

Save the rule file.

3. Test new udev rule

Run below command or reboot to verify new udev rule
1. Check for new device name:

# udevadm trigger --type=devices --action=change
# /bin/ls /dev/asmdisk01p1

2. To reload udev rule execute below command:

# udevadm control --reload

3. For Troubleshooting udev rule execute below command:

# udevadm test /sys/block/sdb

Removing Device File

Remember to manually remove the device file if you no longer need it. Simply use rm to delete the device file as shown below.

# rm /dev/asmdisk01p1
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值