redhat 7.x 、redhat 6.x檢視硬碟UUID方法

it傻博士發表於2018-09-07

1、檢視磁碟分割槽UUID:

[root@rac01 ~]# blkid
/dev/sdb1: UUID="6bba92c4-0b25-4cc4-9442-ca87c563720a" TYPE="xfs" 
/dev/sda1: UUID="21b2b922-fcb7-461f-bdc6-3bd92259f8d7" TYPE="xfs" 
/dev/sda2: UUID="WC12Xe-0neg-Kmhp-u691-8bxn-8PpF-PuGgHH" TYPE="LVM2_member" 
/dev/mapper/rhel-root: UUID="774aa4fa-2bbe-4636-a3ce-3a8aec9cdb40" TYPE="xfs" 
/dev/mapper/rhel-swap: UUID="01075670-9314-4899-8d0f-23af11882416" TYPE="swap" 
/dev/sr0: UUID="2016-10-19-18-32-06-00" LABEL="RHEL-7.3 Server.x86_64" TYPE="iso9660" PTTYPE="dos" 
[root@rac01 ~]#

 

[root@rac01 ~]# ls -l /dev/disk/by-uuid/
total 0
lrwxrwxrwx. 1 root root 10 9月   2 23:49 01075670-9314-4899-8d0f-23af11882416 -> ../../dm-1
lrwxrwxrwx. 1 root root  9 9月   3 00:04 2016-10-19-18-32-06-00 -> ../../sr0
lrwxrwxrwx. 1 root root 10 9月   2 23:49 21b2b922-fcb7-461f-bdc6-3bd92259f8d7 -> ../../sda1
lrwxrwxrwx. 1 root root 10 9月   2 23:49 6bba92c4-0b25-4cc4-9442-ca87c563720a -> ../../sdb1
lrwxrwxrwx. 1 root root 10 9月   2 23:49 774aa4fa-2bbe-4636-a3ce-3a8aec9cdb40 -> ../../dm-0
[root@rac01 ~]#

 

2、檢視磁碟UUID

 

[root@rac01 ~]# lsscsi -i
[2:0:0:0]    disk    VMware,  VMware Virtual S 1.0   /dev/sda   -
[2:0:1:0]    disk    VMware,  VMware Virtual S 1.0   /dev/sdb   -
[4:0:0:0]    cd/dvd  NECVMWar VMware SATA CD01 1.00  /dev/sr0   -
[33:0:1:0]   disk    VMware,  VMware Virtual S 1.0   /dev/sdc   36000c29cd6841d61d151f17cfaae37c1
[33:0:2:0]   disk    VMware,  VMware Virtual S 1.0   /dev/sdd   36000c29981370abb4b6dbf6101ad8e9f
[33:0:3:0]   disk    VMware,  VMware Virtual S 1.0   /dev/sde   36000c29b71c709b99b63547534028558
[33:0:4:0]   disk    VMware,  VMware Virtual S 1.0   /dev/sdf   36000c29bbaf58c22dcb92b6f6e4c67e9
[33:0:5:0]   disk    VMware,  VMware Virtual S 1.0   /dev/sdg   36000c2942fbfb7d286d52d2e7fa5cf05
[33:0:6:0]   disk    VMware,  VMware Virtual S 1.0   /dev/sdh   36000c29ac6f46745dccdcb2e623064da
[root@rac01 ~]#

 

