Disk symbol adjustment method, electronic device, and storage medium

CN117785017BActive Publication Date: 2026-10-27FULIAN PRESION ELECTRONICS (TIANJIN) CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202211158741.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-22
Publication Date
2026-10-27
Estimated Expiration
2042-09-22

AI Technical Summary

Technical Problem

操作人员或系统无法根据原有盘符对发生盘符漂移的硬盘内的文件进行查找或调用,存在使用不便的缺陷

Benefits of technology

[0015]本申请实现方式提供的盘符调整方法、电子设备及存储介质,可以在出现盘符漂移的情况时调整硬盘的盘符为槽位盘符,减少由于盘符漂移情况而导致的无法根据原有盘符对动作硬盘内的文件进行查找或调用的情况,提高对硬盘内文件查找和调用的方便性。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117785017B_ABST
    Figure CN117785017B_ABST
Patent Text Reader

Abstract

The application provides a disk symbol adjustment method, an electronic device and a storage medium, which are used for adjusting the disk symbol of a hard disk. The disk symbol adjustment method comprises the following steps: in response to an action hard disk, acquiring the system disk symbol of the action hard disk; identifying the plug-in position of the action hard disk; in response to the action hard disk being plugged into an expansion slot, acquiring the slot value corresponding to the action hard disk; and modifying the system disk symbol of the action hard disk into a slot disk symbol according to the slot value. Through the disk symbol adjustment method, the electronic device and the storage medium provided by the application, the disk symbol of the hard disk can be adjusted into the slot disk symbol in the case of disk symbol drift, the case that the file in the action hard disk cannot be searched or called according to the original disk symbol due to the disk symbol drift is reduced, and the convenience of searching and calling the file in the hard disk is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and more specifically to a method for adjusting drive letters, an electronic device, and a storage medium. Background Technology

[0002] In the server field, servers or computers have multiple hard drives for data storage. Servers or computers can have multiple drive bays, and multiple hard drives can be connected to multiple drive bays. The server or computer's processor can assign drive letters to the multiple hard drives connected to the drive bays according to preset rules. For example, when the processor is running a Linux system, drive letters such as sda, sdb, and sdc can be assigned to multiple hard drives. When an operator needs to read a file stored on a specific hard drive, or when the system needs to retrieve a file stored on a specific hard drive, it can obtain the file directory of the corresponding hard drive based on the drive letter and then retrieve the corresponding file from the directory.

[0003] Currently, when hard drives are hot-swapped from their slots, the system may not assign drive letters according to preset rules, resulting in drive letter drift. Operators or the system cannot find or access files on the hard drive with the drifted drive letter based on the original drive letter, causing inconvenience. Summary of the Invention

[0004] In view of the above, it is necessary to provide a drive letter adjustment method, electronic device and storage medium that can improve the convenience of searching and accessing files on the hard drive by obtaining the hot-swapped hard drive after it has been hot-swapped.

[0005] In a first aspect, embodiments of this application provide a drive letter adjustment method for adjusting the drive letter of a hard drive. The drive letter adjustment method includes: in response to an identified active hard drive, obtaining the system drive letter of the active hard drive; identifying the insertion position of the active hard drive; in response to the active hard drive being inserted into an expansion slot, obtaining the slot value corresponding to the active hard drive; and modifying the system drive letter of the active hard drive to the slot drive letter according to the slot value.

[0006] Optionally, identifying the insertion position of the active hard drive includes: determining whether the driver corresponding to the active hard drive is the driver for the expansion device, wherein the expansion device is provided with an expansion slot; in response to the driver corresponding to the active hard drive being the driver for the expansion device, obtaining the insertion position of the active hard drive as the expansion slot.

[0007] Optionally, obtaining the insertion position of the active hard disk includes: in response to the fact that the driver corresponding to the active hard disk is not the driver of the expansion device, obtaining the insertion position of the active hard disk as the main slot.

[0008] Optionally, determining whether the driver corresponding to the active hard drive is the driver for the expansion device includes: obtaining the driver name corresponding to the expansion device, wherein the driver name is the name of the driver; determining whether the identification information corresponding to the active hard drive is the same as the driver name, wherein the identification information is information in a preset position in the hardware information of the active hard drive; and determining that the driver corresponding to the active hard drive is the driver for the expansion device in response to the identification information being the same as the driver name.

[0009] Optionally, determining whether the driver corresponding to the active hard drive is the driver for the expansion device includes: obtaining multiple driver names corresponding to multiple expansion devices, wherein the multiple driver names are names of multiple drivers, and the number of drivers is greater than or equal to two; sequentially determining whether the identification information corresponding to the active hard drive is the same as the multiple driver names, wherein the identification information is information in a preset position in the hardware information of the active hard drive; and in response to the identification information being the same as a driver name, determining that the driver corresponding to the active hard drive is the driver for the expansion device.

