RAid drive self-adaption method and system

Through automated monitoring and compilation of RAID drivers, the compatibility problems of RAID driver adaptation in system kernel upgrades are solved, and the system is highly adaptable and stable, avoiding data loss and system startup problems.

CN119847622AInactive Publication Date: 2025-04-18POWERLEADER COMPUTER SYST CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202510332400.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-20
Publication Date
2025-04-18
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

During the system kernel upgrade process, RAID driver adaptation may lead to compatibility issues, resulting in RAID array card drivers not being loaded normally, affecting system startup and data access, and increasing operation and maintenance risks and the possibility of data loss.

Method used

By automatically checking the kernel version, identifying the RAID controller model, automatically selecting and loading the appropriate RAID driver, recompiling the RAID driver module when the existing RAID driver is incompatible with the new kernel, and automatically running dracut and depmod to update the module dependencies and generate a new initramfs image.

Benefits of technology

It realizes automated monitoring of kernel modules, automatically build and compile loading array card drivers, reduces the need for manual intervention, improves the adaptability and flexibility of the system, ensures the compatibility and stability of the raid driver, and avoids data loss and system startup problems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119847622A_ABST
    Figure CN119847622A_ABST
Patent Text Reader

Abstract

The invention relates to a raid drive self-adaption method and a raid drive self-adaption system. The method comprises the following steps: automatically checking a kernel version; identifying the model of the RAID controller; a proper raid drive is automatically selected and loaded; when the existing driver is incompatible with the new kernel, recompiling the raid driving module; and automatically running the draut and the depmod to update the dependency relationship of the module, and generating a new initramfs image. According to the method, the kernel module can be automatically monitored, the array card driver can be automatically constructed, compiled and loaded, and the abnormal phenomena that the system cannot be accessed and the like are prevented.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to a raid drive self-adaptation method and system, belonging to the communication field. Background Art

[0002] RAID (Redundant Array of Independent Disks) is a data storage virtualization technology that combines multiple independent disks into a logical unit. It improves the performance, reliability and fault tolerance of the storage system through data striping, mirroring or verification. In modern computer systems, RAID (Redundant Array of Independent Disks) technology is widely used in data storage systems to provide high performance, high reliability and data redundancy protection. As a key link in realizing RAID functions, RAID driver adaptation directly affects the normal operation of the entire storage system due to its stability and compatibility.

[0003] At present, common system kernel upgrade operations often require the introduction of new API interfaces, kernel module loading mechanisms or memory management strategies, which can easily cause the original RAID driver to not work properly due to compatibility issues. During the kernel upgrade process, the dependencies between system components that enable the RAID driver to operate normally may change, leading to driver adaptation failures and even the risk of data stored in the array being lost or inaccessible.

[0004] Therefore, in the current operation and maintenance environment, RAID driver adaptation faces significant technical problems. When kernel upgrades are required due to software adaptation or dependencies, the upgrade often causes the RAID array card driver to fail to load normally, which in turn affects system startup and data access. This compatibility issue not only increases the operation and maintenance risk, but may also cause data loss, posing a great challenge to system stability. Summary of the invention

[0005] The present invention provides a raid driver self-adaptation method and system, aiming to solve at least one of the technical problems existing in the prior art.

[0006] The technical solution of the present invention relates to a raid driver self-adaptation method, and the method according to the present invention comprises the following steps: S100, automatically check the kernel version; S200, identify the model of the RAID controller; S300, automatically select and load the appropriate raid driver; S400, when the existing raid driver is incompatible with the new kernel, recompile the raid driver module; S500, automatically runs dracut and depmod to update module dependencies and generate a new initramfs image.

[0007] Furthermore, in step S100, the currently running kernel version is obtained and the type of RAID controller in the system is identified, which includes the steps of: S110, obtain the kernel version of the current system through the uname -r command, and store the result in the variable current_kernel; S120. Use the echo command to output the value of the variable current_kernel to the terminal.

