Storage device sorting method
By mapping the symbolic link of the device to the hardware slot or driver protocol resource, the hard disk location is directly determined, which solves the problem of confusing sequence identification of multiple hard disks, improves the efficiency of hard disk device usage, and realizes the automatic sorting function.
Patent Information
- Application Number
- CN202111382430.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-19
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2041-11-19
AI Technical Summary
The existing technology is cumbersome and cumbersome to handle when multiple hard drives are out of order, and is inefficient. It also fails to effectively solve the problem of hard drives being out of order, resulting in inconvenient maintenance.
By corresponding the symbolic link of the device with the hardware slot resource information or driver protocol resource information, the fixed slot or driver protocol resource is used to directly determine the hard disk location, and the symbolic link is used to sort the hard disk to avoid the hard disk sequence identification caused by hot swapping. confusion.
It realizes the automatic sorting of hard disks, improves the usage efficiency of multi-hard disk devices, and avoids the confusion of hard disk sequence identification caused by hot swapping. The sorting can be completed by adding the program at one time and starting automatically.
Smart Images

Figure CN114063925B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of storage devices, and in particular to a storage device sorting method. Background Art
[0002] An existing solution to the disordered order of multiple hard disks is usually to record the hard disks by capturing the product serial numbers of the hard disks, record and compare the data for each disordered order of the hard disks, and save the recorded data and the comparison results in a record table. By checking the record table, it is determined whether the hard disks are dropped or disordered. This method requires setting test variables and time intervals and test parameter files each time, which is troublesome and cumbersome to operate. If an abnormality occurs during the test, it is necessary to repeatedly check and verify according to the test log information, which has low work efficiency. Moreover, it is only a method for verifying the drop of hard disks and disordered order of hard disks during the use of the device, and does not actually solve the problem of hard disk disorder, which brings a lot of inconvenience during use and maintenance. Summary of the invention
[0003] The storage device sorting method provided by the present invention can correspond the symbolic link of the device with the slot resource information or the driver protocol resource information in the hardware, and can directly determine the position of the hard disk through the fixed slot or driver protocol resource.
[0004] The present invention provides a storage device sorting method, comprising:
[0005] Obtaining a device event corresponding to the first storage device;
[0006] Search for the predetermined rule file in the rule file directory;
[0007] When the predetermined rule file exists,
[0008] Obtaining slot resource information or drive protocol resource information corresponding to the first storage device to determine a mapping target;
[0009] According to the predetermined rule file, a first symbolic link corresponding to the mapping target is processed under a first predetermined path.
[0010] Optionally, when the device event is a device deletion event;
[0011] Processing the first symbolic link corresponding to the mapping target includes: deleting the first symbolic link;
[0012] When a device event adds an event to a device;
[0013] Processing a first symbolic link corresponding to the mapping target includes: establishing the first symbolic link.
[0014] Optionally, when the predetermined rule file does not exist, the second symbolic link corresponding to the first storage device is processed according to a default rule in the second predetermined path.
[0015] Optionally, when the device event is a device deletion event;
[0016] Processing the second symbolic link corresponding to the first storage device includes: deleting the second symbolic link corresponding to the first storage device according to a default rule, and updating the symbolic link corresponding to the storage device other than the first storage device;
[0017] When a device event adds an event to a device;
[0018] Processing the second symbolic link corresponding to the first storage device includes: establishing the second symbolic link corresponding to the first storage device according to a default rule.
[0019] Optionally, searching for a predetermined rule file in a rule file directory includes:
[0020] According to one or more key-value pairs of the first storage device, a predetermined rule corresponding to the device addition event is matched;
[0021] When more than one key-value pair is the same as the key-value pair in the rule file, determining the corresponding rule file as a predetermined rule;
[0022] When more than one key-value pair is different from the key-value pairs in the rule file, it is determined that the predetermined rule file does not exist.
[0023] Optionally, it also includes:
[0024] Partitioning, formatting or mounting the first symbolic link, or hot-plugging the first storage device;
[0025] The log file corresponding to the partitioning, formatting, mounting or hot-plugging operation is queried to verify whether the predetermined rule is effective.
[0026] Optionally, it also includes:
[0027] The predetermined rule file is stored in a storage path of the rule file, and the predetermined rule file is configured to be in a boot-up automatic startup state.
[0028] Optionally, when a predetermined rule file exists, the device type of the first storage device is obtained, and slot resource information or drive protocol resource information corresponding to the first storage device is obtained according to the first device type to determine a mapping target.
[0029] Optionally, when the device type of the first storage device is a disk array card, the disk array card is communicatively connected to a plurality of hard disks;
[0030] Obtain the slot resource information or driver protocol resource information corresponding to the disk array card to determine the mapping target.
[0031] Optionally, when the device type of the first storage device is a hard disk;
[0032] Obtain the slot resource information or drive protocol resource information corresponding to the hard disk to determine the mapping target.
[0033] In the technical solution provided by the present invention, by mapping the symbolic link with a fixed hardware slot, or mapping the symbolic link with a driver protocol resource, the connection position of the hard disk or the resource used can be directly determined through the symbolic link. In the technical solution provided by the present invention, the confusion of hard disk sequence recognition caused by hot plugging of hard disks is avoided, and there is no need to waste time to check which specific hard disk name corresponds to which hard disk interface on the device. It only needs to add the program to the boot-up self-starting operation once to complete the sorting of multiple hard disks, thereby improving the efficiency of multi-hard disk devices during use. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] Figure 1 A flowchart of a storage device sorting method according to an embodiment of the present invention;
[0035] Figure 2 A flowchart of a storage device sorting method for determining event types according to another embodiment of the present invention;
[0036] Figure 3 A flowchart of generating symbolic links according to a default rule of a storage device sorting method according to an embodiment of the present invention;
[0037] Figure 4 This is a flowchart of a storage device sorting method for determining event types according to another embodiment of the present invention. DETAILED DESCRIPTION
[0038] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0039] The embodiment of the present invention provides a storage device sorting method, such as Figure 1 As shown, including:
[0040] Obtain a device event corresponding to the first storage device; in some embodiments, the first storage device refers to a storage device on an interface connected to the mainboard, and the first storage device includes multiple storage devices, for example, it can be one or more of a hard disk, a USB flash drive, a floppy disk, an optical disk, and a magnetic storage device. A device event refers to an event in which the device state changes, for example, the addition of a device or the deletion of a device.
[0041] Search for a predetermined rule file in the rule file directory; in some embodiments, the rule file directory is a directory path for storing multiple rule files, and the predetermined rule file refers to a user-defined rule file, which at least includes rules for device file naming or device symbolic link naming. For example, name the custom rule file 10-disk.rules, and add the custom rule file to the default storage path of the UDEV rule file / etc / udev / rules.d / or / usr / lib / udev / rules.d / . Use udevadmin to reload the udev custom rule file in the boot-up self-startup.
[0042] When a predetermined rule file exists, in some embodiments, when a device is added or deleted, the key-value pairs of the device are extracted, and then the key-value pairs of the device are compared with the key-value pairs in the rule file. When the key-value pairs of the two are the same, it indicates that the rule file can be applied to the first storage device that is currently added or deleted.
[0043] Obtain the slot resource information or driver protocol resource information corresponding to the first storage device to determine the mapping target; in some embodiments, the first storage device is connected to the mainboard through a slot, and the first storage device corresponds to the slot one-to-one, so the corresponding slot can be used to determine the sorting position of the first storage device. In other embodiments, when the first storage device is connected to the mainboard, the first storage device will use the driver protocol resources. For example, the first storage device will correspond to the PHY resources of the driver protocol. PHY refers to the physical layer in the hard disk drive protocol. Generally, the drive controller supports 8 PHY resources, and the first storage device will correspond to one of the PHY resources. Due to the corresponding characteristics of the PHY resources and the first storage device, the sorting position of the first storage device can be determined by the PHY resources.
[0044] According to the predetermined rule file, the first symbolic link corresponding to the mapping target is processed under the first predetermined path. In some embodiments, since the mapping target corresponds to each first storage device, and the mapping target is unique, the correspondence between the first symbolic link and the mapping target indirectly reflects the correspondence between the first symbolic link and the slot, or the correspondence between the first symbolic link and the driver protocol resource. Therefore, when the first symbolic link exists, it indicates that the corresponding driver protocol resource is occupied, or the corresponding slot is occupied, which can intuitively represent the hardware resources or software resources occupied by the first storage device. In some embodiments, in order to prevent the confusion of the recognition order caused by hot plugging of the hard disk, the hard disk needs to be fixedly sorted. In order to avoid conflicts with the symbolic links generated by the system in the default file directory / dev / , a predetermined rule file, that is, a custom udev rule file, is used in the sorting process to symbolically link the device files under / dev / . For example, when the system starts, the system will name each device in the default order for all devices connected to our hardware. For example, the device connected to the Phy0 port is described as dev / sda in the system. In the predetermined rule file, the device name sda in the / dev / directory is not modified, but a symbolic link is created in the new directory, such as / dev / scsi / sda.
[0045] In the technical solution provided by the embodiment of the present invention, by mapping the symbolic link with a fixed hardware slot, or mapping the symbolic link with a driver protocol resource, the connection position of the hard disk or the resource used can be directly determined through the symbolic link. In the technical solution provided by the present invention, the confusion of hard disk sequence recognition caused by hot plugging of hard disks is avoided, and there is no need to waste time to check which specific hard disk name corresponds to which hard disk interface on the device. It only needs to add the program to the boot-up self-starting operation once to complete the sorting of multiple hard disks, thereby improving the efficiency of multiple hard disk devices during use.
[0046] As an optional implementation, Figure 2 As shown, in the storage device sorting method, in some embodiments, when the first device is hot-plugged, the device event is manifested as a device addition event or a device deletion event, and hot-plugging is hot plugging, which means inserting or unplugging a module or board into or out of the system without turning off the system power without affecting the normal operation of the system.
[0047] When the device event is a device removal event; in some embodiments, the device removal event refers to unplugging the first storage device without shutting down the system power.
[0048] Processing the first symbolic link corresponding to the mapping target includes: deleting the first symbolic link; in some embodiments, since the first symbolic link corresponds one-to-one to a hardware slot or a driver protocol resource, when the first symbolic link exists, it indicates that the corresponding slot is occupied or the corresponding driver protocol resource is occupied, and when the first symbolic link is deleted, it indicates that the corresponding slot or driver protocol resource is released. Thus, the released slot or driver protocol resource can be determined through the deleted first symbolic link, and the sorting position of the unplugged first storage device can be further confirmed. It should be noted that since each symbolic link corresponds one-to-one to the sorting position of the corresponding storage device, after deleting the first symbolic link, the other symbolic links should remain unchanged, so that the sorting position of the remaining hard disks can be determined through the remaining symbolic links.
[0049] When the device event is a device adding event; in some embodiments, the device adding event refers to inserting the first storage device without turning off the system power.
[0050] Processing the first symbolic link corresponding to the mapping target includes: establishing the first symbolic link. In some embodiments, since the first symbolic link corresponds one-to-one to a hardware slot or a driver protocol resource, when the first symbolic link exists, it indicates that the corresponding slot is occupied or the corresponding driver protocol resource is occupied, and when a new symbolic link is created, it indicates that the corresponding slot or driver protocol resource is occupied. Thus, the released slot or driver protocol resource can be determined through the newly created first symbolic link, and the sorting position of the inserted first storage device can be further confirmed. It should be noted that since each symbolic link corresponds one-to-one to the sorting position of the corresponding storage device, after the first symbolic link is created, the other symbolic links should remain unchanged, so that the sorting positions of the remaining hard disks can be determined through the remaining symbolic links.
[0051] In this embodiment, the arrangement order of the storage devices can be confirmed through the correspondence between the storage devices and the symbolic links. For newly added or deleted storage devices, corresponding symbolic links are created or deleted without affecting other symbolic links. Therefore, the newly added or deleted first storage device will not affect the overall order of the storage devices.
[0052] As an optional implementation, Figure 3As shown, when the predetermined rule file does not exist, the second symbolic link corresponding to the first storage device is processed according to the default rule under the second predetermined path. In some embodiments, since only some storage devices need to be symbolically linked with customized rules in some application scenarios, the default rule can be applied to process the second symbolic link corresponding to the first storage device for storage devices other than some storage devices. For example, the LINUX UDEV rule defines the kernel device name for all devices under the / dev / path through the default rule file, and names the second symbolic link with the kernel device name, such as / dev / sda, / dev / sdb, etc.
[0053] As an optional implementation, Figure 4 As shown, when the predetermined rule file does not exist, executing the storage device sorting method includes:
[0054] When the device event is a device removal event; in some embodiments, the device removal event refers to unplugging the first storage device without shutting down the system power.
[0055] Processing the second symbolic link corresponding to the first storage device includes: deleting the second symbolic link corresponding to the first storage device according to the default rule, and updating the symbolic link corresponding to the storage device other than the first storage device; in some embodiments, according to the default rule, when the first storage device is deleted, the second symbolic link corresponding to the first storage device will be deleted, and at the same time, other symbolic links other than the second symbolic link will be reordered.
[0056] When the device event is a device addition event; in some embodiments, the device addition event refers to inserting the first storage device without shutting down the system power.
[0057] Processing the second symbolic link corresponding to the first storage device includes: establishing the second symbolic link corresponding to the first storage device according to a default rule. In some embodiments, when establishing the second symbolic link corresponding to the first storage device, no matter which slot is currently inserted or which drive protocol resource is occupied, a new second symbolic link will be established after the order of other symbolic links.
[0058] In this embodiment, since in some application scenarios, only some storage devices need to be symbolically linked according to custom rules, therefore, for storage devices other than some storage devices, the default rule can be applied to process the second symbolic link corresponding to the first storage device. This embodiment provides a specific method for establishing and deleting the second symbolic link according to the default rule.
[0059] As an optional implementation, searching for a predetermined rule file in a rule file directory includes:
[0060] According to one or more key-value pairs of the first storage device, a predetermined rule corresponding to the device addition event is matched; in some embodiments, the key-value pair of the first storage device refers to an attribute of the first storage device and a corresponding attribute value, for example, a name field of the first storage device and a name of the first storage device. In the search process, a plurality of key-value pairs can be used to match the first storage device and the predetermined rule.
[0061] When more than one key-value pairs are the same as the key-value pairs in the rule file, the corresponding rule file is determined to be a predetermined rule; in some embodiments, when the key-value pairs in the first storage device are the same as the key-value pairs in the rule file, it can be confirmed that the corresponding rule file can be applied to the creation and deletion of symbolic links in the first storage device.
[0062] When more than one key-value pair is different from the key-value pair in the rule file, it is determined that the predetermined rule file does not exist. In some embodiments, when one of the multiple key-value pairs in the first storage device is different from the key-value pair in the rule file, it is determined that the rule file cannot be applied to the establishment and deletion of the symbolic link of the first storage device.
[0063] In this embodiment, a specific rule matching method is provided, in which only one key-value pair can be used to match the rule file, in which case the matching efficiency will be higher. Alternatively, multiple key-value pairs can be used to match the rule file, in which case the matching efficiency will be lower, but the matching accuracy will be higher.
[0064] As an optional implementation, it also includes:
[0065] The first symbolic link is partitioned, formatted or mounted, or the first storage device is hot-plugged; if the partitioning, formatting or mounting operation can be performed correctly, it indicates that the establishment of the first symbolic link is accurate. Alternatively, when the first storage device is hot-plugged, the establishment and deletion status of the first symbolic link can be used to determine whether the predetermined rule can be correctly executed.
[0066] Query the log file corresponding to the partition, format, mount or hot-swap operation to verify whether the predetermined rule is effective. In some embodiments, when operating the storage device, the system will generate a log file, and the operation results of various operations can be obtained through the log file. For example, perform a plug-in test on the hard disk at the Phy0 port. After starting the system, check the information printed in the temporary log file / tmp / udev.log to check whether the sda device exists in the / dev / scsi directory. Thereby determining whether the predetermined rule of the sda hard disk is effective. For another example, divide / dev / scsi / sdg into 5 partitions. After the partitions of sdg1, sdg2, sdg3, sdg4, and sdg5 are completed, check the information printed in the temporary log file / tmp / udev.log to check whether there are five sdg partitions in the / dev / scsi directory, whether these 5 partitions can be formatted, and whether these 5 partitions can be mounted. Thereby confirming whether the predetermined rule of the sdg hard disk is effective through these operations.
[0067] As an optional implementation, it also includes: storing a predetermined rule file in the storage path of the rule file, and configuring the predetermined rule file to be in the boot-up self-starting state. Before executing the predetermined rule file, it is necessary to first initialize the predetermined rules, for example, add the predetermined rule file 10-disk.rules to the default storage path of the UDEV rule file / etc / udev / rules.d / or / usr / lib / udev / rules.d / . Use udevadmin to reload the udev predetermined rule file in the boot-up self-starting. Copy the program corresponding to the storage device sorting method to the system directory, such as the / home directory for installation. After the installation is complete, the system needs to be restarted.
[0068] As an optional implementation, when a predetermined rule file exists, the device type of the first storage device is obtained, and the slot resource information or driver protocol resource information corresponding to the first storage device is obtained based on the first device type to determine the mapping target. In some embodiments, when the hard disk is connected to the motherboard, the hard disk can be directly connected to the motherboard, or the hard disk can be connected to the motherboard through an array card to form a disk array. Before determining the mapping target, it is necessary to obtain the corresponding predetermined rule file. Since the key-value pair obtained when determining the predetermined rule file usually includes the driver name of the first storage device, it is necessary to determine the mapping target based on different device types. For example, when there is no disk array card, the hard disk driver name in the key-value pair of the first storage device used is AHCI; when there is a disk array card, the corresponding driver name of the disk array card in the key-value pair of the first storage device used is mpt3sas.
[0069] As an optional implementation, when the device type of the first storage device is a disk array card, the disk array card is connected to multiple hard disks in communication; the slot resource information or driver protocol resource information corresponding to the disk array card is obtained to determine the mapping target. In some embodiments, when the system is started, if there is a disk array card, the disk array card connected to the hard disk will be combined into a logical hard disk, and only one hard disk identifier will be seen under / dev in the system. When formulating new fixed rules, a symbolic link is created in the new file directory according to the device name read by the system. If the two hard disks connected to the disk array card are / dev / scsi / sdd and / dev / scsi / sdf; when combined into a disk array, the device name read by the system is sdx; then the disk link corresponding to the created disk array is / dev / scsi / sdx, and the disk array can be operated by operating / dev / scsi / sdx. During debugging, the RAID hard disk at the Phy3 port is plugged and unplugged. After starting the system, check the information printed in the temporary log file / tmp / udev.log to see if the sdx device exists in the / dev / scsi directory. In this way, it can be judged whether the rules after RAID formation are effective. You can also divide / dev / scsi / sdx into 5 partitions, sdx1, sdx2, sdx3, sdx4, and sdx5. After the partitions are completed, check the information printed in the temporary log file / tmp / udev.log to check whether there are five partitions of sdx in the / dev / scsi directory. You can also use the mkfs and mount commands to determine whether these five partitions can be formatted and mounted.
[0070] As an optional implementation, when the device type of the first storage device is a hard disk; obtain the slot resource information or driver protocol resource information corresponding to the hard disk to determine the mapping target. In some embodiments, when the system is started, according to the predetermined rules, the device name sda in the / dev / directory will not be modified, but a symbolic link will be created in the new directory, such as / dev / scsi / sda. During debugging, the hard disk at the Phy0 port is plugged and unplugged. After starting the system, check the information printed in the temporary log file / tmp / udev.log to check whether the sda device exists in the / dev / scsi directory. Thus, it is determined whether the rules of the sda hard disk are effective. Or divide / dev / scsi / sdg into 5 partitions. After the partitions of sdg1, sdg2, sdg3, sdg4, and sdg5 are completed, check the information printed in the temporary log file / tmp / udev.log to check whether there are five sdg partitions in the / dev / scsi directory, whether these 5 partitions can be formatted, and whether these 5 partitions can be mounted. Thus, through these operations, it is confirmed whether the sdg hard disk rules are effective.
[0071] The storage device sorting method is described below through a specific implementation method: Specific implementation 1:
[0073] In the absence of a disk array card, multiple hard disks are sorted as shown in Table 1. The script does not modify the device description in the / dev directory. It only determines the fixed order of symbolic links in the / dev / scsi directory according to the occupation relationship of the driver protocol resources. Partitioning, formatting, or mounting operations on the link files in the / dev / scsi directory will operate on the specified hard disk. When the hard disk is plugged in or out, the / dev / scsi will display whether the hard disk exists and the order of the hard disks.
[0074] Table 1
[0075] Phy0: / dev / scsi / sda Phy2: / dev / scsi / sdc Phy4: / dev / scsi / sde Phy6: / dev / scsi / sdg Phy1: / dev / scsi / sdb Phy3: / dev / scsi / sdd Phy5: / dev / scsi / sdf Phy7: / dev / scsi / sdh Specific implementation 2:
[0077] If there is a disk array card, you can build a disk array on it. Suppose you build a disk array on it, for example, a disk array of two hard disks. Assuming the hard disks of the disk array are / dev / scsi / sdd and / dev / scsi / sdf, then after sorting, you can see the following link in the / dev / scsi directory:
[0078] / dev / scsi / sda
[0079] / dev / scsi / sdb
[0080] / dev / scsi / sdc
[0081] / dev / scsi / sde
[0082] / dev / scsi / sdg
[0083] / dev / scsi / sdh
[0084] / dev / scsi / sdx
[0085] Among them, / dev / scsi / sdx is the symbolic link of the disk array. The disk array card occupies the resources of Phy3, and Phy5 is not connected to any storage device. At this time, operating / dev / scsi / sdx can operate the disk array. The specific sorting relationship can be shown in Table 2:
[0086] Table 2
[0087] Phy0: / dev / scsi / sda Phy2: / dev / scsi / sdc Phy4: / dev / scsi / sde Phy6: / dev / scsi / sdg Phy1: / dev / scsi / sdb Phy3: / dev / scsi / sdx Phy7: / dev / scsi / sdh Specific implementation 3:
[0089] The disk array card can be used as two sets of disk arrays. Assume that the two hard disks at / dev / scsi / sdc and / dev / scsi / sdd are used as the disk array and named sdx, and / dev / scsi / sde, / dev / scsi / sdf, / dev / scsi / sdg, and / dev / scsi / sdh are used as the disk array and named sdy. The disk array card corresponding to sdx occupies the resources of Phy2, and the disk array card corresponding to sdy occupies the resources of Phy4. After sorting, you can see the following in the / dev / scsi directory:
[0090] / dev / scsi / sda
[0091] / dev / scsi / sdb
[0092] / dev / scsi / sdx
[0093] / dev / scsi / sdy
[0094] The specific sorting relationship can be shown in Table 3:
[0095] Table 3
[0096] Phy0: / dev / scsi / sda Phy2: / dev / scsi / sdx Phy4: / dev / scsi / sdy Phy1: / dev / scsi / sdb Specific implementation 4:
[0098] In the absence of a disk array card, multiple hard disks are sorted as shown in Table 1 below. The script does not modify the device description in the / dev directory, but only determines the fixed order of symbolic links in the / dev / scsi directory according to the occupation relationship of the driver protocol resources. Partitioning, formatting or mounting operations such as link files in the / dev / scsi directory will operate on the specified hard disk. When the hard disk is plugged in or out, the / dev / scsi will display whether the hard disk exists and the order of the hard disk. In this embodiment, the correspondence between Phy0-Phy7 and sda-sdh does not need to be in order, and can be in a random order. See Table 4 for details:
[0099] Table 4
[0100] Phy0: / dev / scsi / sdc Phy2: / dev / scsi / sde Phy4: / dev / scsi / sdb Phy6: / dev / scsi / sdf Phy1: / dev / scsi / sdg Phy3: / dev / scsi / sda Phy5: / dev / scsi / sdh Phy7: / dev / scsi / sdd
[0101] Those skilled in the art can understand that all or part of the processes in the above method embodiments can be implemented by instructing related hardware through a computer program, and the program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes in the above method embodiments. The storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.
[0102] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A storage device sorting method, characterized in that: include: Obtaining a device event corresponding to the first storage device; Search for the predetermined rule file in the rule file directory; When the predetermined rule file exists, Obtaining slot resource information or drive protocol resource information corresponding to the first storage device to determine a mapping target; According to the predetermined rule file, under a first predetermined path, processing a first symbolic link corresponding to the mapping target; Wherein, in the first predetermined path, processing the first symbolic link corresponding to the mapping target includes: keeping the device name in the default directory unchanged, and creating a symbolic link in the new directory.
2. The storage device sorting method according to claim 1, characterized in that: When the device event is a device deletion event; Processing the first symbolic link corresponding to the mapping target includes: deleting the first symbolic link; When a device event adds an event to a device; Processing a first symbolic link corresponding to the mapping target includes: establishing the first symbolic link.
3. The storage device sorting method according to claim 1, characterized in that: When the predetermined rule file does not exist, the second symbolic link corresponding to the first storage device is processed according to the default rule in the second predetermined path.
4. The storage device sorting method according to claim 3, characterized in that: When the device event is a device deletion event; Processing the second symbolic link corresponding to the first storage device includes: deleting the second symbolic link corresponding to the first storage device according to a default rule, and updating the symbolic link corresponding to the storage device other than the first storage device; When a device event adds an event to a device; Processing the second symbolic link corresponding to the first storage device includes: establishing the second symbolic link corresponding to the first storage device according to a default rule.
5. The storage device sorting method according to claim 1, characterized in that: Searching for predefined rule files in the rule file directory includes: According to one or more key-value pairs of the first storage device, a predetermined rule corresponding to the device addition event is matched; When more than one key-value pair is the same as the key-value pair in the rule file, determining the corresponding rule file as a predetermined rule; When more than one key-value pair is different from the key-value pairs in the rule file, it is determined that the predetermined rule file does not exist.
6. The storage device sorting method according to claim 1, characterized in that: Also includes: Partitioning, formatting or mounting the first symbolic link, or hot-plugging the first storage device; The log file corresponding to the partitioning, formatting, mounting or hot-plugging operation is queried to verify whether the predetermined rule is effective.
7. The storage device sorting method according to claim 1, characterized in that: Also includes: The predetermined rule file is stored in a storage path of the rule file, and the predetermined rule file is configured to be in a boot-up automatic startup state.
8. The storage device sorting method according to claim 1, characterized in that: When the predetermined rule file exists, the device type of the first storage device is obtained, and the slot resource information or the drive protocol resource information corresponding to the first storage device is obtained according to the device type of the first storage device to determine the mapping target.
9. The storage device sorting method according to claim 8, characterized in that: When the device type of the first storage device is a disk array card, the disk array card is communicatively connected with a plurality of hard disks; Obtain the slot resource information or driver protocol resource information corresponding to the disk array card to determine the mapping target.
10. The storage device sorting method according to claim 9, characterized in that: When the device type of the first storage device is a hard disk; Obtain the slot resource information or drive protocol resource information corresponding to the hard disk to determine the mapping target.