[0010] Optionally, the method for determining whether the identification information is the same as the driver name includes: generating a driver string based on the driver name; obtaining partial information in hardware information that includes the driver name; obtaining information located at a preset position in the partial information as the identification information; and determining that the identification information is the same as the driver name in response to the fact that the content of the driver string is the same as the content of the identification information.

[0011] Optionally, the system drive letter includes a first symbol portion and a second symbol portion, the first symbol portion of multiple system drive letters is the same, and the second symbol portion of multiple system drive letters is different. Modifying the system drive letter of the active hard disk to a slot drive letter according to the slot value includes: in response to the active hard disk not including a partition, replacing the second symbol portion with the slot value to generate the slot drive letter.

[0012] Optionally, the second symbol portion includes a hard disk symbol portion and a partition symbol portion, wherein the plurality of hard disk symbol portions correspond to a plurality of hard disks, and the plurality of partition symbol portions correspond to a plurality of partitions in the hard disks. The step of modifying the system drive letter of the active hard disk to a slot drive letter according to the slot value includes: in response to the active hard disk including a partition, obtaining the partition value; replacing the hard disk symbol portion with the slot value, and modifying the partition symbol portion according to a preset format and the partition value to generate the slot drive letter.

[0013] Secondly, embodiments of this application provide an electronic device, including: a memory for storing a computer program; and a processor for executing the computer program stored in the memory, wherein when the computer program is executed, the processor is configured to execute the drive letter adjustment method as described in any of the preceding claims.

[0014] Thirdly, embodiments of this application provide a storage medium including a computer program that, when run on an electronic device, causes the electronic device to perform the drive letter adjustment method as described in any of the preceding claims.

[0015] The drive letter adjustment method, electronic device, and storage medium provided in this application can adjust the hard drive letter to the slot drive letter when drive letter drift occurs, reducing the situation where files in the hard drive cannot be searched or retrieved based on the original drive letter due to drive letter drift, and improving the convenience of searching and retrieving files in the hard drive. Attached Figure Description

[0016] Figure 1 This is a schematic diagram of the structure of the electronic device in the embodiments of this application.

[0017] Figure 2 This is a flowchart of the drive letter adjustment method in the embodiments of this application.

[0018] Figure 3 This is another flowchart of the drive letter adjustment method in the embodiments of this application.

[0019] Figure 4 This is another flowchart of the drive letter adjustment method in the embodiments of this application.

[0020] Figure 5 This is another flowchart of the drive letter adjustment method in the embodiments of this application.

[0021] Figure 6 This is another flowchart of the drive letter adjustment method in the embodiments of this application.

[0022] Explanation of main component symbols

[0023] Electronic devices 100

[0024] Processor 10

[0025] Memory 20

[0026] Computer Program 21

[0027] Body device 30

[0028] Expansion device 40 Detailed Implementation

[0029] The technical solutions in the implementation of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described implementation is only a part of the implementation of this application, and not all of the implementations.

[0030] Please see Figure 1 , Figure 1 This is a schematic diagram of an electronic device 100 provided in one embodiment of this application. It can be understood that the electronic device 100 can perform a drive letter adjustment method to adjust the drive letter of the hard drive when drive letter drift occurs in the electronic device 100 due to hot-swapping of the hard drive.

[0031] In this embodiment, the electronic device 100 may include a processor 10, a memory 20, a main body device 30, and an expansion device 40. The processor 10, memory 20, main body device 30, and expansion device 40 can be connected via a communication bus and communicate with each other.

[0032] Processor 10 may be a general-purpose central processing unit (CPU), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits used to control the execution of the above scheme program.

[0033] The memory 20 may be a read-only memory (ROM) or other type of static storage device capable of storing static information and instructions, random access memory (RAM) or other type of dynamic storage device capable of storing information and instructions, or electrically erasable programmable read-only memory (EEPROM), compact disc read-only memory (CD-ROM) or other optical disc storage, optical disc storage (including compressed optical discs, laser discs, optical discs, digital universal optical discs, Blu-ray discs, etc.), magnetic disk storage media or other magnetic storage devices, or any other medium capable of carrying or storing desired program code in the form of instructions or data structures and accessible by a computer, but not limited thereto. The memory 20 may exist independently and be connected to the processor 10 via a bus. The memory 20 may also be integrated with the processor 10.