[0008] Further, in the step S200, the RAID controller is screened out by using the lscpi command, which includes the steps of: S210, define a variable raid_controller, and assign it to a list of all RAID-related PCI devices in the system by executing the command lspci | grep -i "RAID"; S220 , using an if statement to check whether the variable raid_controller is not empty, to determine whether a RAID controller is detected in the system.

[0009] Further, the step S220 includes: S221, if raid_controller is not empty, output the value of the variable raid_controller to output the detected RAID controller information; S222: If raid_controller is empty, output that no RAID controller is detected.

[0010] Further, in step S300, according to the current kernel version and RAID controller type, a suitable raid driver is automatically selected and loaded, which includes the steps of: S310, defining a variable driver_path, which contains the expected path of the raid driver file under the current kernel version; S320, use an if statement to check whether the raid driver file in this path exists.

[0011] Further, in step S320, the -f "$driver_path" condition is used to check whether the specified file exists and is a normal file, which includes the steps of: S321, if the if condition is true, it can be obtained that the raid driver file exists, and the script will output a reminder message to indicate that an adapted raid driver is found and is ready to be loaded; S322. If the if condition is false, it can be obtained that the raid driver file does not exist, and the script will output an error message to prompt that no suitable raid driver is found, and it is suggested to check whether the raid driver has been compiled and placed in the correct path. In addition, the script exits through the exit 1 command and returns a non-zero exit status code to indicate that an error was encountered during the script execution.

[0012] Further, the step S400 includes: S410. Use the sudo yum install kernel-devel-$current_kernel -y command to try to install the kernel development package corresponding to the currently running kernel version. S420. Use the cd / root / raid-driver command to try to switch to the source code directory of the raid driver; S430. Use the . / compile.sh command to run the compile.sh script file in the current directory to compile the raid driver through a series of compile commands in the script file.

[0013] Further, the step S500 includes: S510. Execute the command sudo depmod -a "$current_kernel" to update the module dependencies of the current kernel version; S520. Execute the command sudo dracut -f " / boot / initramfs-$current_kernel.img" "$current_kernel" to update initramfs.

[0014] The technical solution of the present invention also relates to a computer-readable storage medium on which program instructions are stored, and the above-mentioned method is implemented when the program instructions are executed by a processor.

[0015] The technical solution of the present invention also relates to a raid drive self-adaptive system, which includes a computer device, and the computer device contains the above-mentioned computer-readable storage medium.

[0016] The beneficial effects of the present invention are as follows: The raid driver self-adaptation method and system of the present invention can automatically monitor kernel modules, automatically build and compile array card drivers, and prevent abnormal phenomena such as failure to enter the system. The present invention can automatically detect the current kernel version and select the most suitable raid driver according to the type of RAID controller actually installed in the system, thereby reducing the need for manual intervention. When the existing driver is incompatible with the new kernel, the tool can intelligently determine whether the raid driver needs to be recompiled, thereby improving the adaptability and flexibility of the system. By adding a dynamic response mechanism, monitoring kernel changes or using the hook function provided by the package manager, the necessary operations are performed immediately after each new kernel is installed, ensuring that the raid driver is always the latest and compatible with the current environment. Its dynamic response mechanism not only simplifies the maintenance process, but also improves the stability and security of the system. Integrating dracut and depmod, by automatically running dracut and depmod commands to update module dependencies and create a new initramfs image, it is ensured that the newly compiled raid driver can be correctly loaded when the system starts, thereby effectively ensuring the normal startup of the server. Scriptability and portability are achieved, and all steps are integrated into an easy-to-deploy and execute shell script, so that the tool can be quickly deployed on different Linux distributions and customized according to specific needs. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] Figure 1 is a basic flow chart of the method according to the present invention. DETAILED DESCRIPTION

[0018] The concept, specific structure and technical effects of the present invention will be clearly and completely described below in combination with the embodiments and drawings to fully understand the purpose, scheme and effect of the present invention.

[0019] It should be noted that, unless otherwise specified, when a feature is referred to as being "fixed" or "connected" to another feature, it may be directly fixed or connected to another feature, or it may be indirectly fixed or connected to another feature. The singular forms "a", "said" and "the" used herein are also intended to include the plural forms, unless the context clearly indicates otherwise. In addition, unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art. The terms used in this specification are intended only to describe specific embodiments and are not intended to limit the invention. The term "and / or" used herein includes any combination of one or more of the related listed items.

