Method, device, equipment and medium for automatically distinguishing front and rear hard disks under OS
By utilizing the expander chip and CPLD-defined disk sequence in the operating system to detect changes in the hard drive position light level and compare the I2C address, the problem of not being able to automatically distinguish between front and rear hard drives in server production line testing is solved, thus improving testing efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-30
- Publication Date
- 2026-03-03
AI Technical Summary
During server production line testing, the machines are already assembled and cannot be disassembled for inspection, which makes it impossible to automatically distinguish between front and rear hard drives, affecting testing efficiency.
By querying the disk order defined by the expander chip and CPLD on the hard drive backplane in the operating system, detecting changes in the level of the position lights, and comparing the I2C addresses, the system can automatically distinguish between the front and rear hard drives.
It enables automatic differentiation between front and rear hard drives under the operating system, improving production line inspection efficiency.
Smart Images

Figure CN115437863B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of hard disk cable testing technology, specifically to a method, apparatus, device, and medium for automatically distinguishing between front and rear hard disks under an OS. Background Technology
[0002] In general-purpose server systems, there is usually a large demand for SATA SSDs, and general-purpose servers typically have front-mounted and rear-mounted hard drives. The functions of the front and rear hard drives may differ depending on the application scenario, and the installation and inspection strategies for the front and rear hard drives may also differ during server assembly and re-inspection on the production line. Therefore, it is necessary to distinguish between the front and rear hard drives.
[0003] However, during the server production line testing process, the machine has already been assembled and cannot be disassembled for inspection. Therefore, it is necessary to automatically detect and distinguish the front and rear hard drives in the operating system to improve the efficiency of production line testing. Summary of the Invention
[0004] To address the issue that during server production line testing, the machines are already assembled and cannot be disassembled for inspection, thus requiring automatic detection and differentiation of front and rear hard drives within the operating system to improve production line testing efficiency, this invention provides a method, apparatus, device, and medium for automatically differentiating front and rear hard drives under an OS.
[0005] In a first aspect, the present invention provides a method for automatically distinguishing between front and rear hard drives under an operating system, comprising the following steps:
[0006] Select the corresponding slot number according to the defined disk order and the number of hard drives in place on the front and rear backplanes to initially determine the front and rear hard drives;
[0007] According to the initially determined sequence number of the front and rear hard drives, the position lights of the corresponding hard drives are lit up in turn according to the slot number;
[0008] Detect changes in the level of the position light and query the I2C address corresponding to the lit position light;
[0009] The system compares the queried I2C address with the preset actual I2C addresses of the front and rear backplanes, and finally determines the front hard drive and the rear hard drive based on the comparison results.
[0010] Further, before selecting the corresponding slot number according to the defined disk order and the number of hard drives in place on the front and rear backplanes, the steps of initially determining the front and rear hard drives include:
[0011] Check the number of hard drives in place on the front and rear backplanes;
[0012] Check the disk order defined by the expander chip and CPLD on the front and rear backplanes to determine the cascading order of the front and rear hard drives;
[0013] The operating system checks the slot numbers identified under the RAID card and generates a slot number table.
[0014] Furthermore, the steps to initially determine the front and rear hard drives include selecting the corresponding slot numbers according to the defined disk order and the number of hard drives in place on the front and rear backplanes:
[0015] Match the slot number table according to the disk order defined by the CPLD and the number of hard drives in place on the front and rear backplanes, select the corresponding slot numbers, and initially determine them as front hard drives and rear hard drives respectively.
[0016] Furthermore, the steps of detecting the level change of the position light and querying the I2C address corresponding to the lit position light include:
[0017] Detect changes in the level of the position indicator light;
[0018] Obtain the unique correspondence table between each slot number, position LED number, and I2C address on the hard drive backplane;
[0019] The I2C address corresponding to the detected position light is queried in the light number correspondence table, and the first I2C address table is generated.
[0020] Furthermore, before the step of comparing the queried I2C address with the preset actual I2C addresses of the front and rear backplanes, the following steps are included:
[0021] Query the second I2C address table generated from the predefined real I2C addresses of the front and rear hard drives.
[0022] Further steps, including comparing the queried I2C addresses with the preset actual I2C addresses of the front and rear backplanes, and finally determining the front and rear hard drives based on the comparison results, include:
[0023] Compare the first I2C address table and the second I2C address table;
[0024] If the I2C addresses of the front and rear hard drives are consistent in both tables, then the check is correct, and the front and rear hard drives are finally determined.
[0025] Secondly, the present invention provides a device for automatically distinguishing front and rear hard disks under an OS, including an initial selection and determination module, a position light illumination module, a detection and query module, and a comparison and confirmation module;
[0026] The initial selection and determination module is used to select the corresponding slot number according to the defined disk order and the number of hard drives in place on the front and rear backplanes, and to initially determine the front and rear hard drives;
[0027] The position light module is used to illuminate the position lights of the corresponding hard drives according to the initially determined sequence numbers of the front and rear hard drives and the slot numbers.
[0028] The detection and query module is used to detect changes in the level of the position light and query the I2C address corresponding to the lit position light;
[0029] The comparison and confirmation module is used to compare the queried I2C address with the preset actual I2C address of the front and rear backplanes, and finally determine the front hard drive and the rear hard drive based on the comparison result.
[0030] Furthermore, the device also includes a hard disk quantity query module, a sequence relationship determination module, and a slot number check module;
[0031] The hard drive quantity query module is used to view the number of hard drives in place on the front and rear backplanes;
[0032] The sequence relationship determination module is used to check the disk order defined by the expander chip and CPLD on the front and rear backplanes to determine the cascading sequence relationship of the front and rear hard drives;
[0033] The slot number checking module is used to check the slot numbers identified under the RAID card in the operating system and generate a slot number table.
[0034] Furthermore, the steps to initially determine the front and rear hard drives include selecting the corresponding slot numbers according to the defined disk order and the number of hard drives in place on the front and rear backplanes:
[0035] The initial selection and determination module is specifically used to match the slot number table according to the disk order defined by the CPLD and the number of hard drives in place on the front and rear backplanes, and select the corresponding slot numbers to initially determine them as front hard drives and rear hard drives, respectively.
[0036] Furthermore, the detection and query module includes a level detection unit, an equal sign correspondence table acquisition unit, and an address query unit;
[0037] The level detection unit is used to detect changes in the level of the position light;
[0038] The equal sign correspondence table acquisition unit is used to acquire the unique correspondence table between each slot number on the hard disk backplane and the position light number and I2C address;
[0039] The address lookup unit is used to look up the I2C address corresponding to the detected position light in the light number correspondence table and generate the first I2C address table.
[0040] Furthermore, the device also includes a preset address lookup module for querying a second I2C address table generated from the predefined real I2C addresses of the front and rear hard drives.
[0041] Furthermore, the comparison and confirmation module includes a comparison unit and a confirmation unit;
[0042] The comparison unit is used to compare the first I2C address table and the second I2C address table;
[0043] The confirmation unit is used to verify that if the I2C addresses of the front and rear hard drives are consistent in both tables, then the verification is correct and the front and rear hard drives are finally determined.
[0044] Thirdly, the present invention also provides an electronic device, the electronic device comprising:
[0045] At least one processor; and,
[0046] A memory communicatively connected to the at least one processor; wherein,
[0047] The memory stores computer program instructions that can be executed by at least one processor to enable the at least one processor to perform the method for automatically distinguishing between front and rear hard disks under an OS as described in the first aspect.
[0048] Fourthly, the present invention also provides a non-transitory computer-readable storage medium that stores computer instructions that cause the computer to execute the method for automatically distinguishing between front and rear hard disks under an OS as described in the first aspect.
[0049] As can be seen from the above technical solution, the present invention has the following advantages: by querying the expander chip on the hard drive backplane, the disk order defined by the CPLD, and the number of hard drives in place on the front and rear backplanes, the slot number of the hard drive in the operating system is determined. The position light of the hard drive is lit by the slot number. The CPLD on the hard drive backplane detects the level change of the position light and queries the I2C address corresponding to the position light. The queried I2C address is matched with the I2C address set on the front and rear backplanes, thereby realizing automatic detection and differentiation of the front and rear hard drives in the operating system, improving the detection efficiency of the production line.
[0050] Furthermore, the design principle of this invention is reliable, the structure is simple, and it has a very wide range of application prospects.
[0051] Therefore, it is evident that the present invention has outstanding substantive features and significant progress compared with the prior art, and the beneficial effects of its implementation are also obvious. Attached Figure Description
[0052] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0053] Figure 1 This is a schematic flowchart of a method according to an embodiment of the present invention.
[0054] Figure 2 This is a schematic flowchart of a method according to another embodiment of the present invention.
[0055] Figure 3 This is a schematic block diagram of an apparatus according to an embodiment of the present invention. Detailed Implementation
[0056] In general-purpose server systems, there is usually a large demand for SATA SSDs, and general-purpose servers typically have front-mounted and rear-mounted hard drives. The functions of the front and rear hard drives may differ depending on the application scenario, and the installation and inspection strategies for the front and rear hard drives may also differ during server assembly and re-inspection on the production line. Therefore, it is necessary to distinguish between the front and rear hard drives.
[0057] However, during the server production line testing process, the machine has already been assembled and cannot be disassembled for inspection. Therefore, it is necessary to automatically detect and distinguish the front and rear hard drives in the operating system to improve the efficiency of production line testing.
[0058] To enable those skilled in the art to better understand the technical solutions of this invention, the technical solutions of the embodiments of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this invention, and not all embodiments. Based on the embodiments of this invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of this invention.
[0059] like Figure 1 As shown, this embodiment of the invention provides a method for automatically distinguishing between front and rear hard drives under an OS, including the following steps:
[0060] Step 1: Select the corresponding slot number according to the defined disk order and the number of hard drives in place on the front and rear backplanes to initially determine the front and rear hard drives;
[0061] Step 2: According to the initially determined sequence number of the front and rear hard drives, turn on the position lights of the corresponding hard drives according to their slot numbers;
[0062] Step 3: Detect the level change of the position light and query the I2C address corresponding to the lit position light;
[0063] Step 4: Compare the queried I2C address with the preset actual I2C address of the front and rear backplanes, and finally determine the front hard drive and the rear hard drive based on the comparison results.
[0064] like Figure 2 As shown, this embodiment of the invention provides a method for automatically distinguishing between front and rear hard drives under an OS, including the following steps:
[0065] S1: Check the number of hard drives in place on the front and rear backplanes;
[0066] S2: Check the disk order defined by the expander chip and CPLD on the front and rear backplanes to determine the cascading order of the front and rear hard drives;
[0067] S3: Check the slot number identified under the RAID card in the operating system and generate a slot number table.
[0068] S4: Match the slot number table according to the disk order defined by the CPLD and the number of hard drives in place on the front and rear backplanes, select the corresponding slot numbers, and initially determine them as front hard drives and rear hard drives respectively.
[0069] S5: According to the initially determined sequence number of the front and rear hard drives, turn on the position lights of the corresponding hard drives in turn according to the slot number;
[0070] S6: Detect changes in the level of the position indicator;
[0071] S7: Obtain the unique correspondence table between each slot number, position light number, and I2C address on the hard drive backplane;
[0072] S8: Query the I2C address corresponding to the detected position light in the light number correspondence table, and generate the first I2C address table.
[0073] S9: Query the second I2C address table generated from the predefined real I2C addresses of the front and rear hard disks;
[0074] S10: Compare the first I2C address table and the second I2C address table; if the I2C addresses of the front and rear hard drives are consistent in both tables, the check is correct, and the front and rear hard drives are finally determined.
[0075] In a configuration where front and rear hard drives are cascaded under the same RAID card, the first step is to check the number of hard drives present on the front and rear backplanes in the operating system. Then, check the disk order defined by the expander chip and CPLD on the hard drive backplane to determine the cascading order of the front and rear hard drives. Next, check the slotIDs identified by the RAID card in the operating system to create a slotID table. Match the slotID table according to the disk order defined by the CPLD and the number of hard drives present on the front and rear backplanes, selecting the corresponding slotIDs to initially identify the front and rear hard drives. Then, according to the initially determined sequence numbers of the front and rear hard drives, sequentially illuminate the corresponding SATA hard drive's location LED using the slotID. The CPLD on the hard drive backplane detects changes in the location LED level. Each slot number on the hard drive backplane corresponds to a unique LED number and I2C address. Look up the corresponding I2C address in the CPLD's LED number mapping table to form I2C address table 1; then look up the actual I2C address table 2 defined at the beginning of the design for the front and rear hard drives. By comparing I2C address table 1 with the actual I2C address table 2 of the front and rear hard drives, if the I2C addresses of the different hard drives in the front and rear are consistent in both tables, the check is correct, and the front and rear hard drives can be finally identified.
[0076] like Figure 3 As shown, this embodiment of the invention provides a device for automatically distinguishing between front and rear hard drives under an OS, including an initial selection and determination module, a position light illumination module, a detection and query module, and a comparison and confirmation module;
[0077] The initial selection and determination module is used to select the corresponding slot number according to the defined disk order and the number of hard drives in place on the front and rear backplanes, and to initially determine the front and rear hard drives;
[0078] The position light module is used to illuminate the position lights of the corresponding hard drives according to the initially determined sequence numbers of the front and rear hard drives and the slot numbers.
[0079] The detection and query module is used to detect changes in the level of the position light and query the I2C address corresponding to the lit position light;
[0080] The comparison and confirmation module is used to compare the queried I2C address with the preset actual I2C address of the front and rear backplanes, and finally determine the front hard drive and the rear hard drive based on the comparison result.
[0081] The device also includes a hard disk quantity query module, a sequence relationship determination module, and a slot number check module;
[0082] The hard drive quantity query module is used to view the number of hard drives in place on the front and rear backplanes;
[0083] The sequence relationship determination module is used to check the disk order defined by the expander chip and CPLD on the front and rear backplanes to determine the cascading sequence relationship of the front and rear hard drives;
[0084] The slot number checking module is used to check the slot numbers identified under the RAID card in the operating system and generate a slot number table.
[0085] It should be further explained that the initial selection and determination module is specifically used to match the slot number table according to the disk order defined by the CPLD and the number of hard drives in place on the front and rear backplanes, and select the corresponding slot numbers to initially determine the front hard drive and the rear hard drive respectively.
[0086] The detection and query module includes a level detection unit, an equal sign correspondence table acquisition unit, and an address query unit;
[0087] The level detection unit is used to detect changes in the level of the position light;
[0088] The equal sign correspondence table acquisition unit is used to acquire the unique correspondence table between each slot number on the hard disk backplane and the position light number and I2C address;
[0089] The address lookup unit is used to look up the I2C address corresponding to the detected position light in the light number correspondence table and generate the first I2C address table.
[0090] The device also includes a preset address lookup module for querying a second I2C address table generated from predefined real I2C addresses of the front and rear hard drives. The comparison and confirmation module includes a comparison unit and a confirmation unit.
[0091] The comparison unit is used to compare the first I2C address table and the second I2C address table;
[0092] The confirmation unit is used to verify that if the I2C addresses of the front and rear hard drives are consistent in both tables, then the verification is correct and the front and rear hard drives are finally determined.
[0093] This invention also provides an electronic device, comprising: a processor, a communication interface, a memory, and a bus, wherein the processor, communication interface, and memory communicate with each other via the bus. The bus can be used for information transmission between the electronic device and sensors. The processor can call logical instructions in the memory to execute the following method: Step 1: Select the corresponding slot number according to the defined disk order and the number of hard drives in place on the front and rear backplanes to initially determine the front and rear hard drives; Step 2: Illuminate the position lights of the corresponding hard drives according to the initially determined sequence numbers of the front and rear hard drives, based on the slot numbers; Step 3: Detect the level change of the position light and query the I2C address corresponding to the illuminated position light; Step 4: Compare the queried I2C address with the preset actual I2C addresses of the front and rear backplanes, and finally determine the front and rear hard drives based on the comparison result.
[0094] In some embodiments, the processor may invoke logical instructions in memory to perform the following methods: check the number of in-situ hard disks on the front and rear backplanes; check the disk order defined by the expander chip and CPLD on the front and rear backplanes to determine the cascading order of the front and rear hard disks; check the slot numbers identified under the RAID card in the operating system and generate a slot number table.
[0095] In some embodiments, the processor may invoke logic instructions in memory to perform the following methods: detect level changes of position lights; obtain a unique light number mapping table on the hard disk backplane that corresponds to each slot number, position light number, and I2C address; query the I2C address corresponding to the detected position light in the light number mapping table to generate a first I2C address table.
[0096] Furthermore, the logical instructions in the aforementioned memory can be implemented as software functional units and sold or used as independent products, and can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0097] This invention provides a non-transitory computer-readable storage medium storing computer instructions that cause a computer to execute the method provided in the above-described method embodiments. For example, the instructions include: S1: checking the number of hard drives in place on the front and rear backplanes; S2: checking the disk order defined by the expander chip and CPLD on the front and rear backplanes to determine the cascading order of the front and rear hard drives; S3: checking the slot numbers identified under the RAID card in the operating system and generating a slot number table; S4: matching the slot number table according to the disk order defined by the CPLD and the number of hard drives in place on the front and rear backplanes, selecting the corresponding slot numbers, and initially determining them as the front and rear hard drives; S5: sequentially lighting the position lights of the corresponding hard drives according to their slot numbers, based on the initially determined sequence numbers of the front and rear hard drives.
[0098] S6: Detect the level change of the position lights; S7: Obtain the unique light correspondence table between each slot number on the hard drive backplane and the position light number and I2C address; S8: Query the I2C address corresponding to the detected position light in the light correspondence table to generate the first I2C address table; S9: Query the second I2C address table generated from the predefined real I2C addresses of the front and rear hard drives; S10: Compare the first and second I2C address tables; if the I2C addresses of the different front and rear hard drives are consistent in both tables, the check is correct, and the front and rear hard drives are finally determined.
[0099] Although the present invention has been described in detail with reference to the accompanying drawings and preferred embodiments, the invention is not limited thereto. Various equivalent modifications or substitutions can be made to the embodiments of the invention by those skilled in the art without departing from the spirit and essence of the invention, and such modifications or substitutions should all be within the scope of the invention. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the invention should also be covered within the protection scope of the invention. Therefore, the protection scope of the invention should be determined by the scope of the claims.
Claims
1. A method for automatically distinguishing front and rear hard disks under an OS, characterized by, The method comprises the following steps: According to the defined disk sequence and the number of hard disks on the front and rear backplanes, the corresponding slot numbers are selected to preliminarily determine the front and rear hard disks. According to the preliminary sequence numbers of the front and rear hard disks, the corresponding hard disk position lights are lit in sequence according to the slot numbers. The level change of the position light is detected, and the I2C address corresponding to the lit position light is queried. The queried I2C address is compared with the preset real I2C address of the front and rear backplanes, and the front and rear hard disks are finally determined according to the comparison result. The step of detecting the level change of the position light and querying the I2C address corresponding to the lit position light comprises: Detecting the level change of the position light. Obtaining a lamp number corresponding table in which each slot number on the hard disk backplane is uniquely corresponding to a position light lamp number and an I2C address. In the lamp number corresponding table, the I2C address corresponding to the detected position light is queried to generate a first I2C address table.
2. The method for automatically distinguishing a front and rear hard disk under an OS according to claim 1, wherein, Before the step of preliminarily determining the front and rear hard disks according to the defined disk sequence and the number of hard disks on the front and rear backplanes, the following steps are included: Viewing the number of hard disks on the front and rear backplanes. Checking the disk sequence defined by the expander chip and the CPLD on the front and rear backplanes to determine the sequence relationship of the front and rear hard disk cascades. Checking the slot numbers recognized by the raid card in the operating system and generating a slot number table.
3. The method of claim 2, wherein the method further comprises: The step of preliminarily determining the front and rear hard disks according to the defined disk sequence and the number of hard disks on the front and rear backplanes comprises: According to the disk sequence defined by the CPLD and the number of hard disks on the front and rear backplanes, the slot number table is matched to select the corresponding slot numbers, and the front and rear hard disks are preliminarily determined, respectively.
4. The method for automatically distinguishing between front and rear hard disks under an OS according to claim 2, wherein, Before the step of comparing the queried I2C address with the preset real I2C address of the front and rear backplanes, the following step is included: Querying a second I2C address table generated by the pre-defined real I2C address of the front and rear hard disks.
5. The method for automatically distinguishing between front and rear hard disks under an OS according to claim 2, wherein, The step of comparing the queried I2C address with the preset real I2C address of the front and rear backplanes and finally determining the front and rear hard disks according to the comparison result comprises: Comparing the first I2C address table with the second I2C address table. If the I2C addresses of the different hard disks in the front and rear of the two tables are consistent, the correctness is checked, and the front and rear hard disks are finally determined.
6. An apparatus for automatically distinguishing a front and rear hard disk under an OS, characterized by, The method comprises an initial selection and determination module, a position light lighting module, a detection and query module, and a comparison and confirmation module. The initial selection and determination module is used for preliminarily determining the front and rear hard disks according to the defined disk sequence and the number of hard disks on the front and rear backplanes. The position light lighting module is used for lighting the corresponding hard disk position light according to the slot number in sequence according to the preliminary sequence number of the front and rear hard disks. The detection and query module is used for detecting the level change of the position light and querying the I2C address corresponding to the lit position light. The comparison and confirmation module is used for comparing the queried I2C address with the preset real I2C address of the front and rear backplanes, and finally determining the front and rear hard disks according to the comparison result. The step of detecting the level change of the position light and querying the I2C address corresponding to the lit position light comprises: Detecting the level change of the position light; Obtaining a light number correspondence table in which each slot number on the hard disk backboard uniquely corresponds to a position light light number and an I2C address; In the light number correspondence table, the I2C address corresponding to the detected position light is queried to generate a first I2C address table.
7. The apparatus for automatically distinguishing between front and rear hard disks under an OS according to claim 6, wherein, The device further includes a hard disk quantity query module, a sequence relationship determination module, and a slot number checking module; The hard disk quantity query module is configured to check the number of hard disks on the front and rear backboards; The sequence relationship determination module is configured to check the disk sequence defined by the expander chip and the CPLD on the front and rear backboards and determine the sequence relationship of the front and rear hard disks in cascade; The slot number checking module is configured to check the slot numbers recognized under the raid card in the operating system and generate a slot number table.
8. An electronic device, comprising: The electronic device includes: at least one processor; and a memory connected to the at least one processor in communication; wherein The memory stores computer program instructions executable by the at least one processor, and the computer program instructions are executed by the at least one processor to enable the at least one processor to execute the method for automatically distinguishing front and rear hard disks under an OS according to any one of claims 1 to 5.
9. A non-transitory computer-readable storage medium, comprising: The non-transitory computer readable storage medium stores computer instructions, and the computer instructions enable the computer to execute the method for automatically distinguishing front and rear hard disks under an OS according to any one of claims 1 to 5.
Citation Information
Patent Citations
Convenient hard disk positioning method and device
CN114115728A