[0034] The processor 10, memory 20, and expansion device 40 are all mounted on the main unit 30. The expansion device 40 has multiple expansion slots for connecting hard drives. The main unit 30 has at least one main unit slot for connecting hard drives.

[0035] It is understandable that hard drives can be connected to both the main unit slot and the expansion device 40 simultaneously. The hard drive connected to the main unit slot can store the operating programs of the electronic device 100's operating system. The hard drive connected to the expansion slot can store files that the operator needs to view, scripts that the operating system needs to call, etc.

[0036] For example, electronic device 100 can be a server, main unit 30 can be the server's motherboard, processor 10 can be the server's CPU, memory 20 can be a hard drive plugged into the main unit slot and the server's memory module, and expansion device 40 can be a host bus adapter (HBA) and its accessories installed on the server's motherboard.

[0037] It is understandable that electronic device 100 can have multiple hard drives. After the server system is running, the system can assign multiple system drive letters to the multiple hard drives according to preset rules. Operators can use the system drive letter to find the corresponding directory on the hard drive to find or retrieve specific files on the hard drive. The server can also retrieve files from a specified hard drive using the system drive letter when running programs.

[0038] For example, the server could be a Linux system, which assigns system drive letters based on the order in which the hard drives are scanned. System drive letters can be sda, sdb1, sdb2, ..., sdz, etc., where the order of the letters (a, b, etc.) corresponds to the order in which the system recognizes the multiple hard drives, and the numbers (1, 2, etc.) correspond to the preset partition values ​​for each partition on the hard drive. The server can assign multiple system drive letters to multiple hard drives based on the alphabetical and numerical order of the system drive letters.

[0039] It is understood that a system drive letter can include a first part and a second part. Multiple hard drives correspond to multiple system drive letters, where multiple first parts are the same, and multiple second parts are different. In Linux systems, system drive letters can be sda, sdb1, sdb2, ..., sdz, etc. For example, the first part of the system drive letter sda is sd, and the second part is a; the first part of the system drive letter sdb1 is sd, and the second part is b1.

[0040] As we can understand, drive letter drift occurs when a server or computer fails to assign system drive letters to multiple hard drives in the default order. For example, after a hard drive is hot-swapped, the server or computer may reassign a system drive letter to that drive, causing system drive letter confusion. In cases of drive letter drift, it becomes difficult for the server or computer's operating system and users to access files on a specific hard drive based on the original directory address.

[0041] In the embodiments of this application, the processor 10 can execute a drive letter adjustment method to adjust the drive letter of the hard drive after the hard drive is hot-swapped and the operating system of the electronic device 100 automatically assigns a new system drive letter to the hot-swapped hard drive, so as to reduce the failure of the operating system of the electronic device 100 and the operator to obtain files in the specified hard drive according to the preset directory address.

[0042] Please see Figure 2 In one embodiment, the drive letter adjustment method may include the following steps S21 to S24:

[0043] Step 21: In response to the identified active hard drive, obtain the system drive letter of the active hard drive.

[0044] It can be understood that a working hard disk is a newly added or changed hard disk that the processor 10 recognizes when the electronic device 100 is working. A change of hard disk refers to hot-swapping the same hard disk in an expansion slot or a main slot. When the electronic device 100 starts up or when a hard disk in the electronic device 100 is hot-swapped, the processor 10 can recognize the newly added or hot-swapped hard disk.

[0045] For example, the operating system of electronic device 100 can be a Linux system. The Linux system can monitor the action events of devices in electronic device 100 through the device manager (udev) to manage the device directory under the / dev directory. Device action events can include adding, changing, or removing devices. After monitoring the addition or change of a hard drive, the device manager can assign a system drive letter to the active hard drive and generate a device directory corresponding to the system drive letter under the / dev directory. When a hard drive is added or changed, the device manager can select the first letter from the unassigned letters based on the alphabetical order and use it as the alphabetical part of the system drive letter for the active hard drive. For example, after the Linux system has completed the assignment of system drive letters sda, sdb, and sdc, when the hard drive corresponding to the system drive letter sdc is hot-plugged, the device manager obtains the action event of that hard drive. The hard drive corresponding to the original system drive letter sdc is the active hard drive. The device manager reassigns the system drive letter sdd to the active hard drive, deletes the / dev / sdc directory, and creates the dev / sdd directory.

[0046] In response to Device Manager assigning a system drive letter to the action hard disk, processor 10 can obtain the system drive letter of the action hard disk.

[0047] It is understandable that when electronic device 100 is powered on and working, when device manager recognizes the hard drive that has been plugged into electronic device 100, device manager can identify the recognized hard drive as the hard drive where the new action event occurred, and assign system drive letters to multiple hard drives.