[0020] It should be understood that, although the term first, second, third etc. may be adopted to describe various elements in the present disclosure, these elements should not be limited to these terms. These terms are only used to distinguish the same type of elements from each other. For example, without departing from the scope of the present disclosure, the first element may also be referred to as the second element, and similarly, the second element may also be referred to as the first element. The use of any and all examples or exemplary language ("for example", "such as" etc.) provided herein is only intended to better illustrate embodiments of the present invention, and unless otherwise required, will not impose limitations on the scope of the present invention.

[0021] Reference Figure 1 In some embodiments, a raid driver self-adaptation method according to the present invention comprises at least the following steps: S100, automatically check the kernel version; S200, identify the RAID controller model; S300, automatically select and load the appropriate raid driver; S400, when the existing raid driver is incompatible with the new kernel, recompile the raid driver module; S500, automatically runs dracut and depmod to update module dependencies and generate a new initramfs image.

[0022] The raid driver self-adaptation method and system of the present invention can automatically monitor kernel modules, automatically build and compile array card drivers for loading, and prevent abnormal phenomena such as failure to enter the system.

[0023] In some embodiments, the method of the present invention can automatically check the kernel version, obtain the currently running kernel version and identify the type of RAID controller in the system. Specifically, firstly, the kernel version of the current system is obtained by the uname -r command, and the result is stored in the variable current_kernel. Then, the echo command is used to output "The current kernel version is:" together with the value of the variable current_kernel to the terminal so that the user can view the currently running kernel version. The code is as follows: current_kernel=$(uname -r) echo "The current kernel version is: $current_kernel" In some embodiments, the method of the present invention can identify the model of the RAID controller, and it filters out the RAID controller through the lscpi command. Specifically, first define a variable raid_controller, and assign it to a list of all RAID-related PCI devices in the system by executing the command lspci | grep-i "RAID". Among them, the present invention uses the pipe symbol | to pass the output of the lspci command to the grep command, and grep -i "RAID" is used to filter out the lines containing "RAID" (case insensitive). Then use the if statement to check whether the variable raid_controller is not empty, that is, whether a RAID controller is detected in the system. Among them, if raid_controller is not empty, that is, the condition [-n "$raid_controller"] is true, then execute the command after then, and use the echo command to output the detected RAID controller information, the format is "detected RAID controller: " followed by the value of the variable raid_controller; if raid_controller is empty, that is, the condition [-n "$raid_controller"] is false, then execute the command after else, and use the echo command to output "no RAID controller is detected". The code is as follows: raid_controller=$(lspci | grep -i "RAID") if [ -n "$raid_controller" ]; then echo "RAID controller detected: $raid_controller" else echo "No RAID controller detected." fi Here is a specific example to illustrate. For example, through the method of the embodiment of the present invention, the user logs in to the system named alice as root, and the user enters the lspci | grep -i "RAID" command in the command line. After executing the command, the system returns a line of results: the device is located at device 0 of bus 83, function 0; this is a RAID bus controller; the manufacturer of the device is Broadcom, and the model is LSI MegaRAID 12Gb / s / PCIe Secure SAS39xx, thereby identifying the model of the RAID controller. The code is as follows: root@alice:~# lspci | grep -i "RAID" 83:00.0 RAID bus controller: Broadcom / LSI MegaRAID 12GSAS / PCIeSecure SAS39xx The lspci command is used to list all PCI devices in the system. The | symbol indicates a pipe operation, which uses the output of the previous command as the input of the next command. The grep -i "RAID" command is used to search for lines containing "RAID" (case-insensitive) in the output of the lspci command.

