Disclosure of Invention
The application provides a method, a device, equipment and a readable storage medium for detecting a hard disk slot number, which can solve the problem that the automatic detection of the hard disk slot number in different configuration scenes cannot be realized in the prior art.
In a first aspect, an embodiment of the present application provides a method for detecting a hard disk slot number, where the method for detecting a hard disk slot number includes:
acquiring hard disk on-site information and initial lighting state information of the on-site hard disk on a hard disk backboard;
updating the lighting state corresponding to the RAID card hard disk to obtain target lighting state information, and determining the slot number of each RAID card hard disk based on the initial lighting state information, the target lighting state information and the hard disk in-place information to form first slot information;
determining a slot number of the NVME hard disk based on the I2C scanning mode to form second slot information;
determining residual slot position information based on the hard disk bit information, the first slot position information and the second slot position information;
and acquiring serial port hard disk interface information corresponding to the on-board hard disk, and determining a slot number corresponding to the on-board hard disk based on the residual slot information and the serial port hard disk interface information.
With reference to the first aspect, in an implementation manner, the updating the lighting state corresponding to the RAID card hard disk to obtain the target lighting state information includes:
and updating the lighting state of a certain target RAID card hard disk to be opened and keeping the lighting states of other underhung hard disks on the RAID card and other on-site hard disks on the hard board backboard to be initial lighting states so as to obtain target lighting state information corresponding to the hard disk backboard.
With reference to the first aspect, in an implementation manner, the determining, based on the initial lighting state information, the target lighting state information, and the hard disk in-place information, a slot number of each RAID card hard disk includes:
determining target hard disks with different lighting states based on the initial lighting state information and the target lighting state information aiming at the target RAID card hard disk;
and determining a target slot number of the target hard disk based on the hard disk in-place information, and taking the target slot number as the slot number of the target RAID card hard disk.
With reference to the first aspect, in an implementation manner, the determining, based on the remaining slot information and serial hard disk interface information, a slot number corresponding to the on-board hard disk includes:
based on the serial hard disk interface information, sequencing serial hard disk interface numbers corresponding to all the on-board hard disks according to the sequence from small to large to obtain sequenced serial hard disk interface numbers;
sequencing the residual slot numbers according to the sequence from small to large based on the residual slot information to obtain sequenced residual slot numbers;
and constructing a mapping relation between the serial port interface numbers after sequencing and the residual slot numbers after sequencing according to the sequencing order to determine the slot numbers of each on-board hard disk.
In a second aspect, an embodiment of the present application provides a hard disk slot number detection device, where the hard disk slot number detection device includes:
the information acquisition module is used for acquiring the hard disk on-site information and the initial lighting state information of the on-site hard disk on the hard disk backboard;
the first detection module is used for updating the lighting state corresponding to the RAID card hard disk to obtain target lighting state information, and determining the slot number of each RAID card hard disk based on the initial lighting state information, the target lighting state information and the hard disk in-place information to form first slot information;
the second detection module is used for determining the slot number of the NVME hard disk based on the I2C scanning mode so as to form second slot information;
the third detection module is used for determining residual slot position information based on the hard disk bit information, the first slot position information and the second slot position information; and acquiring serial port hard disk interface information corresponding to the on-board hard disk, and determining a slot number corresponding to the on-board hard disk based on the residual slot information and the serial port hard disk interface information.
With reference to the second aspect, in one embodiment, the initial lighting state of the in-place hard disk is off, and the first detection module is specifically configured to:
and updating the lighting state of a certain target RAID card hard disk to be opened and keeping the lighting states of other underhung hard disks on the RAID card and other on-site hard disks on the hard board backboard to be initial lighting states so as to obtain target lighting state information corresponding to the hard disk backboard.
With reference to the second aspect, in one embodiment, the first detection module is specifically further configured to:
determining target hard disks with different lighting states based on the initial lighting state information and the target lighting state information aiming at the target RAID card hard disk;
and determining a target slot number of the target hard disk based on the hard disk in-place information, and taking the target slot number as the slot number of the target RAID card hard disk.
With reference to the second aspect, in one embodiment, the third detection module is specifically configured to:
based on the serial hard disk interface information, sequencing serial hard disk interface numbers corresponding to all the on-board hard disks according to the sequence from small to large to obtain sequenced serial hard disk interface numbers;
sequencing the residual slot numbers according to the sequence from small to large based on the residual slot information to obtain sequenced residual slot numbers;
and constructing a mapping relation between the serial port interface numbers after sequencing and the residual slot numbers after sequencing according to the sequencing order to determine the slot numbers of each on-board hard disk.
In a third aspect, an embodiment of the present application provides a hard disk slot number detection apparatus, where the hard disk slot number detection apparatus includes a processor, a memory, and a hard disk slot number detection program stored on the memory and executable by the processor, where the hard disk slot number detection program, when executed by the processor, implements steps of a hard disk slot number detection method as described above.
In a fourth aspect, embodiments of the present application provide a computer readable storage medium having a hard disk slot number detection program stored thereon, where the hard disk slot number detection program, when executed by a processor, implements the steps of the hard disk slot number detection method as described above.
The beneficial effects that technical scheme that this application embodiment provided include at least:
for any application scene, the first slot information is formed by acquiring the hard disk on-site information and the initial lighting state information of the on-site hard disk on the hard disk backboard, updating the lighting state corresponding to the RAID card hard disk, and determining the slot number of each RAID card hard disk based on the change of the lighting state and the on-site hard disk information; determining a slot number of the NVME hard disk based on an I2C scanning mode to form second slot information; determining residual slot position information based on the hard disk bit information, the first slot position information and the second slot position information; and finally, determining the slot number of the on-board hard disk based on the residual slot information and serial port hard disk interface information corresponding to the on-board hard disk, so that automatic detection of the slot numbers of the RAID card hard disk, the on-board hard disk and the NVME hard disk is realized, constraint restriction on a hard disk wiring mode is not needed, the detection efficiency is effectively improved, and the detection difficulty is reduced.
Detailed Description
In order to make the present application solution better understood by those skilled in the art, the following description will clearly and completely describe the technical solution in the embodiments of the present application with reference to the accompanying drawings in the embodiments of the present application, and it is apparent that the described embodiments are only some embodiments of the present application, not all embodiments. All other embodiments, which can be made by one of ordinary skill in the art based on the embodiments herein without making any inventive effort, are intended to be within the scope of the present application.
The terms "comprising" and "having" and any variations thereof in the description and claims of the present application and in the foregoing drawings are intended to cover non-exclusive inclusions. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those listed steps or elements but may include other steps or elements not listed or inherent to such process, method, article, or apparatus. The terms "first," "second," and "third," etc. are used for distinguishing between different objects and not necessarily for describing a sequential or chronological order, and are not limited to the fact that "first," "second," and "third" are not identical.
In the description of embodiments of the present application, "exemplary," "such as," or "for example," etc., are used to indicate an example, instance, or illustration. Any embodiment or design described herein as "exemplary," "such as" or "for example" is not necessarily to be construed as preferred or advantageous over other embodiments or designs. Rather, the use of words such as "exemplary," "such as" or "for example," etc., is intended to present related concepts in a concrete fashion.
In the description of the embodiments of the present application, unless otherwise indicated, "/" means or, for example, a/B may represent a or B; the text "and/or" is merely an association relation describing the associated object, and indicates that three relations may exist, for example, a and/or B may indicate: the three cases where a exists alone, a and B exist together, and B exists alone, and in addition, in the description of the embodiments of the present application, "plural" means two or more than two.
In some of the processes described in the embodiments of the present application, a plurality of operations or steps occurring in a particular order are included, but it should be understood that these operations or steps may be performed out of the order in which they occur in the embodiments of the present application or in parallel, the sequence numbers of the operations merely serve to distinguish between the various operations, and the sequence numbers themselves do not represent any order of execution. In addition, the processes may include more or fewer operations, and the operations or steps may be performed in sequence or in parallel, and the operations or steps may be combined.
For the purpose of making the objects, technical solutions and advantages of the present application more apparent, the embodiments of the present application will be described in further detail below with reference to the accompanying drawings.
In a first aspect, an embodiment of the present application provides a method for detecting a hard disk slot number.
In an embodiment, referring to fig. 1, fig. 1 is a flow chart of an embodiment of a method for detecting a hard disk slot number according to the present application. As shown in fig. 1, the method for detecting the slot number of the hard disk comprises the following steps:
step S10: and acquiring the hard disk on-site information and the initial lighting state information of the on-site hard disk on the hard disk backboard.
For example, it can be understood that, for a motherboard, many different types of hard disks such as a RAID card hard disk, an on-board hard disk, and an NVME hard disk are often plugged into the hard disk backplane, and different application scenarios will make the connection modes of the RAID card hard disk, the on-board hard disk, and the NVME hard disk and the physical hard disk backplane different, so that it is difficult to identify and obtain slot numbers corresponding to the RAID card hard disk, the on-board hard disk, and the NVME hard disk on the hard disk backplane. In this embodiment, for any configuration scenario, when the server is powered on for the first time, the CPLD (Complex Programmable Logic Device ) of the hard disk backplane detects the hard disk in-place status of each card slot to obtain current hard disk in-place information on the hard disk backplane, where the hard disk in-place information includes whether each card slot is plugged with a hard disk and a slot number corresponding to each card slot.
In addition, in this embodiment, the slot number of the RAID card hard disk is identified by the change of the lighting state, so that the lighting initialization operation needs to be performed on the lighting states corresponding to all the in-place hard disks (i.e. the hard disks inserted into the slots) to obtain the initial lighting state information a of the in-place hard disk, where the initial lighting state information includes whether each positioning lamp corresponding to the in-place hard disk is in an on state or an off state. It should be noted that, the lighting initialization operation may be to turn off all the positioning lamps of the hard disk in place, or turn on all the positioning lamps of the hard disk in place, if the lighting initialization operation is the turn-off operation, then when the subsequent slot number is identified, the positioning lamps of the hard disk to be identified need to be turned on to identify the slot number through the change of the lighting state; similarly, if the operation is an opening operation, the positioning lamp of the hard disk to be identified needs to be turned off when the subsequent slot number is identified.
Step S20: updating the lighting state corresponding to the RAID card hard disk to obtain target lighting state information, and determining the slot number of each RAID card hard disk based on the initial lighting state information, the target lighting state information and the hard disk bit information to form first slot information.
In this embodiment, the lower hanging hard disk (i.e. the RAID card hard disk) on the RAID card is polled one by one through a mode (such as I2C (Inter-Integrated Circuit, two-wire serial bus) or PCIE (Peripheral Component Interconnect Express, high-speed serial computer expansion bus standard) out of band of the BMC (Baseboard Management Controller ), and the lighting state corresponding to the RAID card hard disk is configured and updated, and then the current target lighting state information B of the hard disk backboard is obtained through CPLD detection of the hard disk backboard; and then, by comparing the difference between the initial lighting state information A and the target lighting state information B, the slot numbers of the RAID card hard disks with updated lighting states can be calculated, and the slot numbers of all RAID card hard disks are calculated by the method, so that first slot information corresponding to the RAID cards is obtained, namely the first slot information comprises the slot numbers corresponding to the slots of all the bit RAID card hard disks, and the slot number detection of the RAID card hard disks is completed.
Step S30: and determining the slot number of the NVME hard disk based on the I2C scanning mode so as to form second slot information.
In this embodiment, the wiring manner of the NVME hard disk is relatively fixed, so that the slot number of each in-place NVME hard disk can be obtained through the I2C scanning manner, and further second slot information corresponding to the NVME is formed, that is, the second slot information includes slot numbers corresponding to all the clamping slots where the in-place NVME hard disk is located, so that the slot number detection of the NVME hard disk is completed.
Step S40: and determining the residual slot position information based on the hard disk bit information, the first slot position information and the second slot position information.
In this embodiment, the hard disk in-place information includes slot numbers corresponding to all slots where the in-place hard disk is located, the first slot information includes slot numbers corresponding to all slots where the in-place RAID card is located, and the second slot information includes slot numbers corresponding to all slots where the in-place NVME hard disk is located, so that remaining slot information can be calculated through the hard disk in-place information, the first slot information and the second slot information, that is, the remaining slot information includes slot numbers of the in-place hard disk in which the slot number is not identified and the corresponding slot thereof.
For example, assuming that the hard disk in-place information includes slot numbers corresponding to the card slots where the 10 in-place hard disks are located, and the slot numbers of the 10 slots are respectively X1 to X10, the first slot information includes slot numbers corresponding to the card slots where the 3 in-place RAID card hard disks are located, and the 3 slot numbers are respectively X2, X4, and X6, the second slot information includes slot numbers corresponding to the card slots where the 4 in-place NVME hard disks are located, and the 4 slot numbers are respectively X1, X5, X7, and X10, it can be determined that the slot numbers corresponding to the card slots where the 3 in-place hard disks are still left are not identified, and the remaining slot information includes the 3 slot numbers.
Step S50: and acquiring serial port hard disk interface information corresponding to the on-board hard disk, and determining a slot number corresponding to the on-board hard disk based on the residual slot information and the serial port hard disk interface information.
It is to be understood that, for example, the hard disk back plate generally includes three types of hard disks, i.e., a RAID card hard disk, an onboard hard disk, and an NVME hard disk, so that after the slot numbers of the RAID card hard disk and the NVME hard disk are detected, the remaining unrecognized slot number is the slot number corresponding to the onboard hard disk. In this embodiment, then, the asset information reported by the BIOS (Basic Input Output System ) in the POST stage (i.e., the power-on self-test stage) is obtained to obtain all the on-board hard disk information and serial hard disk interface information corresponding to the on-board hard disk, i.e., the serial hard disk interface information includes a SATAPORT corresponding to each on-board hard disk; and then, the corresponding relation between the serial hard disk interface corresponding to each on-board hard disk in the serial hard disk interface information and the residual slot number in the residual slot information can be used for automatically detecting and identifying the slot number of each on-board hard disk.
It can be understood that during the power-on process of the server, whether there is a hot plug event of the hard disk is continuously detected, and if a new hard disk is detected, the actual physical slot number of the newly inserted hard disk needs to be calculated by the same method as the above.
Therefore, the embodiment can realize the automatic detection of the slot numbers of the RAID card hard disk, the onboard hard disk and the NVME hard disk in any application scene, does not need to restrict the hard disk wiring modes in different application scenes, can realize various flexible configuration schemes, reduces the software adaptation work of BMC software to different server application scenes, reduces the possibility of errors caused by configuration parameter transmission and manual intervention, effectively improves the detection efficiency and reduces the detection difficulty.
Further, in an embodiment, the initial lighting state of the in-place hard disk is off, and the updating the lighting state corresponding to the RAID card hard disk to obtain the target lighting state information includes:
and updating the lighting state of a certain target RAID card hard disk to be opened and keeping the lighting states of other underhung hard disks on the RAID card and other on-site hard disks on the hard board backboard to be initial lighting states so as to obtain target lighting state information corresponding to the hard disk backboard.
For example, in this embodiment, since the lighting control methods and principles of all RAID card hard disks are the same, for simplicity of description, the lighting control process of a RAID card hard disk will be described by taking a certain target RAID card hard disk as an example: if the initial lighting states of the in-place hard disks are all closed, the lighting states of the positioning lamps corresponding to the target RAID card hard disks are updated to be opened, and the lighting states corresponding to other RAID card hard disks and other hard disks on the hard disk backboard are still kept in the closed state, so that the lighting state information on the hard disk backboard is changed, namely, the original lighting states of all in-place hard disks are changed into the in-place hard disks with the lighting states being opened on the hard disk backboard, so that new target lighting state information is formed.
Further, in an embodiment, referring to fig. 2, the determining the slot number of each RAID card hard disk based on the initial lighting state information, the target lighting state information, and the hard disk in-place information includes:
step S201: determining target hard disks with different lighting states based on the initial lighting state information and the target lighting state information aiming at the target RAID card hard disk;
step S202: and determining a target slot number of the target hard disk based on the hard disk in-place information, and taking the target slot number as the slot number of the target RAID card hard disk.
For the sake of simplicity of description, the slot number detection process of a RAID card hard disk will be described by taking a certain target RAID card hard disk as an example, because the slot number detection methods and principles of all RAID card hard disks are the same in this embodiment: and obtaining target lighting state information of the hard disk backboard, comparing the target lighting state information with the initial lighting state information to determine target hard disks with different lighting states, and obtaining the slot number of the target hard disk through the hard disk in-place information, wherein the slot number is the slot number of the target RAID card hard disk.
Further, in an embodiment, referring to fig. 3, the determining, based on the remaining slot information and the serial hard disk interface information, a slot number corresponding to the on-board hard disk includes:
step S501: based on the serial hard disk interface information, sequencing serial hard disk interface numbers corresponding to all the on-board hard disks according to the sequence from small to large to obtain sequenced serial hard disk interface numbers;
step S502: sequencing the residual slot numbers according to the sequence from small to large based on the residual slot information to obtain sequenced residual slot numbers;
step S503: and constructing a mapping relation between the serial port interface numbers after sequencing and the residual slot numbers after sequencing according to the sequencing order to determine the slot numbers of each on-board hard disk.
It is to be understood that, for example, when performing the plugging process of the hard disk, the hard disk is often inserted onto the hard disk back plate in order from small to large. Therefore, in this embodiment, the obtained serial hard disk interface information is used to sequence the sateports corresponding to all the on-board hard disks in order from small to large, so as to obtain the sequenced sateports; meanwhile, sequencing the residual slot numbers according to the residual slot information from small to large so as to obtain sequenced residual slot numbers; and then mapping the ordered SATA PORT and the ordered residual slot number, and calculating the slot number corresponding to the on-board hard disk.
For example, assuming that there are the on-board hard disk 1, the on-board hard disk 2, and the on-board hard disk 3, and the SATAPORT corresponding to the on-board hard disk 1 is Y5, the SATAPORT corresponding to the on-board hard disk 2 is Y3, and the SATAPORT corresponding to the on-board hard disk 3 is Y8, the order obtained after sorting the SATAPORT in order from small to large is Y3, Y5, Y8; similarly, assuming that the remaining slot numbers include X3, X8 and X9, after the remaining slot numbers are ordered, the obtained order is X3, X8 and X9; at this time, when the SATAPORT and the remaining slot number are mapped in order from small to large, X3 corresponds to Y3, X8 corresponds to Y5, and X9 corresponds to Y8. From this, the slot number of the on-board hard disk 1 is X8, the slot number of the on-board hard disk 2 is Y3, and the slot number of the on-board hard disk 3 is X9.
In a second aspect, an embodiment of the present application further provides a device for detecting a slot number of a hard disk.
In an embodiment, referring to fig. 4, fig. 4 is a schematic functional block diagram of an embodiment of a hard disk slot number detection device according to the present application. As shown in fig. 4, the hard disk slot number detection device includes:
the information acquisition module is used for acquiring the hard disk on-site information and the initial lighting state information of the on-site hard disk on the hard disk backboard;
the first detection module is used for updating the lighting state corresponding to the RAID card hard disk to obtain target lighting state information, and determining the slot number of each RAID card hard disk based on the initial lighting state information, the target lighting state information and the hard disk in-place information to form first slot information;
the second detection module is used for determining the slot number of the NVME hard disk based on the I2C scanning mode so as to form second slot information;
the third detection module is used for determining residual slot position information based on the hard disk bit information, the first slot position information and the second slot position information; and acquiring serial port hard disk interface information corresponding to the on-board hard disk, and determining a slot number corresponding to the on-board hard disk based on the residual slot information and the serial port hard disk interface information.
Further, in an embodiment, the initial lighting state of the in-place hard disk is off, and the first detection module is specifically configured to:
and updating the lighting state of a certain target RAID card hard disk to be opened and keeping the lighting states of other underhung hard disks on the RAID card and other on-site hard disks on the hard board backboard to be initial lighting states so as to obtain target lighting state information corresponding to the hard disk backboard.
Further, in an embodiment, the first detection module is specifically further configured to:
determining target hard disks with different lighting states based on the initial lighting state information and the target lighting state information aiming at the target RAID card hard disk;
and determining a target slot number of the target hard disk based on the hard disk in-place information, and taking the target slot number as the slot number of the target RAID card hard disk.
Further, in an embodiment, the third detection module is specifically configured to:
based on the serial hard disk interface information, sequencing serial hard disk interface numbers corresponding to all the on-board hard disks according to the sequence from small to large to obtain sequenced serial hard disk interface numbers;
sequencing the residual slot numbers according to the sequence from small to large based on the residual slot information to obtain sequenced residual slot numbers;
and constructing a mapping relation between the serial port interface numbers after sequencing and the residual slot numbers after sequencing according to the sequencing order to determine the slot numbers of each on-board hard disk.
The function implementation of each module in the hard disk slot number detection device corresponds to each step in the embodiment of the hard disk slot number detection method, and the function and implementation process of each module are not described in detail herein.
In a third aspect, embodiments of the present application provide a hard disk slot number detection device, which may be a device with a data processing function, such as a personal computer (personal computer, PC), a notebook computer, a server, or the like.
Referring to fig. 5, fig. 5 is a schematic hardware structure of a hard disk slot number detection device according to an embodiment of the present application. In an embodiment of the present application, a hard disk slot number detection device may include a processor, a memory, a communication interface, and a communication bus.
The communication bus may be of any type for implementing the processor, memory, and communication interface interconnections.
The communication interfaces include input/output (I/O) interfaces, physical interfaces, logical interfaces, and the like for implementing interconnection of devices inside the hard disk slot number detection apparatus, and interfaces for implementing interconnection of the hard disk slot number detection apparatus with other apparatuses (e.g., other computing apparatuses or user apparatuses). The physical interface may be an ethernet interface, a fiber optic interface, an ATM interface, etc.; the user device may be a Display, a Keyboard (Keyboard), or the like.
The memory may be various types of storage media such as random access memory (randomaccess memory, RAM), read-only memory (ROM), nonvolatile RAM (non-volatileRAM, NVRAM), flash memory, optical memory, hard disk, programmable ROM (PROM), erasable PROM (EPROM), electrically erasable PROM (electrically erasable PROM, EEPROM), and the like.
The processor may be a general-purpose processor, and the general-purpose processor may call a hard disk slot number detection program stored in the memory, and execute the hard disk slot number detection method provided in the embodiment of the present application. For example, the general purpose processor may be a central processing unit (central processing unit, CPU). The method executed when the hard disk slot number detection program is called may refer to various embodiments of the hard disk slot number detection method of the present application, and will not be described herein.
Those skilled in the art will appreciate that the hardware configuration shown in fig. 5 is not limiting of the application and may include more or fewer components than shown, or may combine certain components, or a different arrangement of components.
In a fourth aspect, embodiments of the present application also provide a computer-readable storage medium.
The readable storage medium of the application stores a hard disk slot number detection program, wherein when the hard disk slot number detection program is executed by a processor, the steps of the hard disk slot number detection method are realized.
The method implemented when the hard disk slot number detection program is executed may refer to various embodiments of the hard disk slot number detection method of the present application, which are not described herein again.
It should be noted that, the foregoing embodiment numbers are merely for describing the embodiments, and do not represent the advantages and disadvantages of the embodiments.
From the above description of the embodiments, it will be clear to those skilled in the art that the above-described embodiment method may be implemented by means of software plus a necessary general hardware platform, but of course may also be implemented by means of hardware, but in many cases the former is a preferred embodiment. Based on such understanding, the technical solution of the present application may be embodied essentially or in a part contributing to the prior art in the form of a software product stored in a storage medium (e.g. ROM/RAM, magnetic disk, optical disk) as described above, comprising several instructions for causing a terminal device to perform the method described in the various embodiments of the present application.
The foregoing description is only of the preferred embodiments of the present application, and is not intended to limit the scope of the claims, and all equivalent structures or equivalent processes using the descriptions and drawings of the present application, or direct or indirect application in other related technical fields are included in the scope of the claims of the present application.