[0048] Step S22: Determine whether the insertion position of the motion hard disk is an expansion slot; if the insertion position of the motion hard disk is an expansion slot, proceed to step S23; if the insertion position of the motion hard disk is a main slot, end the process.

[0049] It is understood that the insertion position can include an expansion slot and a main slot. When the insertion position of the motion hard drive is obtained as an expansion slot, it can be determined that the motion hard drive is inserted into the expansion slot of the expansion device 40. When the insertion position of the motion hard drive is obtained as a main slot, it can be determined that the motion hard drive is inserted into the expansion slot of the expansion device 40.

[0050] It should be noted that in the embodiments of this application, when the insertion position of the active hard disk is in the main slot, the processor 10 does not adjust the system drive letter of the active hard disk, and the drive letter adjustment method ends. After the drive letter adjustment method ends, the processor 10 can continue to perform the drive letter adjustment method on another active hard disk, or wait for the processor 10 to recognize the active hard disk again and then perform the drive letter adjustment method on the recognized active hard disk.

[0051] It is understood that the hard drive in the main slot is used to store the system files of the operating system of the electronic device 100. In the embodiments of this application, the hard drive in the main slot is not hot-swappable. When the electronic device 100 is powered on, the hard drive in the main slot is first recognized by the processor 10 and identified as an active hard drive. After the processor 10 assigns a system disk to the active hard drive in the main slot, the processor 10 determines the insertion position of the active hard drive by executing step S22 and ends the further execution of the disk letter adjustment method for the active hard drive.

[0052] For example, the operating system of electronic device 100 can be a Linux system, and processor 10 can call the system files of the Linux system in memory 20 to run the Linux system. When electronic device 100 is powered on, processor 10 is powered on and can run the Linux system. Processor 10 identifies the active hard drive in the main slot through the device manager and assigns a system drive letter to the active hard drive in the main slot through the device manager. After executing step S22, processor 10 determines that the active hard drive is plugged into the main slot and determines that the active hard drive may be the hard drive storing the system files of the Linux system. Processor 10 does not adjust the system drive letter already assigned to the active hard drive and continues to identify another active hard drive.

[0053] In some embodiments, the method for obtaining the insertion position of the motion hard disk may include: determining whether the driver corresponding to the motion hard disk is the driver of the expansion device 40; in response to the driver corresponding to the motion hard disk being the driver of the expansion device 40, the insertion position of the motion hard disk can be determined to be the expansion slot, and proceed to step S23; in response to the driver corresponding to the motion hard disk being the driver of the expansion device 40, the insertion position of the motion hard disk can be determined to be the main body slot, and the process ends.

[0054] It is understandable that when the processor 10 accesses a file or program on the hard disk, it needs to run the driver program of the expansion device 40 or the main device 30 to enable information transfer between the processor 10 and the hard disk. The processor 10 can determine whether the insertion position of the mobile hard disk is an expansion slot or a main slot based on whether the driver program running when the processor 10 identifies the file or program stored in the mobile hard disk is the driver program of the expansion device 40.

[0055] Please see Figure 3 In some embodiments, the brand, model, etc., of the expansion device 40 in the electronic device 100 are known to the operator, and the driver name of the expansion device 40 is known, wherein the driver name is the name of the driver program. The method by which the processor 10 determines whether the driver program corresponding to the active hard disk is the driver program for the expansion device 40 may include the following steps:

[0056] Step S31: Obtain the driver name corresponding to the expansion device 40.

[0057] It is understandable that when the driver name is known, the driver name can be pre-stored in the memory 20, and the processor 10 can obtain the driver name of the expansion device 40 from the memory 20.

[0058] Step S32: Determine whether the identification information corresponding to the action hard disk is the same as the driver name. If the identification information is the same as the driver name, determine that the driver corresponding to the action hard disk is the driver of the expansion device 40, and proceed to step S23. If the identification information is not the same as the driver name, determine that the driver corresponding to the action hard disk is not the driver of the expansion device 40, and end the process.

[0059] It can be understood that the identification information is the information in a preset location within the hardware information of the active hard drive. The processor 10 can obtain the hardware information of the active hard drive through known, open-source instructions. The information in the preset location within the hardware information can be the name of the driver that enables information transfer between the processor 10 and the active hard drive. For example, the operating system of the electronic device 100 can be a Linux system. When the processor 10 is running a Linux system, it can obtain the hardware information of the active hard drive through the udevadm instruction. The preset location can be the second column in the row of information in the hardware information that records the driver name.