[root@rac01 ~]# ls -l /dev/disk/by-id
total 0
lrwxrwxrwx. 1 root root  9 9月   3 00:04 ata-VMware_Virtual_SATA_CDRW_Drive_01000000000000000001 -> ../../sr0
lrwxrwxrwx. 1 root root 10 9月   2 23:49 dm-name-rhel-root -> ../../dm-0
lrwxrwxrwx. 1 root root 10 9月   2 23:49 dm-name-rhel-swap -> ../../dm-1
lrwxrwxrwx. 1 root root 10 9月   2 23:49 dm-uuid-LVM-J1i1Vn6zXoJbfabPIPfJB0QKwuIkbSBEardSvOvgmlN05wDrG9PJHoxdW4m1RPwc -> ../../dm-0
lrwxrwxrwx. 1 root root 10 9月   2 23:49 dm-uuid-LVM-J1i1Vn6zXoJbfabPIPfJB0QKwuIkbSBEqNT9omSEi4skcnWqN8lfzMLPGqezyZhm -> ../../dm-1
lrwxrwxrwx. 1 root root 10 9月   2 23:49 lvm-pv-uuid-WC12Xe-0neg-Kmhp-u691-8bxn-8PpF-PuGgHH -> ../../sda2
lrwxrwxrwx. 1 root root  9 9月   2 23:49 scsi-36000c2942fbfb7d286d52d2e7fa5cf05 -> ../../sdg
lrwxrwxrwx. 1 root root  9 9月   2 23:49 scsi-36000c29981370abb4b6dbf6101ad8e9f -> ../../sdd
lrwxrwxrwx. 1 root root  9 9月   2 23:49 scsi-36000c29ac6f46745dccdcb2e623064da -> ../../sdh
lrwxrwxrwx. 1 root root  9 9月   2 23:49 scsi-36000c29b71c709b99b63547534028558 -> ../../sde
lrwxrwxrwx. 1 root root  9 9月   2 23:49 scsi-36000c29bbaf58c22dcb92b6f6e4c67e9 -> ../../sdf
lrwxrwxrwx. 1 root root  9 9月   2 23:49 scsi-36000c29cd6841d61d151f17cfaae37c1 -> ../../sdc
lrwxrwxrwx. 1 root root  9 9月   2 23:49 wwn-0x6000c2942fbfb7d286d52d2e7fa5cf05 -> ../../sdg
lrwxrwxrwx. 1 root root  9 9月   2 23:49 wwn-0x6000c29981370abb4b6dbf6101ad8e9f -> ../../sdd
lrwxrwxrwx. 1 root root  9 9月   2 23:49 wwn-0x6000c29ac6f46745dccdcb2e623064da -> ../../sdh
lrwxrwxrwx. 1 root root  9 9月   2 23:49 wwn-0x6000c29b71c709b99b63547534028558 -> ../../sde
lrwxrwxrwx. 1 root root  9 9月   2 23:49 wwn-0x6000c29bbaf58c22dcb92b6f6e4c67e9 -> ../../sdf
lrwxrwxrwx. 1 root root  9 9月   2 23:49 wwn-0x6000c29cd6841d61d151f17cfaae37c1 -> ../../sdc
[root@rac01 ~]#

 

使用/lib/udev/scsi_id檢視磁碟UUID

[root@rac01 ~]# /lib/udev/scsi_id --help
Usage: scsi_id [OPTION...] DEVICE
SCSI device identification.
  -h --help                        Print this message
    --version                     Print version of the program
  -d --device=                     Device node for SG_IO commands
  -f --config=                     Location of config file
  -p --page=0x80|0x83|pre-spc3-83  SCSI page (0x80, 0x83, pre-spc3-83)
  -s --sg-version=3|4              Use SGv3 or SGv4
  -b --blacklisted                 Treat device as blacklisted
  -g --whitelisted                 Treat device as whitelisted
  -u --replace-whitespace          Replace all whitespace by underscores
  -v --verbose                     Verbose logging
  -x --export                      Print values as environment keys
[root@rac01 ~]#

 

命令:/lib/udev/scsi_id –whitelisted –device=/dev/sd*

[root@rac01 ~]# /lib/udev/scsi_id --whitelisted --device=/dev/sdc
36000c29cd6841d61d151f17cfaae37c1
[root@rac01 ~]# /lib/udev/scsi_id --whitelisted --device=/dev/sdd
36000c29981370abb4b6dbf6101ad8e9f
[root@rac01 ~]# /lib/udev/scsi_id --whitelisted --device=/dev/sde
36000c29b71c709b99b63547534028558
[root@rac01 ~]# /lib/udev/scsi_id --whitelisted --device=/dev/sdf
36000c29bbaf58c22dcb92b6f6e4c67e9
[root@rac01 ~]# /lib/udev/scsi_id --whitelisted --device=/dev/sdg
36000c2942fbfb7d286d52d2e7fa5cf05
[root@rac01 ~]# /lib/udev/scsi_id --whitelisted --device=/dev/sdh
36000c29ac6f46745dccdcb2e623064da
[root@rac01 ~]#

 

