欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  科技

redhat 7.x 、redhat 6.x查看硬盘UUID方法

程序员文章站 2022-06-07 19:02:02
1、查看磁盘分区UUID: [root@rac01 ~]# blkid /dev/sdb1: UUID="6bba92c4-0b25-4cc4-9442-ca87c563720a" TYPE="xfs" /dev/sda1: UUID="21b2b922-fcb7-461f-bdc6-3bd9225 ......

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

 

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