[0060] It can be understood that when the driver corresponding to the mobile hard drive is determined to be the driver for the expansion device 40, it can be determined that the processor 10 transmits information to the mobile hard drive through the driver for the expansion device 40, thus determining that the insertion position of the mobile hard drive is the expansion slot. Conversely, it can be determined that the insertion position of the mobile hard drive is the main slot.

[0061] Please see Figure 4 In other embodiments, the various expansion devices 40 have various different drivers, and each of the various different drivers corresponds to a different driver name. The brand, model, and other information of the expansion devices 40 in the electronic device 100 are unknown to the operator, and the driver names of the expansion devices 40 are also unknown to the operator. The method by which the processor 10 determines whether the driver corresponding to the active hard disk is the driver for the expansion device 40 may include the following steps S41 and S42:

[0062] Step S41: Obtain multiple driver names corresponding to multiple expansion devices 40.

[0063] Step S42: Sequentially determine whether the identification information corresponding to the action hard disk is the same as multiple driver names. If the identification information is the same as a driver name, determine that the driver corresponding to the action hard disk is the driver of the expansion device 40, and proceed to step S23. If the identification information is different from multiple driver names, determine that the driver corresponding to the action hard disk is the driver of the main device 30, and end the process.

[0064] Understandably, when the operator is unaware of the driver name for the expansion device 40, the processor 10 can obtain the driver names corresponding to various expansion devices 40 compatible with the electronic device 100, and compare the identification information with each of the multiple driver names. When a driver name matches the identification information, it can be determined that the insertion position of the mobile hard drive is an expansion slot, and the brand, model, and other information of the expansion device 40 can also be determined based on the driver name. Conversely, it can be determined that the insertion position of the mobile hard drive is the main slot.

[0065] It is understood that the driver names corresponding to the various expansion devices 40 adapted to the electronic device 100 can be stored in the memory 20.

[0066] Please see Figure 5 In some embodiments, the method for determining whether the identification information is the same as the driver name may include the following steps:

[0067] Step S51: Generate a driver string based on the driver name.

[0068] It is understandable that processor 10 can generate one or more driver strings corresponding to one or more driver names based on known driver names.

[0069] For example, processor 10 can execute step S51 by running the code lsi="mpt3sas" and pmc="smartpqi". Here, lsi and pmc are two driver strings. The content "mpt3sas" of driver string lsi is the driver name of the LSI brand host bus adapter driver, and the content "smartpqi"" of driver string pmc is the driver name of the PMC brand host bus adapter driver.

[0070] Step S52: Obtain the hardware information of the action hard disk, including the driver name.

[0071] It is understandable that processor 10 can obtain the hardware information of the motion hard disk through open-source and well-known instructions. When memory 20 stores only one driver name, processor 10 generates a driver string when executing step S51. When processor 10 executes step S52, it searches for information in the hardware information of the motion hard disk that is the same as the driver name in memory 20, and obtains the part of the hardware information that includes the driver name. When memory 20 stores multiple driver names, processor 10 generates multiple driver strings when executing step S51. When processor 10 executes step S52, it sequentially searches for information in the hardware information of the motion hard disk that is the same as multiple driver names, and obtains the part of the hardware information that includes the driver name.

[0072] It is understandable that when the memory 20 stores only one driver name, and the processor 10 cannot find the driver name in the hardware information of the active hard disk, the result of the processor 10 obtaining partial information is empty. When the memory 20 stores multiple driver names, and the processor 10 cannot find any driver name in the hardware information of the active hard disk, the result of the processor 10 obtaining partial information is empty.

[0073] It is understood that some information may be a single line of information in the hardware information that includes the driver name. In the embodiments of this application, when the hardware information contains a driver name, the hardware information includes only one driver name.

[0074] Step S53: Obtain the information located at a preset position from the partial information as identification information.

[0075] It's understandable that the preset position could be a position determined by the staff based on the hardware information format before the drive letter adjustment method is executed. For example, the preset position could be the information located in the second column of a portion of the information.

[0076] It is understandable that the hardware information format of multiple hard drives plugged into the main drive bay and expansion slots can be the same. That is, in the hardware information of the hard drive, the content in the preset position of the driver name in that part of the information is the driver name corresponding to that hard drive. The staff can determine the preset position based on the position of the driver name in the hardware information before running the drive letter adjustment method.

[0077] It is understandable that if the result of obtaining partial information in step S52 is empty, the result of obtaining identification information in step S53 will also be empty.

