System starting method, device and equipment
By creating a target mapping relationship between virtual block devices, memory and startup file system in electronic devices, the inefficiency problem caused by multiple copying and decompressing of system files in the prior art is solved, and a more efficient system startup is achieved.
Patent Information
- Application Number
- CN202311727937.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-14
- Publication Date
- 2025-06-17
AI Technical Summary
When starting the operating system, the prior art requires multiple copies and decompression of the system files, resulting in large time consumption, especially when the device execution speed is slow, it is inefficient.
By creating a target mapping relationship between the virtual block device, memory and startup file system, the memory that stores the startup file system is directly used as the memory corresponding to the virtual block device, avoiding multiple copying and decompression operations.
It improves the efficiency of starting the target system in electronic devices, saves copying and decompression time, and improves the startup speed of the device.
Smart Images

Figure CN120162087A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computers, and in particular, to a system startup method, apparatus, and device. Background Art
[0002] In an electronic device, an operating system can be started to test a chip. Especially in a hardware emulator (Emulator, EMU), since a hard disk device is usually not included in the EMU, when starting the operating system, the system files used usually include a large number of test programs, resulting in large system files, and the execution speed of the EMU device is usually slow.
[0003] In the related art, there are two ways to start the operating system. In the startup method based on a memory-based virtual block device (i.e., the initrd startup method), when starting the operating system, the initrd file needs to be loaded into the memory and copied to a file in a specified directory. Then, the content in the file needs to be decompressed on demand, and the decompressed content is copied to the block device file. Finally, the file system is obtained from the block device file, and the operating system is started based on the file system. In the startup method based on a memory file system (i.e., the initramfs startup method), when starting the operating system, the initramfs file needs to be loaded into the memory and decompressed on demand to obtain the decompressed content. Then, the decompressed content needs to be copied to multiple files in a specified directory, and the operating system can be started based on the multiple files.
[0004] However, in the above two ways, the system files need to be copied and decompressed multiple times. When the system files are large, it takes a long time to copy and decompress the system files, and due to the slow execution speed of the device itself, the efficiency of starting the operating system of the electronic device is low. Summary of the Invention
[0005] Multiple aspects of this application provide a system startup method, apparatus, and device to improve the efficiency of starting a target system.
[0006] In a first aspect, an embodiment of this application provides a system startup method, including:
[0007] In response to a startup instruction of a target system, load a startup file system into the memory of the target system;
[0008] Create a block device file and determine a virtual block device corresponding to the block device file;
[0009] Create a target mapping relationship among the virtual block device, the memory, and the startup file system, and mount the block device file in a target directory of the target system;
[0010] Access the startup file system in the memory through the virtual block device, and start the target system through the startup file system.
[0011] In a possible implementation, creating a block device file includes:
[0012] Obtain a virtual block device identifier and a target file identifier, where the virtual block device identifier is the identifier of the virtual block device;
[0013] Create the block device file according to the virtual block device identifier and the target file identifier, where the file identifier of the block device file is the target file identifier, and the virtual block device identifier is included in the block device file.
[0014] In a possible implementation, mounting the block device file under a target directory of the target system includes:
[0015] Create a root directory in the target system;
[0016] Create a target directory under the root directory of the target system;
[0017] Mount the block device file under the target directory;
[0018] Determine the target directory as the root directory for the target system to start.
[0019] In a possible implementation, creating a target mapping relationship among the virtual block device, the memory, and the startup file system includes:
[0020] Create a first mapping relationship between the virtual block device and the startup file system;
[0021] Create a second mapping relationship between the startup file system and the memory;
[0022] Determine that the target mapping relationship includes the first mapping relationship and the second mapping relationship.
[0023] In a possible implementation, creating a first mapping relationship between the virtual block device and the startup file system includes:
[0024] Determine target sector identifiers corresponding to at least one startup file in the startup file system to obtain at least one target sector identifier;
[0025] Determine the at least one target sector identifier as the at least one target sector identifier corresponding to the virtual block device, so as to create a first mapping relationship between the virtual block device and the startup file system.
[0026] In a possible implementation, creating a second mapping relationship between the startup file system and the memory includes:
[0027] Determining the target sector identifier corresponding to at least one startup file in the startup file system;
[0028] Determining the storage location of at least one startup file in the startup file system in the memory;
[0029] According to each startup file, performing mapping processing on the target sector identifier and the storage location to create a second mapping relationship between the startup file system and the memory.
[0030] In a possible implementation, accessing the startup file system in the memory through the virtual block device includes:
[0031] According to the target mapping relationship, determining the storage location of at least one startup file in the startup file system in the memory;
[0032] According to the storage location, accessing at least one startup file in the startup file system in the memory through the virtual block device.
[0033] In a possible implementation, in response to a startup instruction of the target system, loading the startup file system into the memory of the target system includes:
[0034] In response to the startup instruction, obtaining the startup file system in a preset device;
[0035] Storing the startup file system into the memory of the target system, and using the memory as the memory occupied by the virtual block device.
[0036] In a possible implementation, before obtaining the startup file system in a preset device in response to the startup instruction, the method further includes:
[0037] In response to a creation instruction, creating a target file;
[0038] In response to a conversion instruction, performing format conversion on the target file to obtain an initial startup file system, where there are no startup files in the initial startup file system;
[0039] In response to an addition instruction, adding at least one startup file to the initial startup file system and assigning a target sector identifier to the at least one startup file to obtain the startup file system.
[0040] In a possible implementation, the startup file system is an uncompressed file system supported by the target system.
[0041] In a second aspect, an embodiment of the present application provides a system startup device, including: a loading module, a first creation module, a second creation module, a mounting module, and an access module, where,
[0042] The loading module is configured to load a startup file system into the memory of the target system in response to a startup instruction of the target system;
[0043] The first creation module is configured to create a block device file and determine a virtual block device corresponding to the block device file;
[0044] The second creation module is configured to create a target mapping relationship among the virtual block device, the memory, and the startup file system;
[0045] The mounting module is configured to mount the block device file under a target directory of the target system;
[0046] The access module is configured to access the startup file system in the memory through the virtual block device and start the target system through the startup file system.
[0047] In a possible implementation manner, the first creation module is specifically configured to:
[0048] Obtain a virtual block device identifier and a target file identifier, where the virtual block device identifier is an identifier of the virtual block device;
[0049] Create the block device file according to the virtual block device identifier and the target file identifier, where the file identifier of the block device file is the target file identifier, and the block device file includes the virtual block device identifier.
[0050] In a possible implementation manner, the mounting module is specifically configured to:
[0051] Create a root directory in the target system;
[0052] Create a target directory under the root directory of the target system;
[0053] Mount the block device file under the target directory;
[0054] Determine the target directory as the root directory for the target system to start up.
[0055] In a possible implementation manner, the second creation module is specifically configured to:
[0056] Create a first mapping relationship between the virtual block device and the startup file system;
[0057] Create a second mapping relationship between the startup file system and the memory;
[0058] Determine that the target mapping relationship includes the first mapping relationship and the second mapping relationship.
[0059] In a possible implementation manner, the second creation module is specifically configured to:
[0060] Determine the target sector identifiers corresponding to at least one startup file in the startup file system, and obtain at least one target sector identifier;
[0061] Determine the at least one target sector identifier as the at least one target sector identifier corresponding to the virtual block device, so as to create a first mapping relationship between the virtual block device and the startup file system.
[0062] In a possible implementation manner, the second creation module is specifically configured to:
[0063] Determine the target sector identifiers corresponding to at least one startup file in the startup file system;
[0064] Determine the storage locations of at least one startup file in the startup file system in the memory;
[0065] According to each startup file, perform mapping processing on the target sector identifier and the storage location to create a second mapping relationship between the startup file system and the memory.
[0066] In a possible implementation manner, the access module is specifically configured to:
[0067] According to the target mapping relationship, determine the storage locations of at least one startup file in the startup file system in the memory;
[0068] According to the storage location, access at least one startup file in the startup file system in the memory through the virtual block device.
[0069] In a possible implementation manner, the loading module is specifically configured to:
[0070] In response to a startup instruction, obtain the startup file system in a preset device;
[0071] Store the startup file system in the memory of the target system, and use the memory as the memory occupied by the virtual block device.
[0072] In a third aspect, an embodiment of the present application provides another system startup device, where the system startup device includes: a third creation module, a conversion module, and an addition module, where,
[0073] The third creation module is configured to create a target file in response to a creation instruction;
[0074] The conversion module is configured to perform format conversion on the target file in response to a conversion instruction, to obtain an initial boot file system in which there is no boot file;
[0075] The addition module is configured to add at least one boot file to the initial boot file system and allocate a target sector identifier to the at least one boot file in response to an addition instruction, to obtain the boot file system.
[0076] In a possible implementation manner, the boot file system is an uncompressed file system supported by the target system.
[0077] In a fourth aspect, an embodiment of the present application provides an electronic device, including: a memory and a processor;
[0078] The memory stores computer-executable instructions;
[0079] The processor executes the computer-executable instructions stored in the memory, so that the processor executes the method according to any one of the first aspect.
[0080] In a fifth aspect, an embodiment of the present application provides a computer-readable storage medium, in which computer-executable instructions are stored, and when the computer-executable instructions are executed by a processor, they are used to implement the method according to any one of the first aspect.
[0081] In a sixth aspect, an embodiment of the present application provides a computer program product, including a computer program, and when the computer program is executed by a processor, it implements the method according to any one of the first aspect.
[0082] The embodiments of the present application provide a system startup method, device, and equipment. The electronic device can respond to the startup instruction of the target system, load the startup file system into the memory of the target system, create a block device file, and determine the virtual block device corresponding to the block device file. The electronic device can create a target mapping relationship among the virtual block device, the memory, and the startup file system, and mount the block device file under the target directory of the target system. The electronic device can access the startup file system in the memory through the virtual block device and start the target system through the startup file system. Since a target mapping relationship can be created among the virtual block device, the memory, and the startup file system, and the startup file system in the memory can be accessed through the virtual block device, it is realized that the memory storing the startup file system is directly used as the memory corresponding to the virtual block device. Compared with the prior art, it is not necessary to copy the startup file system multiple times, saving the copy time, and it is not necessary to decompress the startup file system, saving the decompression time, comprehensively improving the efficiency of starting the target system in the electronic device. BRIEF DESCRIPTION OF THE DRAWINGS
[0083] The drawings described herein are used to provide a further understanding of the present application, and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application, and do not constitute an improper limitation of the present application. In the drawings:
[0084] Figure 1 FIG. 9 is a schematic diagram of a scenario provided by an exemplary embodiment of the present application;
[0085] Figure 2 FIG. 13 is a schematic flowchart of a system startup method provided by an exemplary embodiment of the present application;
[0086] Figure 3 FIG. 17 is a schematic structural diagram of a startup file system provided by an exemplary embodiment of the present application;
[0087] Figure 4 FIG. 21 is a schematic diagram of a block device file provided by an exemplary embodiment of the present application;
[0088] Figure 5 FIG. 25 is a schematic flowchart of another system startup method provided by an exemplary embodiment of the present application;
[0089] Figure 6 FIG. 29 is a schematic diagram of the process of a system startup method provided by an exemplary embodiment of the present application;
[0090] Figure 7 FIG. 33 is a schematic structural diagram of a system startup device provided by an exemplary embodiment of the present application;
[0091] Figure 8 FIG. 37 is a schematic structural diagram of another system startup device provided by an exemplary embodiment of the present application;
[0092] Figure 9 A schematic structural diagram of an electronic device provided for an exemplary embodiment of the present application. Detailed implementation manners
[0093] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the present application are all information and data authorized by the user or fully authorized by all parties. And the collection, use, and processing of relevant data need to comply with relevant laws, regulations, and standards, and corresponding operation entrances are provided for the user to choose to authorize or refuse.
[0094] To make the purpose, technical solutions, and advantages of the present application clearer, the technical solutions of the present application will be clearly and completely described below in conjunction with specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.
[0095] Figure 1 A schematic diagram of a scenario provided for an exemplary embodiment of the present application. Please refer to Figure 1 An electronic device may include a memory and a virtual block device.
[0096] A startup file system may be stored in the memory. The startup file system may include at least one startup file, and the at least one startup file may be used to start a target system. For example, the startup file system may be a Fourth extended filesystem (Ext4), and the target system may be an operating system.
[0097] There is a target mapping relationship among the virtual block device, the memory, and the startup file system. The startup file in the startup file system in the memory can be accessed through the virtual block device, and the startup file can be executed to start the target system.
[0098] In the related art, there are two ways to start an operating system. In the startup method based on the virtual block device in memory (i.e., the initrd startup method), when starting the operating system, the initrd file needs to be loaded into memory and copied to a file in a specified directory. Then, the content in this file needs to be decompressed on demand, and the decompressed content is copied to the block device file. Finally, the file system is obtained from the block device file, and the operating system is started based on the file system. In the startup method based on the memory file system (i.e., the initramfs startup method), when starting the operating system, the initramfs file needs to be loaded into memory and decompressed on demand to obtain the decompressed content. Then, the decompressed content needs to be copied to multiple files in a specified directory, and the operating system can be started based on these multiple files.
[0099] However, in the above two methods, the system files need to be copied and decompressed multiple times. When the system files are large, it takes a long time to copy and decompress the system files. Moreover, due to the slow execution speed of the device itself, the efficiency of starting the operating system on the electronic device is low.
[0100] In the embodiments of the present application, a target mapping relationship among the virtual block device, memory, and startup file system can be created. The startup file system in memory can be accessed through the virtual block device, realizing directly using the memory storing the startup file system as the memory corresponding to the virtual block device. Compared with the prior art, there is no need to copy the startup file system multiple times, saving the copy time, and there is no need to decompress the startup file system, saving the decompression time, comprehensively improving the efficiency of starting the target system on the electronic device.
[0101] Next, the technical solutions shown in the present application will be described in detail through specific embodiments. It should be noted that the following several embodiments can exist independently or be combined with each other. For the same or similar content, it will not be repeated in different embodiments.
[0102] Figure 2 The flowchart of a system startup method provided for an exemplary embodiment of the present application is shown. Please refer to Figure 2 The method may include:
[0103] S201. In response to the startup instruction of the target system, load the startup file system into the memory of the target system.
[0104] The execution entity of the embodiments of this application can be an electronic device or a system startup device provided in the electronic device. The system startup device can be implemented by software or a combination of software and hardware. The system startup device can be a processor in the electronic device. For ease of understanding, in the following, the example of the execution entity being an electronic device will be used for illustration.
[0105] The target system can be an operating system.
[0106] The startup file system can include multiple directories, and there can be startup files under the multiple directories. Each startup file can have a corresponding target sector identifier. The startup files can be used to start the target system.
[0107] To avoid spending time decompressing the startup file system during the startup process of the target system, the startup file system can be an uncompressed file system supported by the target system.
[0108] The block driver (Ram block device driver, brd) corresponding to the memory-based virtual block device (ramdisk) can access the startup files in the startup file system through the target sector identifier.
[0109] Next, in combination with Figure 3 , the startup file system will be described.
[0110] Figure 3 It is a schematic structural diagram of a startup file system provided for an exemplary embodiment of this application. Please refer to Figure 3 , the startup file system can include Directory 1, and under Directory 1, there can be Directory 2, Directory 3,.... Under Directory 2, there can be Startup File 1, and the target sector identifier corresponding to Startup File 1 can be Sector Identifier 1; under Directory 3, there can be Startup File 2, and the target sector identifier corresponding to Startup File 2 can be Sector Identifier 2. The electronic device can access the startup files according to the target sector identifier.
[0111] The electronic device can respond to the startup instruction of the target system, obtain the startup file system, and load the startup file system into the memory of the electronic device.
[0112] For example, if the startup instruction is Instruction 1 and the startup file system is the Ext4 file system, the electronic device can respond to Instruction 1, obtain the Ext4 file system, and load the Ext4 file system into the memory of the electronic device.
[0113] S202. Create a block device file and determine the virtual block device corresponding to the block device file.
[0114] A block device refers to a device that stores data in fixed - sized data blocks. A block device can be mapped to a block device file. In the technical solution of this application, a block device file refers to a file corresponding to a virtual block device. The virtual block device can be accessed through the block device file.
[0115] A virtual block device is a block device virtualized based on memory.
[0116] In an optional embodiment, a block device file can be created in the following way: obtain a virtual block device identifier and a target file identifier; create a block device file according to the virtual block device identifier and the target file identifier.
[0117] The virtual block device identifier can be composed of a major device number and a minor device number. The virtual block device identifier can be the identifier of the virtual block device.
[0118] The major device number can be used to represent the device type. For example, if the virtual block device belongs to type 1, and type 1 is represented by "1", then the major device number can be 1.
[0119] The minor device number can be used to represent the unique identifier of the virtual block device in the target system. For example, the minor device number can be 2.
[0120] For example, if the major device number is 1 and the minor device number is 2, then the virtual block device identifier can be "1,2".
[0121] The file identifier of the block device file is the target file identifier. For example, if the target file identifier is / dev / ram0, then the file identifier of the block device file can be / dev / ram0.
[0122] The block device file includes the virtual block device identifier. Optionally, the block device can also include read - write permissions.
[0123] Optionally, the electronic device can, in response to a first creation instruction, obtain the virtual block device identifier and the target file identifier, and create a block device file according to the virtual block device identifier and the target file identifier.
[0124] Next, in combination with Figure 4 , the block device file will be described.
[0125] Figure 4 It is a schematic diagram of a block device file provided for an exemplary embodiment of this application. Please refer to Figure 4, for example, if the first creation instruction is the mknod command, the electronic device can, in response to the mknod command, obtain that the virtual block device identifier is "1,2" and the target file identifier is / dev / ram0, and then can create block device file 1 according to the virtual block device identifier and the target file identifier. The file identifier of block device file 1 can be / dev / ram0, and block device file 1 can include the virtual block device identifier "1,2" and can also include read and write permissions.
[0126] Optionally, the automatic creation of block device files can be implemented through the basic functions of the linux kernel.
[0127] Optionally, after creating the block device file, the virtual block device corresponding to the block device file can be determined. The identifier of the virtual block device is the virtual block device identifier. For example, if block device file 1 is the / dev / ram0 file and the virtual block device identifier included in block device file 1 is "1,2", then the virtual block device 1 corresponding to block device file 1 can be determined, and the identifier of virtual block device 1 can be "1,2".
[0128] S203. Create a target mapping relationship among the virtual block device, the memory, and the startup file system, and mount the block device file in the target directory of the target system.
[0129] Since the startup files in the startup file system have corresponding target sector identifiers, after loading the startup file system into the memory, at least one startup file in the startup file system has different storage locations in the memory. To enable the electronic device to access the startup files in the startup file system through the virtual block device, it is necessary to create a target mapping relationship among the virtual block device, the memory, and the startup file system.
[0130] In an optional embodiment, the mapping relationship among the virtual block device, the memory, and the startup file system can be created in the following manner: create a first mapping relationship between the virtual block device and the startup file system; create a second mapping relationship between the startup file system and the memory; determine that the target mapping relationship includes the first mapping relationship and the second mapping relationship.
[0131] To establish the first mapping relationship between the virtual block device and the startup file system, at least one target sector identifier corresponding to the startup file system can be determined as at least one target sector identifier corresponding to the virtual block device. For example, if the startup file system corresponds to 10 target sector identifiers, which are sector identifier 1, sector identifier 2, sector identifier 3,..., sector identifier 10 respectively, then these 10 target sector identifiers can be determined as the 10 target sector identifiers corresponding to virtual block device 1.
[0132] After establishing the first mapping relationship between the virtual block device and the boot file system, the boot file of the boot file system can be accessed through the target sector identifier corresponding to the virtual block device. However, the boot files in the boot file system are stored in different storage locations in the memory. Therefore, a second mapping relationship between the boot file system and the memory needs to be created in order to determine the corresponding storage location in the memory based on the target sector identifier and obtain the boot file at the storage location.
[0133] Optionally, the storage location of each boot file in the memory can be determined, and the target sector identifier of each boot file in the boot file system can be determined. The storage location and the target sector identifier of each boot file can be mapped to create the second mapping relationship between the boot file system and the memory. For example, if the storage location of boot file 1 is storage location 1 and the target sector identifier of boot file 1 is sector identifier 1, then sector identifier 1 and storage location 1 can be mapped based on boot file 1.
[0134] The electronic device can determine that the target mapping relationship includes the first mapping relationship and the second mapping relationship. The first mapping relationship is used to associate the virtual block device and the boot file system, and the second mapping relationship is used to associate the boot file system and the memory. Therefore, the virtual block device, the boot file system, and the memory can be associated through the first mapping relationship and the second mapping relationship.
[0135] After determining the target mapping relationship, the electronic device can mount the block device file under the target directory of the target system to mount the virtual block device. For example, if block device file 1 is the / dev / ram0 file and block device file 1 corresponds to virtual block device 1, then the / dev / ram0 file can be mounted under the target directory of the target system to mount virtual block device 1.
[0136] S204. Access the boot file system in the memory through the virtual block device and start the target system through the boot file system.
[0137] Optionally, the electronic device can determine the file identifier of the boot file to be accessed, determine the corresponding target sector identifier based on the file identifier, and then determine the storage location identifier based on the target sector identifier. The target boot file can be obtained at the storage location indicated by the storage location identifier.
[0138] For example, if the boot file to be accessed is boot file 1, then based on the identifier of boot file 1, the target sector identifier can be determined as sector identifier 1 in the mapping relationship. Then, based on sector identifier 1 in the second mapping relationship, storage location 1 can be determined. The electronic device can then access boot file 1 at storage location 1 through the virtual block device and start the target system based on boot file 1.
[0139] In an embodiment of the present application, an electronic device may respond to a startup instruction of a target system, load a startup file system into the memory of the target system, create a block device file, and determine a virtual block device corresponding to the block device file. The electronic device may create a target mapping relationship among the virtual block device, the memory, and the startup file system, and mount the block device file under a target directory of the target system. The electronic device may access the startup file system in the memory through the virtual block device and start the target system through the startup file system. Since a target mapping relationship can be created among the virtual block device, the memory, and the startup file system, and the startup file system in the memory can be accessed through the virtual block device, the memory storing the startup file system is directly used as the memory corresponding to the virtual block device. Compared with the prior art, it is not necessary to copy the startup file system multiple times, saving the copy time, and it is not necessary to decompress the startup file system, saving the decompression time, comprehensively improving the efficiency of starting the target system in the electronic device.
[0140] Next, based on the Figure 2 illustrated embodiment, in combination with Figure 5 , the above system startup method will be further described in detail.
[0141] Figure 5 The flowchart of another system startup method provided by an exemplary embodiment of the present application is shown. Please refer to Figure 5 , the method may include:
[0142] S501. In response to a creation instruction, create a target file in a preset device.
[0143] Optionally, the creation instruction may be a dd instruction, and the preset device may respond to the creation instruction to create a target file, and the target file may be an image file (initrd file) of a virtual block device.
[0144] S502. In response to a conversion instruction, perform format conversion on the target file to obtain an initial startup file system.
[0145] There is no startup file in the initial file system, and the initial file system may include multiple directories.
[0146] For example, the conversion instruction may be an mkfs.ext4 instruction. If the target file is an initrd file, the preset device may respond to the mkfs.ext4 command to perform format conversion on the initrd file to obtain an initial startup file system. The initial startup file system may include multiple directories.
[0147] S503. In response to an addition instruction, add at least one startup file to the initial startup file system and assign a target sector identifier to the at least one startup file to obtain a startup file system.
[0148] The initial startup file system may include multiple directories. The preset device may, in response to an addition instruction, add at least one startup file under different directories in the initial startup file system and assign a target sector identifier to the at least one startup file to obtain a startup file system.
[0149] For example, if the initial startup file system includes Directory 1, and Directory 1 includes Directory 2 and Directory 3, the preset device may, in response to addition instruction 1, add startup file 1 under Directory 2 and assign the target sector identifier of sector identifier 1 to startup file 1; it may add startup file 2 under Directory 3 and assign the target sector identifier of sector identifier 2 to startup file 2 to obtain a startup file system as Figure 3 shown.
[0150] Since in the startup file system, each startup file has a corresponding target sector identifier, the startup file system may include a mapping relationship between the file identifier of the startup file and the target sector identifier, and this mapping relationship may exist in the file directory in the startup file system.
[0151] For example, the mapping relationship between the file identifier of the startup file and the target sector identifier may be as shown in Table 1:
[0152] Table 1
[0153] File identifier of the startup file Target sector identifier File identifier 1 Sector identifier 1 File identifier 2 Sector identifier 2 …… ……
[0154] S504. In response to a startup instruction, obtain the startup file system in the preset device.
[0155] In an alternative embodiment, the electronic device and the preset device may be connected by means of a physical bus, and obtain the startup file system in the preset device through the physical bus.
[0156] For example, if the startup instruction is instruction 1 and the startup file system is an Ext4 file system, the electronic device may, in response to instruction 1, obtain the Ext4 file system from the preset device through the physical bus.
[0157] In another alternative embodiment, the electronic device may obtain the startup file system from the preset device through a Boot Loader.
[0158] For example, if the startup instruction is instruction 1 and the startup file system is an Ext4 file system, the electronic device may, in response to instruction 1, obtain the Ext4 file system from the preset device in a BootLoader manner.
[0159] S505. Store the startup file system in the memory of the target system and use the memory as the memory occupied by the virtual block device.
[0160] For example, if the boot file system is the Ext4 file system, the electronic device can store the Ext4 file system in the memory of the target system and use this memory as the memory occupied by the virtual block device 1, that is, the ramdisk memory.
[0161] S506. Create a block device file and determine the virtual block device corresponding to the block device file.
[0162] It should be noted that the execution process of step S506 can refer to step S202 and will not be elaborated here.
[0163] S507. Create a first mapping relationship between the virtual block device and the boot file system.
[0164] In an optional embodiment, the first mapping relationship between the virtual block device and the boot file system can be created in the following manner: determine the target sector identifiers corresponding to at least one boot file in the boot file system to obtain at least one target sector identifier; determine the at least one target sector identifier as the at least one target sector identifier corresponding to the virtual block device to create the first mapping relationship between the virtual block device and the boot file system.
[0165] Since at least one boot file in the boot file system already has a corresponding target sector identifier, the target sector identifiers corresponding to at least one boot file in the boot file system can be determined to obtain at least one target sector identifier. For example, if there are 10 boot files and the corresponding target sector identifiers are sector identifier 1, sector identifier 2, sector identifier 3,..., sector identifier 10 respectively, then 10 target sector identifiers corresponding to the boot file system can be obtained.
[0166] The at least one target sector identifier can be determined as the at least one target sector identifier corresponding to the virtual block device, that is, the virtual block device can be associated with the boot file system to create the first mapping relationship between the virtual block device and the boot file system.
[0167] For example, if the boot file system corresponds to 10 target sector identifiers, then the 10 target sector identifiers can be determined as the 10 target sector identifiers corresponding to the virtual block device 1 to create the first mapping relationship between the virtual block device and the boot file system.
[0168] S508. Create a second mapping relationship between the boot file system and the memory.
[0169] In an alternative embodiment, the second mapping relationship between the startup file system and the memory can be created in the following manner: determine the target sector identifier corresponding to at least one startup file in the startup file system; determine the storage location of at least one startup file in the startup file system in the memory; according to each startup file, map the target sector identifier and the storage location to create the second mapping relationship between the startup file system and the memory.
[0170] For any storage location, the storage location can have a corresponding storage location identifier. For example, the storage location identifier of storage location 1 can be storage location identifier 1.
[0171] The second mapping relationship can include at least one target sector identifier and the target storage location identifier corresponding to each target sector identifier. The second mapping relationship can be as shown in Table 2:
[0172] Table 2
[0173] Target sector identifier Target storage location identifier Sector identifier 1 Storage location identifier 1 Sector identifier 2 Storage location identifier 2 …… ……
[0174] For example, if there are 10 startup files in the startup file system, for startup file 1, determine that the target sector identifier corresponding to startup file 1 is sector identifier 1, and it can be determined that the storage location of startup file 1 in the memory is storage location 1, then according to startup file 1, map sector identifier 1 and storage location 1; similarly, for startup file 2, it can be determined that the target sector identifier corresponding to startup file 2 is sector identifier 2, and determine the storage location of startup file 2 in the memory is storage location 2, then according to startup file 2, map sector identifier 2 and storage location 2;..., then it can be determined that the second mapping relationship includes 10 target sector identifiers and the target storage location identifiers corresponding to each target sector identifier.
[0175] The startup file system and the memory can be associated through the second mapping relationship, so that the electronic device can find the target storage location in the memory through the target sector identifier.
[0176] S509. Determine that the target mapping relationship includes the first mapping relationship and the second mapping relationship.
[0177] S510. Mount the block device file under the target directory of the target system.
[0178] In an alternative embodiment, the block device file can be mounted under the target directory of the target system in the following manner, including: create a root directory in the target system; create a target directory under the root directory of the target system; mount the block device file under the target directory; determine the target directory as the root directory for the target system to start up.
[0179] Optionally, the root directory can be the root directory of rootfs, which is the first directory in the target system and the root of other directories.
[0180] Optionally, the target directory can be determined as the root directory for starting the target system by executing the chroot function.
[0181] For example, the electronic device can create the root directory of rootfs in the target system and create the target directory in rootfs. Assuming the target directory can be Directory 1, if the block device file 1 is the / dev / ram0 file, then the / dev / ram0 file can be mounted under Directory 1, and Directory 1 can be used as the root directory for starting the target system.
[0182] S511. Access the boot file system in memory through a virtual block device and start the target system through the boot file system.
[0183] In an optional embodiment, the boot file system in memory can be accessed through a virtual block device in the following manner: Determine the storage location in memory of at least one boot file in the boot file system according to the target mapping relationship; Access at least one boot file in the boot file system in memory through the virtual block device according to the storage location.
[0184] Optionally, the electronic device can determine the target file identifier of the target boot file to be accessed, and determine the corresponding target sector identifier in the mapping relationship according to the target file identifier. Furthermore, in the second mapping relationship, the storage location identifier can be determined according to the target sector identifier, and the target boot file can be obtained at the storage location indicated by the storage location identifier.
[0185] For example, if the boot file to be accessed is Boot File 1, then according to the identifier of Boot File 1, the target sector identifier can be determined as Sector Identifier 1 in the mapping relationship. Furthermore, according to Sector Identifier 1 in the second mapping relationship, Storage Location 1 can be determined. Then the electronic device can access Boot File 1 at Storage Location 1 through the virtual block device and start the target system according to Boot File 1.
[0186] It should be noted that during the startup process of the target system, the startup parameter keepinitrd needs to be added to avoid releasing the memory occupied by the boot file system during startup, that is, the memory occupied by the virtual block device.
[0187] In an embodiment of the present application, a preset device may create a target file, and in response to a conversion instruction, perform format conversion on the target file to obtain an initial startup file system. The preset device may, in response to an addition instruction, add at least one startup file to the initial startup file system and assign a target sector identifier to the at least one startup file to obtain a startup file system. An electronic device may, in response to a startup instruction, obtain the startup file system in the preset device, store the startup file system in the memory of the target system, and use the memory as the memory occupied by the virtual block device. The electronic device may create a block device file, determine the virtual block device corresponding to the block device file, and create a target mapping relationship among the virtual block device, the memory, and the startup file system. The electronic device may mount the block device file in a target directory of the target system, access the startup file system in the memory through the virtual block device, and start the target system through the startup file system. Since a target mapping relationship can be created among the virtual block device, the memory, and the startup file system, and the startup file system in the memory can be accessed through the virtual block device, it is realized that the memory storing the startup file system is directly used as the memory corresponding to the virtual block device. Compared with the prior art, it is not necessary to copy the startup file system multiple times, saving the copying time, and it is not necessary to decompress the startup file system, saving the decompression time, comprehensively improving the efficiency of starting the target system in the electronic device.
[0188] Next, based on any of the above embodiments, in combination with Figure 6 , the above system startup method will be further described.
[0189] Figure 6 It is a schematic diagram of the process of a system startup method provided by an exemplary embodiment of the present application. Please refer to Figure 6 , including a preset device and an electronic device.
[0190] In step ①, the preset device may, in response to the dd instruction, create an initrd file and perform format conversion processing on the initrd file through the mkfs.ext4 instruction to obtain an initial startup file system. After the format conversion, the initrd file may include the initial startup file system, and the initial startup file system includes multiple directories.
[0191] The preset device can, in response to an addition instruction, add at least one startup file under a directory in the initial startup file system and assign a target sector identifier to each startup file to obtain a startup file system. For example, the preset device can, in response to an addition instruction, add startup file 1 under directory 2 in the initial startup file system and assign the corresponding target sector identifier for startup file 1 as sector identifier 1; add startup file 2 under directory 3 in the initial startup file system and assign the corresponding target sector identifier for startup file 2 as sector identifier 2 to obtain a startup file system.
[0192] In step ②, the electronic device can obtain the startup file system from the preset device, load the startup file system into the memory, and can use the memory as a ramdisk memory.
[0193] In step ③, the electronic device can create block device file 1 as the / dev / ram0 file. The / dev / ram0 file can include virtual block device identifiers 1, 2, and read / write permissions. The electronic device can determine the corresponding virtual block device 1 for block device file 1, and the identifier of virtual block device 1 can be "1, 2".
[0194] In step ④, the electronic device can create a target mapping relationship among the virtual block device, the memory, and the startup file system. Specifically, the electronic device can determine at least one target sector identifier corresponding to the startup file system and determine the at least one target sector identifier as the at least one target sector identifier corresponding to virtual block device 1 to associate the startup file system with the virtual block device to obtain a first mapping relationship. The electronic device can determine at least one storage location in the memory for at least one startup file in the startup file system, and can, according to each startup file, associate the target sector identifier corresponding to the startup file with the storage location to map the startup file system to the memory to obtain a second mapping relationship. The electronic device can determine that the target mapping relationship includes the first mapping relationship and the second mapping relationship.
[0195] In step ⑤, the electronic device can create a root directory of rootfs in the target system and create a target directory under the root directory of the target system. The electronic device can mount block device file 1, i.e., the / dev / ram0 file, under the target directory and, by executing the chroot function, determine the target directory as the root directory for the target system to start up.
[0196] In step ⑥, the electronic device can determine the file identifier of the startup file, and determine the corresponding target sector identifier according to the file identifier. Furthermore, the electronic device can determine the storage location of the startup file in the memory according to the target sector identifier, so as to obtain the startup file at the storage location. For example, if it is determined that the startup file to be accessed is startup file 2, the corresponding target sector identifier can be determined as sector identifier 2 according to the identifier of startup file 2. Then, the corresponding target storage location can be determined as storage location 2 in the second mapping relationship according to sector identifier 2. Thus, startup file 2 can be obtained at storage location 2 in the memory, and the target system can be started according to startup file 2.
[0197] In the embodiment of the present application, the preset device can create a target file, and in response to a conversion instruction, perform format conversion on the target file to obtain an initial startup file system. The preset device can, in response to an addition instruction, add at least one startup file to the initial startup file system, and allocate target sector identifiers to the at least one startup file to obtain a startup file system. The electronic device can, in response to a startup instruction, obtain the startup file system in the preset device, store the startup file system in the memory of the target system, and use the memory as the memory occupied by the virtual block device. The electronic device can create a block device file, determine the virtual block device corresponding to the block device file, and create a target mapping relationship among the virtual block device, the memory, and the startup file system. The electronic device can mount the block device file in the target directory of the target system, access the startup file system in the memory through the virtual block device, and start the target system through the startup file system. Since a target mapping relationship can be created among the virtual block device, the memory, and the startup file system, and the startup file system in the memory can be accessed through the virtual block device, it is realized that the memory storing the startup file system is directly used as the memory corresponding to the virtual block device. Compared with the prior art, it is not necessary to copy the startup file system multiple times, saving the copying time, and it is not necessary to decompress the startup file system, saving the decompression time, comprehensively improving the efficiency of starting the target system in the electronic device.
[0198] Figure 7 The figure is a schematic structural diagram of a system startup device provided by an exemplary embodiment of the present application. Please refer to Figure 7 The system startup device 10 includes: a loading module 11, a first creation module 12, a second creation module 13, a mounting module 14, and an access module 15, where
[0199] The loading module 11 is configured to load the startup file system into the memory of the target system in response to a startup instruction of the target system;
[0200] The first creation module 12 is configured to create a block device file and determine the virtual block device corresponding to the block device file;
[0201] The second creation module 13 is configured to create a target mapping relationship among the virtual block device, the memory, and the startup file system;
[0202] The mounting module 14 is configured to mount the block device file under a target directory of the target system;
[0203] The access module 15 is configured to access the startup file system in the memory through the virtual block device and start the target system through the startup file system.
[0204] The system startup device provided by the embodiments of the present application can execute the technical solutions shown in the above method embodiments, and the implementation principles and beneficial effects are similar, which will not be elaborated here.
[0205] In a possible implementation manner, the first creation module 12 is specifically configured to:
[0206] Obtain a virtual block device identifier and a target file identifier, where the virtual block device identifier is the identifier of the virtual block device;
[0207] Create the block device file according to the virtual block device identifier and the target file identifier, where the file identifier of the block device file is the target file identifier, and the virtual block device identifier is included in the block device file.
[0208] In a possible implementation manner, the mounting module 14 is specifically configured to:
[0209] Create a root directory in the target system;
[0210] Create a target directory under the root directory of the target system;
[0211] Mount the block device file under the target directory;
[0212] Determine the target directory as the root directory for starting the target system.
[0213] In a possible implementation manner, the second creation module 13 is specifically configured to:
[0214] Create a first mapping relationship between the virtual block device and the startup file system;
[0215] Create a second mapping relationship between the startup file system and the memory;
[0216] Determine that the target mapping relationship includes the first mapping relationship and the second mapping relationship.
[0217] In a possible implementation manner, the second creation module 13 is specifically configured to:
[0218] Determine the target sector identifiers corresponding to at least one startup file in the startup file system, and obtain at least one target sector identifier;
[0219] Determine the at least one target sector identifier as the at least one target sector identifier corresponding to the virtual block device, so as to create a first mapping relationship between the virtual block device and the startup file system.
[0220] In a possible implementation manner, the second creation module 13 is specifically configured to:
[0221] Determine the target sector identifiers corresponding to at least one startup file in the startup file system;
[0222] Determine the storage locations of at least one startup file in the startup file system in the memory;
[0223] According to each startup file, perform mapping processing on the target sector identifier and the storage location to create a second mapping relationship between the startup file system and the memory.
[0224] In a possible implementation manner, the access module 15 is specifically configured to:
[0225] According to the target mapping relationship, determine the storage locations of at least one startup file in the startup file system in the memory;
[0226] According to the storage location, access at least one startup file in the startup file system in the memory through the virtual block device.
[0227] In a possible implementation manner, the loading module 11 is specifically configured to:
[0228] In response to a startup instruction, obtain the startup file system in a preset device;
[0229] Store the startup file system in the memory of the target system, and use the memory as the memory occupied by the virtual block device.
[0230] Figure 7 The system startup device shown in can be applied to the electronic device described in any of the above embodiments.
[0231] The system startup device provided in the embodiments of the present application can execute the technical solutions shown in the above method embodiments, and the implementation principles and beneficial effects are similar, and will not be elaborated here.
[0232] Figure 8 This is a schematic structural diagram of another system startup device provided for an exemplary embodiment of the present application. Please refer toFigure 8 The system startup device 20 may include: a third creation module 21, a conversion module 22, and an addition module 23, where,
[0233] The third creation module 21 is configured to create a target file in response to a creation instruction;
[0234] The conversion module 22 is configured to perform format conversion on the target file in response to a conversion instruction to obtain an initial startup file system in which there is no startup file;
[0235] The addition module 23 is configured to add at least one startup file to the initial startup file system and assign a target sector identifier to the at least one startup file to obtain the startup file system.
[0236] In a possible implementation, the startup file system is an uncompressed file system supported by the target system.
[0237] Figure 8 The system startup device shown in may be applied to the preset device described in any of the above embodiments.
[0238] The system startup device provided by the embodiments of the present application may execute the technical solutions shown in the above method embodiments, and the implementation principles and beneficial effects are similar, and will not be elaborated here.
[0239] An exemplary embodiment of the present application provides a schematic structural diagram of an electronic device. Please refer to Figure 9 The electronic device 30 may include a processor 31 and a memory 32. Exemplarily, the processor 31 and the memory 32 are connected to each other through a bus 33.
[0240] The memory 32 stores computer-executable instructions;
[0241] The processor 31 executes the computer-executable instructions stored in the memory 32, so that the processor 31 executes the method shown in the above method embodiments.
[0242] Optionally, Figure 9 The electronic device shown in may be a hardware emulator.
[0243] Correspondingly, an embodiment of the present application provides a computer-readable storage medium, in which computer-executable instructions are stored, and when the computer-executable instructions are executed by a processor, they are used to implement the method described in the above method embodiments.
[0244] Accordingly, an embodiment of the present application can also provide a computer program product, including a computer program, which can implement the method shown in the above method embodiment when executed by a processor.
[0245] Those skilled in the art should understand that the embodiments of the present invention can be provided as a method, a system, or a computer program product. Therefore, the present invention can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present invention can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0246] The present invention is described with reference to the flowcharts and / or block diagrams of methods, apparatuses (systems), and computer program products according to embodiments of the present invention. It should be understood that each flow and / or block in the flowchart and / or block diagram, and the combination of flows and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, such that the instructions executed by the processor of the computer or other programmable data processing devices generate means for implementing the specified functions in Figure 1 one or more flows and / or blocks Figure 1 one or more blocks.
[0247] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, such that the instructions stored in the computer-readable memory generate a manufactured article including instruction means that implement the specified functions in Figure 1 one or more flows and / or blocks Figure 1 one or more blocks.
[0248] These computer program instructions can also be loaded onto a computer or other programmable data processing device, such that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process, so that the instructions executed on the computer or other programmable device provide steps for implementing the specified functions in Figure 1 one or more flows and / or blocks Figure 1 one or more blocks.
[0249] In a typical configuration, a computing device includes one or more processors (CPUs), an input / output interface, a network interface, and a memory.
[0250] The memory may include non-permanent memory in the form of computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. The memory is an example of computer-readable media.
[0251] Computer-readable media includes both permanent and non-permanent, removable and non-removable media and can store information by any method or technology. The information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transitory medium that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory media such as modulated data signals and carrier waves.
[0252] It should also be noted that the term "comprising", "including" or any other variation thereof is intended to cover non-exclusive inclusion, such that a process, method, article or apparatus comprising a series of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article or apparatus. Without further limitation, an element defined by the statement "comprising an..." does not exclude the presence of additional identical elements in the process, method, article or apparatus comprising the element.
[0253] The above description is only for the embodiments of the present application and is not intended to limit the present application. For those skilled in the art, various changes and modifications can be made to the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present application shall be included within the scope of the claims of the present application.
Claims
1. A system startup method, characterized in that, including: In response to a startup instruction of a target system, loading a startup file system into the memory of the target system; Creating a block device file and determining a virtual block device corresponding to the block device file; Creating a target mapping relationship among the virtual block device, the memory, and the startup file system, and mounting the block device file under a target directory of the target system; Accessing the startup file system in the memory through the virtual block device, and starting the target system through the startup file system.
2. The method according to claim 1, characterized in that, Creating a block device file includes: Obtaining a virtual block device identifier and a target file identifier, where the virtual block device identifier is an identifier of the virtual block device; Creating the block device file according to the virtual block device identifier and the target file identifier, where the file identifier of the block device file is the target file identifier, and the block device file includes the virtual block device identifier.
3. The method according to claim 1 or 2, characterized in that, Mounting the block device file under a target directory of the target system includes: Creating a root directory in the target system; Creating a target directory under the root directory of the target system; Mounting the block device file under the target directory; Determining the target directory as the root directory for starting the target system.
4. The method according to any one of claims 1-3, characterized in that, Creating a target mapping relationship among the virtual block device, the memory, and the startup file system includes: Creating a first mapping relationship between the virtual block device and the startup file system; Creating a second mapping relationship between the startup file system and the memory; Determining that the target mapping relationship includes the first mapping relationship and the second mapping relationship.
5. The method according to claim 4, characterized in that, Creating a first mapping relationship between the virtual block device and the startup file system includes: Determining target sector identifiers corresponding to at least one startup file in the startup file system to obtain at least one target sector identifier; Determining the at least one target sector identifier as the at least one target sector identifier corresponding to the virtual block device to create a first mapping relationship between the virtual block device and the startup file system.
6. The method according to claim 4, characterized in that, Creating a second mapping relationship between the startup file system and the memory includes: Determining target sector identifiers corresponding to at least one startup file in the startup file system; Determining storage locations of at least one startup file in the startup file system in the memory; Performing a mapping process on the target sector identifier and the storage location according to each startup file to create a second mapping relationship between the startup file system and the memory.
7. The method according to any one of claims 1-6, characterized in that, Accessing the startup file system in the memory through the virtual block device includes: Determining storage locations of at least one startup file in the startup file system in the memory according to the target mapping relationship; Accessing at least one startup file in the startup file system in the memory through the virtual block device according to the storage location.
8. The method according to any one of claims 1-7, characterized in that, In response to a startup instruction of a target system, loading a startup file system into the memory of the target system includes: In response to the startup instruction, obtaining the startup file system in a preset device; Store the startup file system in the memory of the target system, and use the memory as the memory occupied by the virtual block device.
9. The method according to any one of claims 1-8, characterized in that, Before obtaining the startup file system in a preset device in response to a startup instruction, the method further includes: Create a target file in response to a creation instruction; In response to a conversion instruction, perform format conversion on the target file to obtain an initial startup file system that does not contain startup files; In response to an addition instruction, add at least one startup file to the initial startup file system and assign a target sector identifier to the at least one startup file to obtain the startup file system.
10. According to the method described in any one of claims 1-9, characterized in that, The startup file system is an uncompressed file system supported by the target system.
11. A system startup device, characterized in that, It includes: A loading module, a first creation module, a second creation module, a mounting module, and an access module, where The loading module is configured to load the startup file system into the memory of the target system in response to a startup instruction of the target system; The first creation module is configured to create a block device file and determine the virtual block device corresponding to the block device file; The second creation module is configured to create a target mapping relationship among the virtual block device, the memory, and the startup file system; The mounting module is configured to mount the block device file under a target directory of the target system; The access module is configured to access the startup file system in the memory through the virtual block device and start the target system through the startup file system.
12. An electronic device, characterized in that, It includes: At least one processor; And A memory communicatively connected to the at least one processor; Wherein, the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the electronic device to execute the method according to any one of claims 1-10.
13. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, and when the processor executes the computer-executable instructions, the method according to any one of claims 1-10 is implemented.
14. A computer program product, including a computer program, characterized in that, When the computer program is executed by the processor, the method according to any one of claims 1-10 is implemented.
Citation Information
Cited By
Pre-loading block equipment implementation method and device suitable for multi-core heterogeneous hardware system
CN120492045A