CN-117472272-B - Method and terminal for formatting magnetic disk
Abstract
The invention provides a method for formatting a disk and a terminal, which are used for storing key data through a preset initial configuration space, so that a bootstrap program can directly find the key data in the initial configuration space without entering an operating system, and the key data of the terminal can be obtained in a bootstrap stage when the terminal is formatted in batches. In addition, before the disk is formatted, key data is written into the memory for backup, so that the key data is prevented from being lost during formatting, and the key data of the terminal is still stored after the disk is formatted.
Inventors
- ZHANG HUI
- CHEN MIN
- FENG CHONG
Assignees
- 福建升腾资讯有限公司
Dates
- Publication Date
- 20260512
- Application Date
- 20230912
Claims (4)
- 1. A method of formatting a disk, comprising: presetting an initial configuration space, wherein the initial configuration space comprises key data; judging whether a formatting command is received, if so, storing the key data to a memory, and then executing formatting; The performing formatting includes: obtaining disk information of a source disk, and calculating the size of a disk space according to the disk information; carrying out emptying treatment on the data in the source disk through address position offset according to the size of the disk space to obtain a new disk; creating a current custom file system partition in the new disk according to the disk information; Creating a current configuration space in the current custom file system partition; acquiring the key data from the memory, and storing the key data to the current configuration space through address position offset; The preset initial configuration space comprises: acquiring a new formatted disk; Creating an initial custom file system partition in the new disk; Creating an initial configuration space in the initial custom file system partition; Acquiring key data, and storing the key data into the initial configuration space; The pre-setting the initial configuration space comprises the following steps: acquiring header information of a current file system partition; judging whether the current file system partition is a custom file system partition according to the header information, if so, executing the step of judging whether a formatting command is received or not, otherwise, executing the step of presetting an initial configuration space; The custom file system partitions include an initial custom file system partition and a current custom file system partition.
- 2. The method of claim 1, wherein the obtaining key data and storing the key data in the initial configuration space comprises: and loading an operating system, calling key data through the operating system, and storing the key data into the initial configuration space through address position offset.
- 3. A formatted disc terminal comprising a memory, a processor and a computer program stored on said memory and running on said processor, wherein said processor when executing said computer program performs the steps of: presetting an initial configuration space, wherein the initial configuration space comprises key data; judging whether a formatting command is received, if so, storing the key data to a memory, and then executing formatting; The performing formatting includes: obtaining disk information of a source disk, and calculating the size of a disk space according to the disk information; carrying out emptying treatment on the data in the source disk through address position offset according to the size of the disk space to obtain a new disk; creating a current custom file system partition in the new disk according to the disk information; Creating a current configuration space in the current custom file system partition; acquiring the key data from the memory, and storing the key data to the current configuration space through address position offset; The preset initial configuration space comprises: acquiring a new formatted disk; Creating an initial custom file system partition in the new disk; Creating an initial configuration space in the initial custom file system partition; Acquiring key data, and storing the key data into the initial configuration space; The pre-setting the initial configuration space comprises the following steps: acquiring header information of a current file system partition; judging whether the current file system partition is a custom file system partition according to the header information, if so, executing the step of judging whether a formatting command is received or not, otherwise, executing the step of presetting an initial configuration space; The custom file system partitions include an initial custom file system partition and a current custom file system partition.
- 4. A formatted disc terminal according to claim 3, wherein the obtaining key data and storing the key data in the initial configuration space comprises: and loading an operating system, calling key data through the operating system, and storing the key data into the initial configuration space through address position offset.
Description
Method and terminal for formatting magnetic disk Technical Field The present invention relates to the field of formatting technologies, and in particular, to a method and a terminal for formatting a disk. Background The VOI is an infrastructure for centralized storage and distributed operation of images, and the working mode is that template images are stored at a server side, and a desktop is operated on a client. After the client is started through iPXE network, the boot file is obtained first, then the boot program is started to connect to ISCSI equipment at the server end, and then the server end loads the operating system to the local so that the local computer can be used normally. In the current VOI scene, the server can realize batch operation on all terminals, such as unified cache mirroring, batch formatting of terminals, unified startup and shutdown, and the like. But critical configuration information such as IP (Internet Protocol Address, internet protocol) addresses, subnet masks, gateway addresses, domain name addresses, and server addresses need to be maintained when formatting the terminals in bulk. Since many companies or schools now use fixed IP addresses, the MAC (MEDIA ACCESS Control, medium access Control, also called physical address) address of each terminal has and corresponds to a fixed IP address. At present, the cloud computer technology is based on iPXE frames as a director, so that an IP address is required to be configured for server communication in a booting stage. However, the fixed IP information cannot be stored in the boot stage, if the next time the terminal is started, it is necessary to store the IP configuration information in the form of file data and then obtain the fixed IP configuration information in the form of reading the file. However, conventional file systems, such as NTFS file system and FAT32 file system, need to be loaded after entering the operating system, so the data in the file system cannot be read in the boot phase. The conventional disk formatting method is that a PE disk (Windows Pe system installed in a U disk) is used to enter the PE system, and then a disk management tool is used to perform disk formatting operation. Or using the disk operating system DOS (Disk Operation System) to call the Format command to Format the disk. The method can also directly enter a Windows system, and a disk management tool is used for formatting the disk. With the above method of formatting the disk, the format of the file system will generally default to NTFS format after formatting the disk. Disclosure of Invention The invention aims to solve the technical problem of providing a disk formatting method and a terminal, which can always store key data information of the existing terminal when the terminals are formatted in batches. In order to solve the technical problems, the invention adopts the following technical scheme: A method of formatting a disk, comprising: presetting an initial configuration space, wherein the initial configuration space comprises key data; Judging whether a formatting command is received, if so, storing the key data into a memory, and executing formatting. In order to solve the technical problems, the invention adopts another technical scheme that: A stylized disk terminal comprising a memory, a processor, and a computer program stored on the memory and running on the processor, the processor implementing the following steps when executing the computer program: presetting an initial configuration space, wherein the initial configuration space comprises key data; Judging whether a formatting command is received, if so, storing the key data into a memory, and executing formatting. The method has the advantages that the key data is stored through the preset initial configuration space, so that the bootstrap program can directly find the key data in the initial configuration space without entering an operating system, and the key data of the terminal can be obtained in a bootstrap stage when the terminal is formatted in batches. In addition, before the disk is formatted, key data is written into the memory for backup, so that the key data is prevented from being lost during formatting, and the key data of the terminal is still stored after the disk is formatted. Drawings FIG. 1 is a flowchart illustrating steps of a method for formatting a disk according to an embodiment of the present invention; FIG. 2 is a schematic diagram of a relationship between a partition of a custom file system and a disk according to an embodiment of the present invention; FIG. 3 is a schematic diagram of an address of a partition of a disk according to an embodiment of the present invention; Fig. 4 is a schematic program framework of a server and a terminal according to an embodiment of the present invention; FIG. 5 is a program flow chart of a method for formatting a disk according to an embodiment of the present invention; FIG. 6 is a schematic structural diag