[0024] In some embodiments, the method of the present invention can automatically select and load a suitable raid driver, which automatically selects and loads a suitable raid driver according to the current kernel version and the RAID controller type. Specifically, first, a variable driver_path is defined, which contains the expected path of the raid driver file under the current kernel version, for example, the path points to the megaraid_sas.ko driver file in the kernel / drivers / scsi / megaraid / subdirectory corresponding to the current kernel version (specified by the variable current_kernel) under the / lib / modules / directory. Then, an if statement is used to check whether the raid driver file under this path exists. It is implemented by the -f "$driver_path" condition, where the -f test is used to check whether the specified file exists and is a normal file. Among them, if the raid driver file exists, that is, if the condition is true, the script will output a message indicating that an adapted raid driver has been found and is ready to load the driver. This message includes the path to the raid driver file, and then loads the megaraid_sas module by executing the modprobe megaraid_sas command; if the raid driver file does not exist, that is, the if condition is false, the script will output an error message, indicating that no suitable raid driver was found, and suggesting to check whether the raid driver has been compiled and placed in the correct path, and the script will exit through the exit 1 command and return a non-zero exit status code to indicate that an error was encountered during the script execution. The code is as follows: driver_path=" / lib / modules / $current_kernel / kernel / drivers / scsi / megaraid / megaraid_sas.ko" # Check if the driver file exists if [ -f "$driver_path" ]; then echo "Found the appropriate raid driver, loading: $driver_path" modprobe megaraid_sas else echo "No compatible raid driver found, please check whether the driver has been compiled and placed in the correct path" exit 1 fi In some embodiments, the method of the present invention can load and recompile the driver. When the existing driver is incompatible with the new kernel, the method of the present invention recompiles the raid driver module. Specifically, first, use the sudo yum installkernel-devel-$current_kernel -y command to try to install the kernel development package (kernel-devel) corresponding to the currently running kernel version. The code is as follows: sudo yum install kernel-devel-$current_kernel -y || { echo 'Unable to install kernel-devel'; exit 1;} Among them, $current_kernel is a variable that contains the current kernel version number obtained by the uname -r command. The -y option means automatically answering all prompts during the installation process with "yes", so that unattended installation can be achieved. The || operator is used for error handling. If the yum install command fails to execute, that is, returns a non-zero exit status, the command block after || is executed, which includes outputting the error message "Unable to install kernel-devel" and using the exit 1 command to exit the script. The return status code 1 indicates that the execution failed.

[0025] Then, use the cd / root / raid-driver command to try to switch to the source code directory of the raid driver. For example, as shown in the following code, the driver source code has been downloaded and unzipped to the / root / raid-driver directory. The code is as follows: # Enter the driver source code directory cd / root / raid-driver || { echo 'The driver source code directory does not exist'; exit 1;} The || operator is also used for error handling. If the cd command fails (for example, if the directory does not exist), the command block following || is executed. This includes outputting the error message "The driver source code directory does not exist" and exiting the script using the exit 1 command, returning a status code 1 to indicate failure.

[0026] Then, use the . / compile.sh command to run the compile.sh script file in the current directory. Compile the raid driver through a series of compile commands in the script file. The code is as follows: # Compile the driver . / compile.sh || { echo 'Compilation failed! '; exit 1;} The || operator is used to execute the following command block when the compile.sh script fails to execute (that is, the script returns a non-zero exit status). If the compilation fails, the script will output an error message "Compilation failed!" and then exit through the exit 1 command, returning a status code of 1 to indicate that an error was encountered during execution.

[0027] The method of the present invention can automatically install a kernel development package and switch to a raid driver source code directory, can promptly notify a user and terminate subsequent operations when a compilation error occurs, and prevent system instability or other problems that may be caused by unsuccessful driver compilation, thereby realizing automation of the driver compilation process.

[0028] In some embodiments, the method of the present invention can automatically run dracut and depmod, update module dependencies, and generate a new initramfs image, thereby ensuring that the system's module dependencies and initramfs are up to date. Specifically, first execute the command sudo depmod -a "$current_kernel" to update the module dependencies of the current kernel version. The code is as follows: # Update module dependencies sudo depmod -a "$current_kernel" The sudo command is used to obtain the necessary permissions, because updating module dependencies usually requires administrator privileges. The depmod command is used to generate dependency information for kernel modules. The -a parameter means to generate dependency information for all modules, not just the currently loaded modules. The "$current_kernel" variable contains the version number of the currently running kernel, ensuring that the update operation targets the correct kernel version.

