Disclosure of Invention
The application aims to provide a method, a device and equipment for detecting an external storage medium and the storage medium, so that the external storage medium can be quickly and effectively detected, the detection efficiency is improved, and the production cost is reduced.
In order to solve the technical problem, the application provides the following technical scheme:
a method for detecting an external storage medium is applied to a Baseboard Management Controller (BMC), and comprises the following steps:
in the starting process, searching a first storage medium externally connected with the BMC in a device directory;
if the first storage medium is found to have at least one partition, creating a file system in the first storage medium, and mounting the file system of the first storage medium into a file system of the BMC;
according to a received file generation instruction, creating a target file in a file system of the first storage medium, and writing a test completion character string in the target file;
and if the writing is successful, determining that the initialization of the first storage medium is successful.
In a specific embodiment of the present application, before creating the file system in the first storage medium, the method further includes:
creating at least one partition in the first storage medium if the at least one partition does not exist in the first storage medium.
In one embodiment of the present application, the method further includes:
and if the file system of the first storage medium is not mounted in the file system of the BMC, or the target file cannot be created in the file system of the first storage medium, or the test completion character string cannot be written in the target file, determining that the initialization of the first storage medium fails.
In a specific embodiment of the present application, after determining that the initialization of the first storage medium fails, the method further includes:
and outputting error prompt information corresponding to the failure reason.
In one embodiment of the present application, the method further includes:
determining that a hardware circuit of the first storage medium is not connected if the first storage medium is not found in the device directory.
In one embodiment of the present application, the method further includes:
receiving an initialization information notification instruction aiming at a second storage medium externally connected with the system and sent by a Basic Input Output System (BIOS), wherein the initialization information notification instruction carries initialization information of whether the second storage medium is successfully connected, whether the second storage medium is partitioned, whether the file system of the second storage medium is created or not, and whether the second storage medium supports read-write operation or not;
and storing the initialization information into a setting medium which is not easy to lose.
In one embodiment of the present application, the method further includes:
and outputting the initialization information stored in the setting medium when receiving a state checking instruction of an external storage medium of the system.
The utility model provides an external storage medium detection device, is applied to base plate management controller BMC, external storage medium detection device includes:
the first storage medium searching module is used for searching the first storage medium externally connected with the BMC in the equipment directory in the starting process;
the file system creating and mounting module is used for creating a file system in the first storage medium and mounting the file system of the first storage medium into the file system of the BMC under the condition that the first storage medium is found and at least one partition exists in the first storage medium;
the target file creating and writing module is used for creating a target file in a file system of the first storage medium according to the received file generation instruction and writing a test completion character string in the target file;
and the initialization result determining module is used for determining that the initialization of the first storage medium is successful under the condition that the writing is successful.
An external storage medium detection device, which runs on a Baseboard Management Controller (BMC), comprises:
a memory for storing a computer program;
and the processor is used for realizing the steps of the external storage medium detection method when the computer program is executed.
A computer-readable storage medium, having a computer program stored thereon, which, when executed by a processor, implements the steps of the method for detecting an external storage medium according to any of the above.
By applying the technical scheme provided by the embodiment of the application, in the starting process of the BMC, the first storage medium externally connected with the BMC is searched in the device directory, if the first storage medium is found and has at least one partition, a file system is created in the first storage medium and is mounted in the file system of the BMC, a target file is created in the file system of the first storage medium according to a received file generation instruction, a test completion character string is written in the target file, if the writing is successful, the first storage medium is determined to be successfully initialized, the detection of the first storage medium is completed, the external storage medium is automatically and quickly and effectively detected through the BMC, the detection efficiency can be improved, and the production cost is reduced.
Detailed Description
The core of the application is to provide a method for detecting the external storage medium, the method can be applied to BMC, and the BMC can quickly and effectively detect the external storage medium, so that the detection efficiency can be improved, and the production cost can be reduced.
In order that those skilled in the art will better understand the disclosure, the following detailed description will be given with reference to the accompanying drawings. It is to be understood that the embodiments described are only a few embodiments of the present application and not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
Referring to fig. 1, a flowchart of an implementation of a method for detecting an external storage medium according to an embodiment of the present application is shown, where the method may include the following steps:
s110: in the starting process, a first storage medium externally connected with the BMC is searched in the device directory.
In practical applications, in order to store important management information, a storage medium externally connected to the BMC needs to be added. During the starting process of the BMC, the first storage medium externally connected with the BMC can be searched in the device directory. The device directory may specifically be a/dev directory. The first storage medium may be any storage medium externally connected to the BMC.
It can be understood that, if there is no problem in the hardware connection of the first storage medium externally connected to the BMC, the BMC may find the first storage medium in the device directory and continue to perform the operations of the subsequent steps.
If the BMC does not find the first storage medium in the device directory, the BMC can determine that the hardware circuit of the first storage medium is not connected, and can output corresponding error prompt information to facilitate technicians to check problems in time.
S120: and if the file system is found and at least one partition exists in the first storage medium, creating the file system in the first storage medium, and mounting the file system of the first storage medium into the file system of the BMC.
In the starting process of the BMC, a first storage medium externally connected with the BMC is searched in the device directory, if the first storage medium is searched, whether at least one partition exists in the first storage medium can be further judged, if the partition exists, a file system can be established in the first storage medium, and the file system of the first storage medium is mounted in the file system of the BMC, so that the BMC can further control the first storage medium.
If the first storage medium does not have at least one partition, creating at least one partition in the first storage medium and then performing the operations of the subsequent steps. So as to improve the success rate of the subsequent step operation.
S130: and according to the received file generation instruction, creating a target file in a file system of the first storage medium, and writing a test completion character string in the target file.
In the embodiment of the application, a technician can provide a file generation instruction in advance for use in production detection. The file generation instruction may be an IPMI (Intelligent Platform Management Interface) instruction. The file name that needs to be generated in the storage medium may be specified in the file generation instruction.
After the BMC creates the file system in the first storage medium and mounts the file system of the first storage medium into the file system of the BMC, if a file generation instruction is received, a target file may be created in the file system of the first storage medium according to the file generation instruction. The file name of the created target file is the file name which is specified in the file generation instruction and needs to be generated in the storage medium.
After the target file is created, a test completion string may be further written into the target file, such as "test ok! "character string.
S140: if the writing is successful, it is determined that the first storage medium initialization is successful.
If the first storage medium supports the read-write operation, the BMC writes the test completion character string into the target file, and the writing is successful. If the writing is successful, it may be determined that the first storage medium initialization is successful. The detection of the first storage medium is completed and the first storage medium can be used normally.
By applying the method provided by the embodiment of the application, in the starting process of the BMC, the first storage medium externally connected with the BMC is searched in the device directory, if the first storage medium is found and has at least one partition, a file system is created in the first storage medium and is mounted in the file system of the BMC, a target file is created in the file system of the first storage medium according to a received file generation instruction, a test completion character string is written in the target file, if the writing is successful, the first storage medium is determined to be successfully initialized, the detection of the first storage medium is completed, the external storage medium is automatically and quickly and effectively detected through the BMC, the detection efficiency can be improved, and the production cost is reduced.
In one embodiment of the present application, the method may further comprise the steps of:
if the file system of the first storage medium is not mounted in the file system of the BMC, or the target file cannot be created in the file system of the first storage medium, or the test completion string cannot be successfully written in the target file, it may be determined that the initialization of the first storage medium fails.
In this embodiment of the application, the BMC creates a file system in the first storage medium, mounts the file system of the first storage medium to the file system of the BMC, and if the mounting is not successful, that is, the file system of the first storage medium is not mounted to the file system of the BMC, the operation of the subsequent step cannot be performed, and it can be determined that the initialization of the first storage medium fails.
In addition, the BMC may create the target file in the file system of the first storage medium according to the received file generation instruction, may further determine whether the creation of the target file is successful, and if the creation is not successful, that is, the target file cannot be created in the file system of the first storage medium, may determine that the initialization of the first storage medium is failed.
Furthermore, after the BMC creates the target file in the file system of the first storage medium, if the test completion string cannot be written in the target file, the first storage medium cannot be normally used, and it may be determined that the initialization of the first storage medium fails.
After determining that the first storage medium has failed to be initialized, error prompt information corresponding to a reason for the failure may be output.
The specific failure reason may be that the file system of the first storage medium is not mounted in the file system of the BMC, the target file cannot be created in the file system of the first storage medium, the test completion string cannot be written in the target file, and the like.
Different failure reasons can correspond to different error prompt messages. After determining that the first storage medium has failed to be initialized, error prompt information corresponding to a reason for the failure may be output. Therefore, technicians can conveniently look up the information, and the reason of initialization failure can be quickly known through error prompt information so as to solve the problem as soon as possible. Specifically, the error prompt message may be in the form of an error code.
For convenience of understanding, the embodiment of the present application is described by taking the detection process of the BMC external storage medium shown in fig. 2 as an example, where the detection process is as follows:
the BMC can determine whether a first storage medium exists under the/dev directory in the starting process;
if there is a first storage medium, it may be further determined whether there is at least one partition in the first storage medium, and if there is no first storage medium, an error warning message ERR1 may be output: no hardware devices;
if the first storage medium has at least one partition, it may be further determined whether a file system has been created, and if the first storage medium does not have at least one partition, at least one partition may be created and a file system created;
if the file system is created, the created file system can be mounted to the file system of the BMC, and if the file system is not created, the created file system can be mounted to the file system of the BMC after the file system is created;
after receiving an IPMI command generated by a file sent from the outside, determining whether the created file system is mounted in a file system of the BMC;
if the mount is successful, a target file specified in the File Generation IPMI directive may be created in the created file system and written to "test ok! "character string, if the writing is successful, the initialization of the first storage medium is determined to be successful;
if the created file system is not mounted in the file system of the BMC, outputting an error prompt message ERR 2: the mounting is unsuccessful;
if the target file cannot be created in the created file system, outputting error prompt information ERR 3: files cannot be created;
if "test ok!cannot be written in the destination file! "character string", then output the wrong suggestion message ERR 4: read and write operations are not possible.
In one embodiment of the present application, the method may further comprise the steps of:
the method comprises the following steps: receiving an initialization information informing instruction which is sent by a Basic Input Output System (BIOS) and aims at a second storage medium externally connected with the system, wherein the initialization information informing instruction carries initialization information of whether the second storage medium is successfully connected, whether the second storage medium is partitioned, whether the creation of a file system of the second storage medium is finished, and whether the second storage medium supports read-write operation;
step two: the initialization information is stored in a setting medium that is not easily lost.
For convenience of description, the above two steps are combined for illustration.
In practical applications, the server system often needs to add an external storage medium to store more information. That is, the server may be connected to a storage medium externally. In this case, before the System is started, the System may be started by a BIOS (Basic Input Output System) to perform an initialization operation on the external storage medium of the System. The second storage medium may be any one of the system-external storage media.
The BIOS may look up the second storage medium in the corresponding device directory, and if the second storage medium is found to have at least one partition, may create a file system in the second storage medium. If the second storage medium is not located, it may be determined that the second storage medium has failed the hard-wired connection. If at least one partition does not exist in the searched second storage medium, the operation of creating the file system in the second storage medium may be executed after at least one partition is created in the second storage medium. After the file system is created, the created file system may be mounted to the file system of the system, a designated file may be created, and a preset character string may be written into the designated file.
Through the above operations, the BIOS may obtain initialization information of the second storage medium. The initialization information may include information on whether the second storage medium is successfully connected, whether the second storage medium is partitioned, whether creation of a file system of the second storage medium is completed, whether the second storage medium supports a read-write operation, and the like.
After the BIOS detects the second storage medium externally connected to the system, an initialization information notification instruction may be sent to the BMC, where the initialization information notification instruction may be an IPMI instruction, and carries initialization notification information.
After receiving the initialization information notification instruction, the BMC may store the initialization information in a setting medium that is not easily lost.
And outputting the initialization information stored in the setting medium when receiving a state checking instruction of the system external storage medium.
Therefore, technicians can quickly know the state of the external storage medium of the system.
For convenience of understanding, the embodiment of the present application is described by taking the detection process of the system external storage medium shown in fig. 3 as an example, and the detection process is as follows:
the BMC receives initialization information aiming at a second storage medium externally connected with the system and sent by a BIOS to inform an IPMI instruction;
storing initialization information contained in the IPMI command in an EEPROM (Electrically Erasable Programmable read only memory);
after receiving the externally transmitted state view IPMI command, the initialization information stored in the EEPROM may be output, such as the successful initialization of the second storage medium, ERR 1: no hardware device, ERR 2: unsuccessful mount, ERR 3: file cannot be created, ERR 4: inability to read and write, etc.
According to the embodiment of the application, the detection of the external storage medium is carried out based on the BMC, the labor cost can be effectively saved, the large-scale rapid and stable production is facilitated, and the production efficiency is improved. Moreover, the initialization of the external storage medium can be completed in advance, so that the user can directly use the external storage medium after the server is delivered for use.
Corresponding to the above method embodiment, an embodiment of the present application further provides an external storage medium detection device, which is applied to the BMC, and the external storage medium detection device described below and the external storage medium detection method described above may be referred to in a corresponding manner.
Referring to fig. 4, the apparatus may include the following modules:
the first storage medium searching module 410 is configured to search, in a starting process, a first storage medium externally connected to the BMC in the device directory;
the file system creating and mounting module 420 is configured to create a file system in the first storage medium and mount the file system of the first storage medium into a file system of the BMC when the first storage medium is found and at least one partition exists in the first storage medium;
a target file creating and writing module 430, configured to create a target file in a file system of the first storage medium according to the received file generation instruction, and write a test completion string in the target file;
and an initialization result determining module 440, configured to determine that the initialization of the first storage medium is successful if the writing is successful.
By applying the device provided by the embodiment of the application, in the starting process of the BMC, the first storage medium externally connected with the BMC is searched in the device directory, if the first storage medium is found and has at least one partition, a file system is created in the first storage medium and is mounted in the file system of the BMC, a target file is created in the file system of the first storage medium according to a received file generation instruction, a test completion character string is written in the target file, if the writing is successful, the first storage medium is determined to be successfully initialized, the detection of the first storage medium is completed, the external storage medium is automatically and quickly and effectively detected through the BMC, the detection efficiency can be improved, and the production cost is reduced.
In a specific embodiment of the present application, the system further includes a partitioning module, configured to:
before creating the file system in the first storage medium, if the first storage medium does not have at least one partition, creating at least one partition in the first storage medium.
In a specific embodiment of the present application, the initialization result determining module 440 is further configured to:
if the file system of the first storage medium is not mounted in the file system of the BMC, or the target file cannot be created in the file system of the first storage medium, or the test completion character string cannot be written in the target file, it is determined that the initialization of the first storage medium fails.
In a specific embodiment of the present application, the system further includes an error prompt information output module, configured to:
after determining that the first storage medium has failed to be initialized, outputting error prompt information corresponding to the reason of the failure.
In a specific embodiment of the present application, the apparatus further includes a hardware connection determining module, configured to:
if the first storage medium is not found in the device directory, determining that the hardware circuit of the first storage medium is not connected.
In one embodiment of the present application, the method further includes:
the initialization information acquisition module is used for receiving an initialization information informing instruction which is sent by a Basic Input Output System (BIOS) and aims at a second storage medium externally connected with the system, wherein the initialization information informing instruction carries initialization information about whether the second storage medium is successfully connected, whether the second storage medium is partitioned, whether the creation of a file system of the second storage medium is finished, and whether the second storage medium supports read-write operation;
and the initialization information storage module is used for storing the initialization information into a setting medium which is not easy to lose.
In a specific embodiment of the present application, the system further includes an initialization information output module, configured to:
and outputting the initialization information stored in the setting medium when receiving a state checking instruction of the system external storage medium.
Corresponding to the above method embodiment, an embodiment of the present application further provides an external storage medium detection device, including:
a memory for storing a computer program;
and the processor is used for realizing the steps of the external storage medium detection method when executing the computer program.
As shown in fig. 5, which is a schematic view of a composition structure of an external storage medium detection device, the external storage medium detection device may include: a processor 10, a memory 11, a communication interface 12 and a communication bus 13. The processor 10, the memory 11 and the communication interface 12 all communicate with each other through a communication bus 13.
In the embodiment of the present application, the processor 10 may be a Central Processing Unit (CPU), an application specific integrated circuit, a digital signal processor, a field programmable gate array or other programmable logic device, etc.
The processor 10 may call a program stored in the memory 11, and in particular, the processor 10 may perform operations in an embodiment of the external storage medium detection method.
The memory 11 is used for storing one or more programs, the program may include program codes, the program codes include computer operation instructions, in this embodiment, the memory 11 stores at least the program for implementing the following functions:
in the starting process, a first storage medium externally connected with the BMC is searched in the equipment directory;
if the first storage medium is found to have at least one partition, creating a file system in the first storage medium, and mounting the file system of the first storage medium into a file system of the BMC;
according to a received file generation instruction, creating a target file in a file system of a first storage medium, and writing a test completion character string in the target file;
if the writing is successful, it is determined that the first storage medium initialization is successful.
In one possible implementation, the memory 11 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application program required by at least one function (such as a file creation function, a data read/write function), and the like; the storage data area may store data created during use, such as initialization data.
Further, the memory 11 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device or other volatile solid state storage device.
The communication interface 12 may be an interface of a communication module for connecting with other devices or systems.
Of course, it should be noted that the structure shown in fig. 5 does not constitute a limitation to the external storage medium detection device in the embodiment of the present application, and in practical applications, the external storage medium detection device may include more or less components than those shown in fig. 5, or some components in combination.
Corresponding to the above method embodiments, the present application further provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the steps of the external storage medium detection method are implemented.
The embodiments are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same or similar parts among the embodiments are referred to each other.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative components and steps have been described above generally in terms of their functionality in order to clearly illustrate this interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module may reside in Random Access Memory (RAM), memory, Read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
The principle and the implementation of the present application are explained in the present application by using specific examples, and the above description of the embodiments is only used to help understanding the technical solution and the core idea of the present application. It should be noted that, for those skilled in the art, it is possible to make several improvements and modifications to the present application without departing from the principle of the present application, and such improvements and modifications also fall within the scope of the claims of the present application.