[0078] For example, processor 10 can execute steps S52 and S53 by running the code `driver=`udevadm info -a / dev / $SD|grepmpt3sas|awk -F'"”{printf$2}'`. The code segment corresponds to the driver name "mpt3sas". The content of "$SD" is the second character in the system drive letter of the active hard disk. When processor 10 executes the instruction corresponding to driver, it can obtain the hardware information of the active hard disk, search for the line containing "mpt3sas" in the hardware information, and retrieve the information in the second column of the line containing "mpt3sas". When the hardware information contains "mpt3sas", processor 10 obtains the identification information "mpt3sas"; when the hardware information does not contain the content name "mpt3sas", processor 10 obtains an empty result.

[0079] Step S54: Determine whether the content of the driver string is the same as the content of the identification information. If the content of the driver string is the same as the content of the identification information, determine that the identification information is the same as the driver name and proceed to step S23. If the content of the driver string is different from the content of the identification information, determine that the identification information is different from the driver name and end the process.

[0080] It is understandable that when the result of obtaining the identification information in step S53 is not empty, the content of the identification information is the driver name, and the content of the identification information is the same as the content of the driver string. When the result of obtaining the identification information in step S53 is empty, the content of the identification information is different from the content of the driver string.

[0081] It can be understood that when the memory 20 stores M driver names, the processor 10 executes steps S51 to S53 M times according to the M driver names to generate M identification information. The processor 10 can execute step S54 for each of the M identification information to determine whether the content of the M identification information is the same as the content of the M driver strings. When step S54 is executed M times, the processor 10 can determine whether there is a set of identification information whose content is the same as the content of the driver strings. If so, the processor 10 can determine that the identification information is the same as the driver name; if the content of the M sets of identification information is different from the content of the M driver strings, the processor 10 can determine that the identification information is different from the driver name. Here, M is a positive integer greater than or equal to 2.

[0082] It is understandable that when the identification information is the same as the drive name, the plug-in position of the motion hard disk can be determined as expansion device 40.

[0083] Please refer to the previous document. Figure 2 Step S23: Obtain the slot value corresponding to the hard drive.

[0084] It can be understood that the slot value can be a preset serial number of multiple expansion slots on the expansion device 40. During the manufacturing process, the expansion device 40 can sort the expansion slots in a preset order so that each expansion slot corresponds to a different serial number. For example, the host bus adapter has multiple slots, and the serial numbers of the multiple slots are 0, 1, 2, ..., n, where n is a positive integer.

[0085] It is understandable that processor 10 can obtain the slot position of the expansion slot corresponding to the action hard disk through open-source and well-known instructions.

[0086] For example, in a Linux system, the `lsscsi` command can be used to obtain the slot information corresponding to the active hard disk on the host bus adapter, and the slot position can be obtained from the slot information. For instance, the slot information can be `slot1`, `slot2`, ..., `slotn`, where `n` is a constant. The numerical part `n` in the slot information is the slot value, representing that the slot corresponding to the slot information is the nth expansion slot in expansion device 40.

[0087] Step S24: Modify the system drive letter of the action hard drive to the drive letter of the slot according to the slot value.

[0088] It is understandable that when the electronic device 100 is powered on, after the operating system of the electronic device 100 assigns system drive letters to the multiple hard drives in the electronic device 100, the processor 10 can execute a drive letter adjustment method to change the system drive letters of all hard drives plugged into the expansion slots to the slot drive letters. When a new hard drive is added to the expansion slot or a hard drive in the expansion slot is hot-swapped, the operating system of the electronic device 100 reallocates system drive letters to the active hard drives, and the processor 10 can execute a drive letter adjustment method to change the system drive letters of the active hard drives in the expansion slots to the slot drive letters. Based on this, during the continuous operation of the electronic device 100, the drive letters of the hard drives located in the expansion slots are all slot drive letters. When the operator or the processor 10 retrieves files stored in the hard drives in the expansion slots, they can use the slot drive letter as the directory address to find the files. For example, when the processor 10 is running a Linux system, when the electronic device 100 is powered on or the hard drive in the expansion slot is hot-swapped, the processor 10 obtains the system drive letter of the active hard drive as sdd and the corresponding slot information as slot2, where 2 is the slot value. The processor 10 can then change the system drive letter of the active hard drive from sdd to sd2.

[0089] Please see Figure 6 In some embodiments, the method for modifying the system drive letter to the drive letter based on the slot value may include the following steps:

[0090] Step S61: Determine if the action hard disk has partitions. If the action hard disk has no partitions, proceed to step S62; if the action hard disk has partitions, proceed to step S63.

[0091] It's understandable that a hard drive can contain partitions, and multiple partitions can be used to store different files. The second part of the system drive letter can include both the hard drive part and the partition part; multiple hard drive parts correspond to multiple hard drives. Multiple partition parts correspond to multiple partitions within a single hard drive.

[0092] For example, when processor 10 runs a Linux system, the system drive letter of the active hard disk can be sdd1, sdd2, and sdd3, where sd is the first drive letter, and d1, d2, and d3 are the second drive letters. In the second drive letters d1, d2, and d3, d is the hard disk drive letter, and 1, 2, and 3 are the partition drive letters. The active hard disk contains three partitions.

[0093] It is understandable that processor 10 can view the hard drive's file directory based on the system drive letter, and determine whether the hard drive has a partition by checking if a subdirectory corresponding to the partition exists within that file directory. If a subdirectory corresponding to the partition exists within the hard drive's file directory, then the hard drive has a partition.

[0094] Step S62: Replace the second symbol with the slot value to generate the slot disk symbol.

[0095] It is understandable that when the active hard disk does not have a partition, the processor 10 can delete the second part of the system drive letter corresponding to the active hard disk and fill the slot value into the position of the second part, thereby generating the slot drive letter corresponding to the active hard disk.

[0096] Step S63: Obtain multiple partition values ​​of the action hard disk.

[0097] It is understood that the processor 10 can obtain the number of partitions in the system drive letter and the partition value corresponding to each partition by recognizing the number of system drive letters and partition numbers corresponding to the action hard drive, or by recognizing the names of subdirectories in the file directory of the action hard drive based on the system drive letter.

[0098] For example, in an electronic device 100 running a Linux system, the number of system drive letters corresponding to the active hard disk is 4, namely sdd, sdd1, sdd2, and sdd3. Based on the number of system drive letters, the processor 10 can determine that there are (4-1) partitions in the active hard disk, and the partition values ​​of the three partitions are 1, 2, and 3 respectively.

[0099] Step S64: Replace the hard disk letter with the slot value, and modify the partition letter according to the preset format and partition value to generate the slot drive letter.

[0100] It's understandable that in Linux systems, both slot values ​​and partition numbers are Arabic numerals. To reduce the possibility of multiple Arabic numerals appearing in the slot drive letter, causing the processor or staff to misidentify the slot drive letter, the partition value adjusted according to a preset format can be used to replace the partition number in the generated slot drive letter. This preset format can be a format chosen by the staff before the drive letter adjustment method is run, and it must be different from the format of the partition number.

[0101] For example, in a Linux system, the default format can be p*, where * is the partition value and * is a positive integer greater than 0. For instance, the active hard disk has three system drive letters: sdd1, sdd2, and sdd3. The first part is sd, the hard disk part is d, and the partition parts are 1, 2, and 3. The slot value corresponding to the active hard disk is 0, and the partition values ​​corresponding to the active hard disk's partitions are 1, 2, and 3. After processor 10 executes step S64, the three generated slot drive letters are sd0p1, sd0p2, and sd0p3.

[0102] It is understood that, in the embodiments of this application, the drive letter adjustment method can be run when the electronic device 100 is powered on and when a hard drive hot-swapping occurs in the electronic device 100. When the electronic device 100 is powered on, the processor 10 first identifies multiple hard drives in the electronic device. After the operating system of the electronic device 100 assigns system drive letters to the multiple hard drives, the processor 10 can sequentially acquire the multiple hard drives as active hard drives according to the order in which they are identified, and execute the drive letter adjustment method to adjust the drive letter of the hard drive plugged into the expansion slot to the slot drive letter. Specifically, the order in which the processor 10 identifies the multiple hard drives can be: first reading the hard drives in the main slot, then reading the hard drives in the expansion slot; when multiple hard drives are plugged into multiple main slots, the processor 10 identifies the hard drives in the main slots sequentially according to the preset sequence number of the multiple main slots in ascending order; when multiple hard drives are plugged into multiple expansion slots, the processor 10 identifies the hard drives in the expansion slots sequentially according to the preset sequence number of the multiple expansion slots in ascending order.

[0103] When electronic device 100 is operating and a hard drive in electronic device 100 is hot-swapped, processor 10 can perform a drive letter adjustment method on the active hard drive. When the active hard drive is plugged into an expansion slot, processor 10 can adjust the drive letter of the active hard drive to the slot drive letter. After processor 10 finishes performing the drive letter adjustment method on one active hard drive, the operating system of electronic device 100 continuously monitors the operation time of the hard drives. When another active hard drive is hot-swapped, processor 10 can perform a drive letter adjustment method on the other active hard drive.

[0104] The drive letter adjustment method provided in the embodiments of this application can adjust the system drive letter of the active hard drive to the slot drive letter corresponding to the slot value of the expansion slot to be used when the electronic device 100 is powered on or when a hot-swapping of the active hard drive occurs in the expansion slot. When the operator or processor 10 needs to find or access files in the active hard drive, the directory address corresponding to the active hard drive can be determined through the slot drive letter, and the required file can be searched in the directory. The drive letter adjustment method provided in the embodiments of this application can adjust the hard drive's drive letter to the slot drive letter when drive letter drift occurs, reducing the situation where files in the active hard drive cannot be found or accessed based on the original drive letter due to drive letter drift, and improving the convenience of finding and accessing files in the hard drive.

[0105] Based on the same concept, embodiments of this application also provide a storage medium. The readable storage medium stores a computer program 21, which, when run on the electronic device 100, enables the electronic device 100 to execute the drive letter adjustment method provided in the foregoing embodiments.

[0106] It will be apparent to those skilled in the art that this application is not limited to the details of the exemplary embodiments described above, and that this application can be implemented in other specific forms without departing from the spirit or essential characteristics of this application. Therefore, the embodiments described above should be considered exemplary and non-limiting in all respects, and the scope of this application is defined by the appended claims rather than the foregoing description. Thus, all variations falling within the meaning and scope of equivalents of the claims are intended to be included within this application.

Claims

1. A method for adjusting drive letters, characterized in that, It is applied to electronic devices, which include a main body and an expansion device. The main body has a main body slot, and the expansion device has an expansion slot. The drive letter adjustment method includes: In response to an identified active hard drive, the system drive letter of the active hard drive is obtained. The active hard drive is a newly added or changed hard drive identified when the electronic device is working. The system drive letter includes a first symbol and a second symbol. The first symbol of multiple system drive letters is the same, and the second symbol of multiple system drive letters is different. The second symbol includes a hard drive symbol and a partition symbol. The multiple hard drive symbols correspond to multiple hard drives, and the multiple partition symbols correspond to multiple partitions in the hard drives. In response to the fact that the driver corresponding to the active hard disk is the driver of the expansion device, the insertion position of the active hard disk is obtained as the expansion slot; Obtain the slot value corresponding to the hard drive used in the action; Modifying the system drive letter of the action hard drive to the drive letter of the slot according to the slot value includes: In response to the action that the hard drive does not include the partition, the second character part is replaced with the slot value to generate the slot drive letter; In response to the action, the hard drive includes the partition, the partition value is obtained, the hard drive letter is replaced with the slot value, and the partition letter is modified according to the preset format and the partition value to generate the slot drive letter.

2. The drive letter adjustment method as described in claim 1, characterized in that, The step of obtaining the insertion position of the action hard disk includes: In response to the fact that the driver corresponding to the active hard drive is not the driver of the expansion device, the insertion position of the active hard drive is determined to be the main slot.

3. The drive letter adjustment method as described in claim 1, characterized in that, Determining whether the driver corresponding to the active hard disk is the driver for the expansion device includes: Obtain the driver name corresponding to the expansion device, wherein the driver name is the name of the driver program; Determine whether the identification information corresponding to the action hard disk is the same as the driver name, wherein the identification information is information in a preset position in the hardware information of the action hard disk; In response to the identification information being identical to the driver name, it is determined that the driver corresponding to the active hard drive is the driver for the expansion device.

4. The drive letter adjustment method as described in claim 1, characterized in that, Determining whether the driver corresponding to the active hard disk is the driver for the expansion device includes: Obtain multiple driver names corresponding to multiple expansion devices, wherein the multiple driver names are the names of multiple drivers, and the number of drivers is greater than or equal to two; Sequentially determine whether the identification information corresponding to the action hard disk is the same as multiple driver names, wherein the identification information is information in a preset position in the hardware information of the action hard disk; In response to the identification information being identical to a driver name, it is determined that the driver corresponding to the active hard drive is the driver for the expansion device.

5. The drive letter adjustment method as described in claim 3 or 4, characterized in that, The method for determining whether the identification information is the same as the driver name includes: Generate a driver string based on the driver name; The hardware information obtained includes partial information about the driver name; The identification information is obtained by selecting the information located at a preset position from the partial information. In response to the fact that the content of the driver string is the same as the content of the identification information, it is determined that the identification information is the same as the driver name.

6. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor is configured to execute the computer program stored in the memory, wherein when the computer program is executed, the processor is configured to perform the drive letter adjustment method as described in any one of claims 1 to 5.

7. A storage medium, characterized in that, The storage medium includes a computer program that, when run on an electronic device, causes the electronic device to perform the drive letter adjustment method as described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Method and device for binding disk drive in Linux system

    CN104699423A