******************************************************************************

注:

redhat 6.x命令為:

scsi_id –whitelisted –device=/dev/sd*

******************************************************************************

 

3、使用指令碼輸入磁碟UUID

符號“c d e f g h”為磁碟名

linux 7.x指令碼為

[root@rac01 ~]# for i in c d e f g h; 
> do 
> echo "sd$i" "`/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/sd$i` "; 
> done
sdc 36000c29cd6841d61d151f17cfaae37c1 
sdd 36000c29981370abb4b6dbf6101ad8e9f 
sde 36000c29b71c709b99b63547534028558 
sdf 36000c29bbaf58c22dcb92b6f6e4c67e9 
sdg 36000c2942fbfb7d286d52d2e7fa5cf05 
sdh 36000c29ac6f46745dccdcb2e623064da 
[root@rac01 ~]#

 

******************************************************************************

注:

linux 6.x指令碼為

> do 
> echo "sd$i" "`scsi_id --whitelisted --replace-whitespace --device=/dev/sd$i` "; 
> done
sdc 36000c29cd6841d61d151f17cfaae37c1 
sdd 36000c29981370abb4b6dbf6101ad8e9f 
sde 36000c29b71c709b99b63547534028558 
sdf 36000c29bbaf58c22dcb92b6f6e4c67e9 
sdg 36000c2942fbfb7d286d52d2e7fa5cf05 
sdh 36000c29ac6f46745dccdcb2e623064da 
[root@rac01 ~]#

 

******************************************************************************

 

4、Oracle ASM配置

生成檔案內容的指令碼

 

for i in c d e f g h;
do
echo "KERNEL=="sd*",BUS=="scsi", PROGRAM=="/lib/udev/scsi_id --whitelisted --replace-whitespace--device=/dev/$name", RESULT=="`/lib/udev/scsi_id --whitelisted--replace-whitespace --device=/dev/sd$i`", NAME="asm-disk$i",OWNER="grid", GROUP="asmadmin",MODE="0660""     
done
 
[root@rac01 ~]# for i in c d e f g h;
> do
> echo "KERNEL=="sd*", BUS=="scsi", PROGRAM=="/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="`/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/sd$i`", NAME="asm-disk$i", OWNER="grid", GROUP="asmadmin", MODE="0660""      
> done
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="36000c29cd6841d61d151f17cfaae37c1", NAME="asm-diskc", OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="36000c29981370abb4b6dbf6101ad8e9f", NAME="asm-diskd", OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="36000c29b71c709b99b63547534028558", NAME="asm-diske", OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="36000c29bbaf58c22dcb92b6f6e4c67e9", NAME="asm-diskf", OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="36000c2942fbfb7d286d52d2e7fa5cf05", NAME="asm-diskg", OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="36000c29ac6f46745dccdcb2e623064da", NAME="asm-diskh", OWNER="grid", GROUP="asmadmin", MODE="0660"
[root@rac01 ~]#

 

編寫/etc/udev/rules檔案,新增ASM塊裝置

將生成的內容儲存在99-oracle-asmdevices.rules檔案中。

修改磁碟名,便於識別:asm-grid1……

vim /etc/udev/rules.d/99-oracle-asmdevices.rules

linux 6.x

#linux 6.x
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="36000c29cd6841d61d151f17cfaae37c1", NAME="asm-grid1", OWNER="grid", GROUP="asmadmin", MODE="0660"

KERNEL=="sd*", BUS=="scsi", PROGRAM=="/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="36000c29981370abb4b6dbf6101ad8e9f", NAME="asm-grid2", OWNER="grid", GROUP="asmadmin", MODE="0660"

KERNEL=="sd*", BUS=="scsi", PROGRAM=="/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="36000c29b71c709b99b63547534028558", NAME="asm-dgsystem", OWNER="grid", GROUP="asmadmin", MODE="0660"

KERNEL=="sd*", BUS=="scsi", PROGRAM=="/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="36000c29bbaf58c22dcb92b6f6e4c67e9", NAME="asm-dgrecovery", OWNER="grid", GROUP="asmadmin", MODE="0660"

KERNEL=="sd*", BUS=="scsi", PROGRAM=="/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="36000c2942fbfb7d286d52d2e7fa5cf05", NAME="asm-dgdata1", OWNER="grid", GROUP="asmadmin", MODE="0660"

