Using Udev to bind shared storage on Linux 6

Source: Internet
Author: User

1. How to view the hard drive;
2. Obtain the hard disk scsi (Smallcomputer System Interface) ID;
3. Bind shared storage;
4. Bind the shared storage script;

1. How to view the hard drive:

[Email protected] ~]# ls-ltr/dev/sd*
BRW-RW----. 1 root disk 8, 48 August 13:34/DEV/SDD
BRW-RW----. 1 root disk 8, 16 August 13:34/dev/sdb
BRW-RW----. 1 root disk 8, 32 August 13:34/DEV/SDC
BRW-RW----. 1 root disk 8, 80 August 13:34/DEV/SDF
BRW-RW----. 1 root disk 8, 64 August 13:34/DEV/SDE
BRW-RW----. 1 root disk 8, 0 August 13:34/DEV/SDA
BRW-RW----. 1 root disk 8, 4 August 13:34/dev/sda4
BRW-RW----. 1 root disk 8, 8 August 13:34/dev/sda8
BRW-RW----. 1 root disk 8, 9 August 13:34/dev/sda9
BRW-RW----. 1 root disk 8, 1 August 13:34/dev/sda1
BRW-RW----. 1 root disk 8, 6 August 13:34/dev/sda6
BRW-RW----. 1 root disk 8, 3 August 13:34/dev/sda3
BRW-RW----. 1 root disk 8, 2 August 13:34/dev/sda2
BRW-RW----. 1 root disk 8, 7 August 13:34/DEV/SDA7
BRW-RW----. 1 root disk 8, 5 August 13:34/dev/sda5

SDA represents the local hard disk, sda1,2,3,6: Represents the partition on the local hard disk, SDB. F represents a non-local hard disk, whether the specific hard disk partition is mounted on the system, you can use the DF command query:

[Email protected] ~]# DF-HT
Filesystem Type Size used Avail use% mounted on
/dev/sda9 ext4 62G 551M 58G 1%/
Tmpfs tmpfs 499M 0 499M 0%/dev/shm
/DEV/SDA1 ext4 291M 56M 220M 21%/boot
/dev/sda6 ext4 5.1G 139M 4.7G 3%/home
/dev/sda3 ext4 5.1G 161M 4.7G 4%/opt
/dev/sda2 ext4 15G 2.9G 12G 21%/usr
/dev/sda7 ext4 5.1G 139M 4.7G 3%/usr/local
/dev/sda5 ext4 5.1G 611M 4.2G 13%/var

2. Obtain the hard disk scsi (Small computer System Interface) ID:
SCSI is a standard physical connection and transfer of data between computers and peripherals, SCSI defines standard commands, protocols, and electrical optical interfaces for hard disk and tape devices, and when configuring shared storage, you need to bind the device through the SCSI ID to the system, and the following operations get the SCSI ID of the shared storage in My computer:

[Email protected] ~]#/sbin/scsi_id--whitelisted--replace-whitespace--device=/dev/sdb
1ata_vbox_harddisk_vbf1082ced-38c590fb
[Email protected] ~]#/sbin/scsi_id--whitelisted--REPLACE-WHITESPACE--DEVICE=/DEV/SDC
1ata_vbox_harddisk_vbcb889b15-45566527
[Email protected] ~]#/sbin/scsi_id--whitelisted--REPLACE-WHITESPACE--DEVICE=/DEV/SDD
1ata_vbox_harddisk_vb91e00a0b-5bc96a2b
[Email protected] ~]#/sbin/scsi_id--whitelisted--replace-whitespace--device=/dev/sde
1ata_vbox_harddisk_vbe9eca0fb-a99c152d
[Email protected] ~]#/sbin/scsi_id--whitelisted--replace-whitespace--device=/dev/sdf
1ata_vbox_harddisk_vb414d8bfa-0256c987

3. Bind shared storage:
Establish the Rules file (note format)/etc/udev/rules.d/99-oracle-asmdevices.rules, each entry corresponds to a disk device, program defines the UDEV device name; name defines the Udev device link name, The name will be displayed in the/dev/directory; RESULT defines the device's SCSI id;owner to define the device owner; Group defines the user groups for the device owner:

kernel== "sd*", bus== "scsi", program== "/sbin/scsi_id--whitelisted--replace-whitespace--device=/dev/$name", RESULT= = "1ATA_VBOX_HARDDISK_VBF1082CED-38C590FB", name= "ASM-DISKB", owner= "grid", group= "Asmadmin", mode= "0660"
kernel== "sd*", bus== "scsi", program== "/sbin/scsi_id--whitelisted--replace-whitespace--device=/dev/$name", RESULT= = "1ata_vbox_harddisk_vbcb889b15-45566527", name= "ASM-DISKC", owner= "grid", group= "Asmadmin", mode= "0660"
kernel== "sd*", bus== "scsi", program== "//sbin/scsi_id--whitelisted--replace-whitespace--device=/dev/$name", RESULT = = "1ata_vbox_harddisk_vb91e00a0b-5bc96a2b", name= "ASM-DISKD", owner= "grid", group= "Asmadmin", mode= "0660"
kernel== "sd*", bus== "scsi", program== "/sbin/scsi_id--whitelisted--replace-whitespace--device=/dev/$name", RESULT= = "1ata_vbox_harddisk_vbe9eca0fb-a99c152d", name= "Asm-diske", owner= "grid", group= "Asmadmin", mode= "0660"
kernel== "sd*", bus== "scsi", program== "/sbin/scsi_id--whitelisted--replace-whitespace--device=/dev/$name", RESULT= = "1ata_vbox_harddisk_vb414d8bfa-0256c987", name= "ASM-DISKF", owner= "grid", group= "Asmadmin", mode= "0660"

Restart Udev:

[Email protected] ~]#/sbin/start_udev

To view the shared storage after binding:

[Email protected] ~]# ls-ltr/dev/asm*
BRW-RW----. 1 Grid asmadmin 8, 32 August 15:27/DEV/ASM-DISKC
BRW-RW----. 1 Grid asmadmin 8, 16 August 15:27/DEV/ASM-DISKB
BRW-RW----. 1 grid asmadmin 8, 48 August 15:27/DEV/ASM-DISKD

4. Bind the shared storage script:
The above is the process of binding shared storage, the purpose is to understand how to do, if the configuration is not looked at the shared storage, please carefully check the configuration, any configuration error will cause Udev startup failure; The following script is an automatic configuration of shared storage.
When used, modify according to the actual situation:

For i in B c d E F g;
Do
echo "kernel==\" sd*\ ", bus==\" scsi\ ", program==\"/sbin/scsi_id--whitelisted--replace-whitespace--device=/dev/\$ Name\ ", result==\" '/sbin/scsi_id--whitelisted--replace-whitespace--device=/dev/sd$i ' \ ", NAME=\" asm-disk$i\ ", Owner=\ "grid\", group=\ "asmadmin\", mode=\ "0660\" ">>/etc/udev/rules.d/99-oracle-asmdevices.rules
Done

For example: When only/DEV/SDC,/DEV/SDD, the script for Iin b c D E F g is modified to for I in C D;
Finally restart Udev:

[Email protected] ~]#/sbin/start_udev

Using Udev to bind shared storage on Linux 6

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.