[0029] Then, execute the command sudo dracut -f " / boot / initramfs-$current_kernel.img" "$current_kernel" to update initramfs. The code is as follows: # Update initramfs sudo dracut -f " / boot / initramfs-$current_kernel.img" "$current_kernel" Among them, dracut is a tool for generating initramfs. It can generate an initramfs image containing all necessary drivers and files according to the current system configuration and kernel version. The -f parameter forces the regeneration of initramfs, even if an initramfs of the same version already exists. " / boot / initramfs-$current_kernel.img" specifies the path and name of the generated initramfs image file, which contains the current kernel version number. The second parameter "$current_kernel"" specifies the kernel version for which to generate initramfs.

[0030] Here is a specific example to illustrate. The example shown in the following code, current_kernel=$(uname -r) echo "Current kernel version: $current_kernel" raid_controller=$(lspci | grep -i "RAID") if [ -n "$raid_controller" ]; then echo "RAID controller detected: $raid_controller" else echo "No RAID controller detected." fi driver_path=" / lib / modules / $current_kernel / kernel / drivers / scsi / megaraid / megaraid_sas.ko" if [ -f "$driver_path" ]; then echo "Found the appropriate raid driver, loading: $driver_path" sudo modprobe megaraid_sas else echo "raid driver does not match, recompiling..." sudo yum install kernel-devel-"$current_kernel" -y || { echo 'Unable to install kernel-devel'; exit 1;} cd / root / raid-driver || { echo 'The driver source code directory does not exist'; exit 1;} . / compile.sh || { echo 'Compilation failed! '; exit 1;} sudo depmod -a "$current_kernel" sudo dracut -f " / boot / initramfs-$current_kernel.img" "$current_kernel" echo "The driver has been updated, loading..." sudo modprobe megaraid_sas || { echo 'Failed to load driver! '; exit 1;} echo "RAID driver update completed." It should be appreciated that the method steps in the embodiments of the present invention can be implemented or implemented by computer hardware, a combination of hardware and software, or by computer instructions stored in a non-transitory computer readable memory. The method can use standard programming techniques. Each program can be implemented in a high-level process or object-oriented programming language to communicate with a computer system. However, if necessary, the program can be implemented in an assembly or machine language. In any case, the language can be a compiled or interpreted language. In addition, the program can be run on a programmed ASIC for this purpose.

[0031] In addition, the operations of the processes described herein may be performed in any suitable order unless otherwise indicated herein or otherwise clearly contradicted by context. The processes described herein (or variations and / or combinations thereof) may be performed under the control of one or more computer systems configured with executable instructions, and may be implemented as code (e.g., executable instructions, one or more computer programs, or one or more applications) that is executed collectively on one or more processors, by hardware, or a combination thereof. The computer program includes a plurality of instructions that may be executed by one or more processors.

[0032] Further, the method can be implemented in any type of computing platform that is operably connected to a suitable computer, including but not limited to a personal computer, a minicomputer, a mainframe, a workstation, a network or distributed computing environment, a separate or integrated computer platform, or in communication with a charged particle tool or other imaging device, etc. Various aspects of the present invention can be implemented in machine-readable code stored on a non-transitory storage medium or device, whether removable or integrated into a computing platform, such as a hard disk, an optical read and / or write storage medium, an RSM, a ROM, etc., so that it can be read by a programmable computer, and when the storage medium or device is read by the computer, it can be used to configure and operate the computer to perform the process described herein. In addition, the machine-readable code, or portions thereof, can be transmitted via a wired or wireless network. When such media includes instructions or programs that implement the steps described above in conjunction with a microprocessor or other data processor, the invention described herein includes these and other different types of non-transitory computer-readable storage media. When programmed according to the methods and techniques of the present invention, the present invention can also include the computer itself.

[0033] The computer program can be applied to input data to perform the functions described herein, thereby converting the input data to generate output data stored in a non-volatile memory. The output information can also be applied to one or more output devices such as a display. In a preferred embodiment of the present invention, the converted data represents physical and tangible objects, including specific visual depictions of physical and tangible objects produced on the display.