KERNEL=="sd*", BUS=="scsi", PROGRAM=="/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="36000c29ac6f46745dccdcb2e623064da", NAME="asm-dgdata2", OWNER="grid", GROUP="asmadmin", MODE="0660"

 

linux7.x

#linux 7.x
KERNEL=="sdc",SUBSYSTEM=="block",PROGRAM=="/usr/lib/udev/scsi_id-g -u -d /dev/$name",RESULT=="36000c29cd6841d61d151f17cfaae37c1",SYMLINK+="asm-grid1",OWNER="grid",GROUP="asmadmin",MODE="0660"
 
KERNEL=="sdd",SUBSYSTEM=="block",PROGRAM=="/usr/lib/udev/scsi_id-g -u -d /dev/$name",RESULT=="36000c29981370abb4b6dbf6101ad8e9f",SYMLINK+="asm-grid2",OWNER="grid",GROUP="asmadmin",MODE="0660"
 
KERNEL=="sde",SUBSYSTEM=="block",PROGRAM=="/usr/lib/udev/scsi_id-g -u -d /dev/$name",RESULT=="36000c29b71c709b99b63547534028558",SYMLINK+="asm-dgsystem",OWNER="grid",GROUP="asmadmin",MODE="0660"
 
KERNEL=="sdf",SUBSYSTEM=="block",PROGRAM=="/usr/lib/udev/scsi_id-g -u -d /dev/$name",RESULT=="36000c29bbaf58c22dcb92b6f6e4c67e9",SYMLINK+="asm-dgrecovery",OWNER="grid",GROUP="asmadmin",MODE="0660"
 
KERNEL=="sdg",SUBSYSTEM=="block",PROGRAM=="/usr/lib/udev/scsi_id-g -u -d /dev/$name",RESULT=="36000c2942fbfb7d286d52d2e7fa5cf05",SYMLINK+="asm-dgdata1",OWNER="grid",GROUP="asmadmin",MODE="0660"
 
KERNEL=="sdh",SUBSYSTEM=="block",PROGRAM=="/usr/lib/udev/scsi_id-g -u -d /dev/$name",RESULT=="36000c29ac6f46745dccdcb2e623064da",SYMLINK+="asm-dgdata2",OWNER="grid",GROUP="asmadmin",MODE="0660"

 

5、重啟udev裝置

/sbin/udevadm control --reload-rules

/sbin/start_udev

udevadm trigger

systemctl restartsystemd-udevd.service

[root@rac01 ~]# partprobe

[root@rac01 ~]# ll /dev/a*

crw-rw----. 1 root video 10, 175 9月   4 02:47 /dev/agpgart

lrwxrwxrwx. 1 root root        3 9月   4 02:59 /dev/asm-dgdata1 -> sdg

lrwxrwxrwx. 1 root root        3 9月   4 02:59 /dev/asm-dgdata2 -> sdh

lrwxrwxrwx. 1 root root        3 9月   4 02:59 /dev/asm-dgrecovery -> sdf

lrwxrwxrwx. 1 root root        3 9月   4 02:59 /dev/asm-dgsystem -> sde

lrwxrwxrwx. 1 root root        3 9月   4 02:59 /dev/asm-grid1 -> sdc

lrwxrwxrwx. 1 root root        3 9月   4 02:59 /dev/asm-grid2 -> sdd

crw-------. 1 root root  10, 235 9月   4 02:47 /dev/autofs

[root@rac01 ~]#

 

6、重新生成

# rm -rf /dev/asm-dgsystem 

/sbin/udevadm control --reload-rules

/sbin/start_udev

udevadm trigger

systemctl restartsystemd-udevd.service

ll /dev/a*

 

***************************************************************************************

RestartUDEV Service

Restart the UDEV service.

# #OL5
# /sbin/udevcontrol reload_rules
 
# #OL6 and OL7
# udevadm control --reload-rules
 
# #OL5 and OL6 : Not needed for OL7
# /sbin/start_udev

 

***************************************************************************************

 

 

參考:

https://oracle-base.com/articles/linux/udev-scsi-rules-configuration-in-oracle-linux

http://www.zhongweicheng.com/?p=1608

相關文章