Linux Drive-Letter binding slots

Source: Internet
Author: User

The hard drive under the server has a mechanical hard disk, a solid state drive, and a RAID array, and the kernel assigns the drive letter in the order of/DEV/SDA,/dev/sdb .... During system startup, the kernel assigns the drive letter in the order in which it is scanned to the hard disk (the pass-through, then the array is allocated first). In the same hard disk slot, hot-swappable hard disk, the system will follow the existing drive letter assignment, such as the previous allocation is/DEV/SDB, the last hard drive of the system is/DEV/SDF, then the/dev/sdb/hot plug, the system will reassign the disk letter of the drive is/DEV/SDG, A situation in which the drive letter is garbled.

Assuming that there are 14 hard disk slots on the machine, slot numbers are 0~13, and in the Centos7.3 environment, the R730XD server allocates slots as follows:

0 3 6
1 4 7
2 5 8

/dev/sda /dev/sdd /dev/sdg
/dev/sdb /dev/sde /dev/sdh
/dev/sdc /dev/sdf /dev/sdi

In this case, we should be able to solve the problem of disk character dislocation in the following ways:

[Email protected] ~]# udevadm info-q path-n/DEV/SDA

/devices/pci0000:00/0000:00:10.0/host0/target0:0:0/0:0:0:0/block/sda

Get the number, in the/etc/udev/rules.d/80-mydisk.rules, increase

devpath== "/devices/pci0000:00/0000:00:10.0/host0/target0:0:0/0:0:0:0/block/sda", NAME= "SDA", MODE= "0660"

So the second of the corresponding slots will always correspond to the drive letter SDC without the problem of the jump drive, and we can use a small script to implement all the drive and slot bits:

#!/bin/bash
Disk= "A b c D e F g h i j k l I j k M N"
For i in ${disk};
Do
A= '/usr/sbin/udevadm info-q path-n/dev/sd${i} ';
if [!-n "$a"]; Then
Break 1;
Else
echo devpath== "\" ${a} "\", name= "\" Sd${i} "\", mode= "\" 0660 "\" >>/etc/udev/rules.d/80-mydisk.rules;
Fi
Done

Linux Drive-Letter binding slots

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.