[0034] The above is only a preferred embodiment of the present invention. The present invention is not limited to the above implementation. As long as the technical effect of the present invention is achieved by the same means, any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the scope of protection of the present invention. Within the scope of protection of the present invention, its technical scheme and / or implementation method may have various modifications and changes.

Claims

1. A raid driver self-adaptation method, characterized in that: The method comprises the following steps: S100, automatically check the kernel version; S200, identify the model of the RAID controller; S300, automatically selects and loads the appropriate RAID driver; S400, when the existing raid driver is incompatible with the new kernel, recompile the raid driver module; S500, automatically runs dracut and depmod to update module dependencies and generate a new initramfs image.

2. The method according to claim 1, characterized in that In step S100, the currently running kernel version is obtained and the type of RAID controller in the system is identified, which includes the following steps: S110, obtain the kernel version of the current system through the uname -r command, and store the result in the variable current_kernel; S120. Use the echo command to output the value of the variable current_kernel to the terminal.

3. The method according to claim 1, characterized in that: In the step S200, the RAID controller is screened out by using the lscpi command, which includes the steps of: S210, define a variable raid_controller, and assign it to a list of all RAID-related PCI devices in the system by executing the command lspci | grep -i "RAID"; S220 , using an if statement to check whether the variable raid_controller is not empty, to determine whether a RAID controller is detected in the system.

4. The method according to claim 3, characterized in that The step S220 includes: S221, if raid_controller is not empty, output the value of the variable raid_controller to output the detected RAID controller information; S222: If raid_controller is empty, output that no RAID controller is detected.

5. The method according to claim 1, characterized in that In the step S300, according to the current kernel version and the RAID controller type, the appropriate raid driver is automatically selected and loaded, which includes the steps of: S310, defining a variable driver_path, which contains the expected path of the raid driver file under the current kernel version; S320, use an if statement to check whether the raid driver file in this path exists.

6. The method according to claim 5, characterized in that In step S320, the -f "$driver_path" condition is used to check whether the specified file exists and is a normal file, which includes the steps of: S321, if the if condition is true, it can be obtained that the raid driver file exists, and the script will output a reminder message to indicate that an adapted raid driver is found and is ready to be loaded; S322. If the if condition is false, the driver file does not exist, and the script will output an error message to prompt that no suitable raid driver is found, and suggest checking whether the raid driver has been compiled and placed in the correct path. In addition, the script exits through the exit 1 command and returns a non-zero exit status code to indicate that an error was encountered during the script execution.

7. The method according to claim 1, characterized in that The step S400 includes: S410. Use the sudo yum install kernel-devel-$current_kernel -y command to try to install the kernel development package corresponding to the currently running kernel version. S420. Use the cd / root / raid-driver command to try to switch to the source code directory of the raid driver; S430. Use the . / compile.sh command to run the compile.sh script file in the current directory to compile the raid driver through a series of compile commands in the script file.

8. The method according to claim 1, characterized in that The step S500 includes: S510. Execute the command sudo depmod -a "$current_kernel" to update the module dependencies of the current kernel version; S520. Execute the command sudo dracut -f " / boot / initramfs-$current_kernel.img" "$current_kernel" to update initramfs.

9. A computer-readable storage medium, characterized in that: Program instructions are stored thereon, and when the program instructions are executed by a processor, the method according to any one of claims 1 to 8 is implemented.

10. A raid driver self-adaptive system, characterized in that: include: A computer device comprising a computer readable storage medium according to claim 9.

Citation Information

Patent Citations

  • Method for compiling raid card driver in tobo linux 7.01 system

    CN101819535A

  • Method and system for configuring Raid (Redundant array of independent disks)

    CN104360883A

  • Cache system based on nonvolatile memory and software RAID

    CN106528001A

  • A method and apparatus for installing a RAID driver

    CN109358907A

  • Method for handling small computer system interface (SCSI) commands via a redundant array of inexpensive disks (RAID) device driver

    US20100005482A1