Method and device for equipment running different OSs to use storage medium
By interoperating on the storage medium, the second OS formats the free space without affecting the first OS and creates a second file system, solving the problems of coexistence and data security of different OSes, and realizing flexible allocation of storage medium and Run efficiently.
Patent Information
- Application Number
- CN202411138487.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-19
- Publication Date
- 2024-12-06
AI Technical Summary
The prior art is difficult to meet the needs of different operating systems for different file systems on a single storage medium, especially to realize the coexistence of different file systems without destroying the original data. The traditional method requires full disk formatting to lead to data loss and Trifty operation.
Through interactive operations, the second OS only formats the free space of the storage medium, creates a second file system without affecting the first OS and its file system, ensuring data security, and implementing it without requiring full disk formatting without requiring full disk formatting File systems coexist between different OSes.
It realizes the coexistence of different file systems supported by different OSes, enhances the flexible allocation of storage media, avoids data loss and operational complexity, and improves the system's operating efficiency and data security.
Smart Images

Figure CN119088461A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of computer operating systems, and more particularly to a method and apparatus for using a storage medium by devices running different OSs. Background Art
[0002] Currently, operating system deployment usually involves burning the system image to a boot storage device (such as EMMC, SD card), and formatting these storage media into a specific file system format, such as ext4, NTFS, to ensure that the system can be directly started and run. This process simplifies system deployment, however, it also has the following limitations.
[0003] First, although some operating systems provide disk management tools that allow users to flexibly adjust the capacity allocation of the boot storage medium to a certain extent, such as in the Windows operating system reinstallation scenario, users can customize the system partition size. However, this flexibility is not common in specific fields, especially in embedded system development. In such specific fields, the system image provided by the manufacturer often formats the entire boot storage medium as a single file system, which greatly limits the ability to dynamically reallocate storage resources to other file systems.
[0004] Second, when users need to change the file system on a storage medium, the traditional method requires full disk formatting, which is not only cumbersome but also results in the loss of all data stored on the medium.
[0005] Therefore, under the current technical system, it is impossible to simultaneously meet the requirements of different operating systems for different file systems on a single storage medium (such as a boot storage medium), especially to achieve the coexistence of different file systems without destroying the original data. Summary of the invention
[0006] In view of the above problems in the prior art, the present application provides a method, apparatus, device and medium for devices running different OS to use storage media, which solves the problem of inflexible allocation of storage resources of storage media in the current technology and enables different file systems supported by different OS to coexist on the same storage medium.
[0007] To achieve the above object, the first aspect of the present application provides a method for using a storage medium by a device running different OSs, wherein the different OSs include a first OS supporting a first file system and a second OS supporting a second file system; a first space of the storage medium is formatted as the first file system for access by the first OS; wherein the first space is the entire space of the storage medium, or a portion of the space with continuous addresses, and the method comprises:
[0008] The second OS interacts with the first OS and obtains from the first OS the used space in the first space; wherein the used space is the space where data has been written, and the space where data has not been written is the free space;
[0009] The second OS determines the free space of the storage medium, where the free space of the storage medium includes the free space of the first space;
[0010] The second OS uses the entire free space of the storage medium, or a portion of the space with continuous addresses, as the second space, and formats it into a second file system for access by the second OS.
[0011] From the above, the present application proposes a method for using a storage medium by devices running different OSes. When the second OS formats the second space, it only operates on the free space of the storage medium. That is to say, the second file system is added without affecting the first OS and its first file system. This not only ensures the security of the existing data in the first space, but also eliminates the need to reformat the entire storage medium. Therefore, the ability to flexibly allocate storage media between different OSes is significantly enhanced, so that different file systems supported by different OSes can coexist, meeting the needs of different application scenarios or users for diverse file systems.
[0012] As a possible implementation of the first aspect, the second OS determines free space of the storage medium, takes all the free space of the storage medium or a portion of the free space with continuous addresses as the second space, and formats the free space into a second file system for access by the second OS, including:
[0013] The second OS determines an expected space size, where the expected space size is the space size of the storage medium that it expects to use;
[0014] When the second OS determines that the size of the free space of the storage medium is not less than the expected space size, it selects space of the expected space size from all the free space in the storage medium, or part of the space with continuous addresses, as the second space, and formats it into a second file system for access by the second OS.
[0015] As described above, the second OS can determine the free space in the storage medium to be used according to actual needs (i.e., the expected space size), avoiding over-allocation or space waste, and realizing efficient and accurate use of storage resources. Moreover, it can dynamically create an independent second file system area for the second OS on the storage medium without interfering with the first OS and its file system, realizing the harmonious coexistence of file systems between different OSes, and meeting the needs for supporting diverse file systems in a multi-system environment.
[0016] As a possible implementation of the first aspect, the free space of the storage medium is located after the used space, and the selecting the space of the expected space size as the second space and formatting it into a second file system for access by the second OS includes:
[0017] Starting from the starting address of the free space of the storage medium, moving backward to a second address, the space size between the starting address and the second address matches the expected space size;
[0018] The space from the starting address to the second address is used as a second space and formatted into a second file system for access by a second OS.
[0019] From the above, the second space is selected by moving backward sequentially from the starting address of the free space of the storage medium, thereby ensuring the continuity of the first space and the second space on the storage medium. Compared with non-continuous allocation, continuous space allocation reduces the overhead in managing file fragments and updating file allocation tables. This continuous space allocation strategy further enhances the operating efficiency and response speed of the entire system.
[0020] As a possible implementation of the first aspect, the following also includes:
[0021] Lock information is set at the start address and the end address of the second space of the storage medium; the lock information prevents the first OS from accessing the second space of the storage medium.
[0022] As described above, the introduction of lock information can clearly divide the storage boundary of the first OS and the second OS, ensuring that the first OS cannot cross the boundary to access the second file system of the second OS, effectively preventing data misoperation and potential security risks, and enhancing the security of data isolation in a multi-system environment.
[0023] As a possible implementation manner of the first aspect, after the second space is formatted as the second file system, the step of expanding the current first space by the first OS includes:
[0024] The first OS determines the size of the space to be expanded, interacts with the second OS, and provides the size of the space to be expanded to the second OS;
[0025] When the second OS determines that the free space in the second space of the storage medium is larger than the space used by the second OS, and the sum of the space sizes of the first space, the space to be expanded by the first OS, and the space used by the second OS in the second space is smaller than the total space size of the storage medium:
[0026] The second OS determines a third address in the second space of the storage medium according to the size of the space to be expanded by the first OS, wherein the size of the space from the start address to the third address in the second space matches the size of the space to be expanded by the first OS;
[0027] The second OS moves the data in the space used by it backward to the space where the third address is the starting address;
[0028] The first OS formats the space between the start address of the second space and the third address into a first file system for access by the first OS.
[0029] As described above, when the first OS needs to expand its storage space, through close cooperation with the second OS, the second OS can migrate the data in its used storage space backwards, ensuring the integrity and consistency of all data during the migration process, and at the same time releasing a continuous area at the front of the space originally occupied by the second OS, which just meets the size required for the expansion of the first OS. Therefore, not only is the available free space on the storage medium effectively utilized, but the impact on the running state of the second OS is also minimized, and the flexible adjustment and optimized allocation of storage resources between the first OS and the second OS are realized.
[0030] As a possible implementation manner of the first aspect, when the start address and the end address of the second space of the storage medium have lock information, the method further includes:
[0031] Before the first OS provides the size of the space to be expanded to the second OS, the first OS sends an unlock request to the second OS;
[0032] After the second OS moves the data of its used space backward to the empty space with the third address as the starting address, it removes the lock information of the starting address and the last address of the second space, and sets the lock information of the third address and the last address of the second space.
[0033] As described above, by introducing the unlocking and re-locking process before and after the first OS expands the storage space, the security and coordination of storage management in a multi-operating system environment are enhanced. Specifically, the first OS needs to request the second OS to unlock, ensuring the authorization and control of the space adjustment operation and avoiding unauthorized access; and after the second OS completes the data movement, it adds lock information in time, re-establishes the access rights to the storage area, and maintains the isolation between the first OS and the second OS.
[0034] As a possible implementation of the first aspect, the free space of the storage medium is located after the used space, and the selecting the space of the expected space size as the second space and formatting it into a second file system for access by the second OS includes:
[0035] Starting from the last address of the free space of the storage medium, moving forward to a fourth address, the space between the fourth address and the last address forms the space of the expected space size;
[0036] The space from the fourth address to the last address is used as a second space and formatted into a second file system for access by a second OS.
[0037] As described above, by allocating space in the above manner, the first space of the first OS is naturally separated from the second space of the second OS, reducing the risk of cross-data access due to misoperation, and to a certain extent, enhancing the stability of the system and data security.
[0038] To achieve the above-mentioned object, the second aspect of the present application provides an apparatus for using a storage medium by a device running different OSs, wherein the different OSs include a first OS supporting a first file system and a second OS supporting a second file system; a first space of the storage medium is formatted as the first file system for access by the first OS; wherein the first space is the entire space of the storage medium, or a portion of the space with continuous addresses; the apparatus comprises:
[0039] an information interaction unit, used for the second OS to interact with the first OS, so that the second OS can learn from the first OS the used space in the first space; wherein the used space refers to the space where data has been written, and the space where data has not been written is the free space;
[0040] A determining unit, configured for the second OS to determine free space of the storage medium, wherein the free space of the storage medium includes free space of the first space;
[0041] The formatting unit is used for the second OS to format the entire free space of the storage medium, or a portion of the space with continuous addresses, as a second space into a second file system for access by the second OS.
[0042] To achieve the above object, the third aspect of the present application provides a computing device, including:
[0043] processor, and
[0044] A memory having program instructions stored thereon, wherein when the program instructions are executed by the processor, the processor executes the method described in any one of the first aspects above.
[0045] To achieve the above-mentioned purpose, the fourth aspect of the present application provides a computer-readable storage medium having program instructions stored thereon, and when the program instructions are executed by a computer, the computer implements any of the methods described in the first aspect above. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] Figure 1 It is a flowchart of the main steps of a method for using a storage medium by a device running different OS provided by the present application;
[0047] Figure 2 It is an operation schematic diagram of Embodiment 1 provided in this application;
[0048] Figure 3 This is an operation diagram of Embodiment 2 provided in this application;
[0049] Figure 4 It is a structural schematic diagram of devices running different OSs according to Embodiment 1 and Embodiment 2 provided in the present application;
[0050] Figure 5 It is a structural schematic diagram of an apparatus for using a storage medium by devices running different OS provided by the present application;
[0051] Figure 6 It is a structural schematic diagram of a computing device provided by the present application.
[0052] It should be understood that the size and shape of each block diagram in the above structural diagram are for reference only and should not constitute an exclusive interpretation of the embodiment of the present invention. The relative position and inclusion relationship between the blocks presented in the structural diagram are only schematic representations of the structural association between the blocks, and do not limit the physical connection method of the embodiment of the present invention. DETAILED DESCRIPTION
[0053] The technical solution provided by the present application is further described below with reference to the accompanying drawings and examples. It should be understood that the system structure and business scenarios provided in the examples of the present application are mainly to illustrate the possible implementation methods of the technical solution of the present application and should not be interpreted as the only limitation on the technical solution of the present application. It is known to those of ordinary skill in the art that with the evolution of the system structure and the emergence of new business scenarios, the technical solution provided by the present application is also applicable to similar technical problems.
[0054] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art of the present application. In case of any inconsistency, the meaning described in this specification or the meaning derived from the contents recorded in this specification shall prevail. In addition, the terms used herein are only for the purpose of describing the embodiments of the present application and are not intended to limit the present application.
[0055] Used storage medium space: In this application, it refers to the physical space on the storage medium where data has been stored, including the space that has been formatted with a certain file system and has data written to it. Correspondingly, unused storage medium space (i.e., free space) includes: space that has been formatted with a certain file system but has not yet been written to, and space that has not yet been formatted.
[0056] OS: Operating System. Common operating systems include Windows, Linux, Android, and iOS.
[0057] The embodiment of the present application provides a method for using a storage medium by a device running different OSs, wherein the different OSs include a first OS supporting a first file system and a second OS supporting a second file system; a first space of the storage medium is formatted as the first file system for access by the first OS; wherein the first space is the entire space of the storage medium, or a portion of the space with continuous addresses; Figure 1 As shown, the method includes:
[0058] S101, the second OS interacts with the first OS, and obtains from the first OS the used space in the first space; wherein the used space is the space where data has been written, and the space where data has not been written is the free space;
[0059] S102: The second OS determines free space of the storage medium, where the free space of the storage medium includes free space of the first space;
[0060] S103: The second OS uses the entire free space of the storage medium, or a portion of the space with continuous addresses, as a second space, and formats it into a second file system for access by the second OS.
[0061] Exemplarily, the first OS is a Linux operating system, and the first file system is an ext4 file system;
[0062] The second OS is the Intel operating system, and the second file system is the fat32 file system.
[0063] The free space of the storage medium is explained below through two examples.
[0064] Example 1: The total space of the storage medium is 8G, and the first space occupies 5G, of which 3G is used in the first space and 2G is free. Then, the free space of the storage medium is: the sum of the remaining space of the storage medium (in this example, the remaining space can be the space that has not been formatted) and the free space of the first space, that is, 8G-5G+2G=5G.
[0065] Example 2: The total space of the storage medium is 8G, and the first space occupies 8G. Among them, the used space in the first space is 5G, and the free space of the first space is 3G. Then, the free space of the storage medium is the free space of the first space, that is, 3G.
[0066] It is worth noting that after the second OS successfully formats the free space in the storage medium into the second file system, the second OS informs the first OS of the starting address of its second file system to ensure information synchronization between the first OS and the second OS. The specific steps are as follows: Assume that the storage range initially occupied by the first OS is from address 1 to address 3, where address 1 and address 2 are used spaces, and address 3 is free space. As the second OS occupies the space, address 3 is used as the starting point of its second space. In order to maintain the management of storage resources between the first OS and the second OS, the second OS will actively report its occupied starting address, i.e., address 3, to the first OS. After receiving this information, the first OS will adjust its internal records accordingly, adjusting the range of the first space from the original address 1 to address 3 to address 1 to address 2.
[0067] Thus, the present application proposes a method for using a storage medium by devices running different OSes. When the second OS formats the second space, it only operates on the free space of the storage medium. That is to say, the second file system is added without affecting the first OS and its first file system. This not only ensures the security of the existing data in the first space, but also eliminates the need to reformat the entire storage medium. Therefore, the ability to flexibly allocate storage media between different OSes is significantly enhanced, so that different file systems supported by different OSes can coexist, meeting the needs of different application scenarios or users for diverse file systems.
[0068] In some embodiments, the second OS determines the free space of the storage medium, takes all the free space of the storage medium, or part of the free space with continuous addresses as the second space, and formats it into a second file system for access by the second OS, including:
[0069] The second OS determines an expected space size, where the expected space size is the space size of the storage medium that it expects to use;
[0070] When the second OS determines that the size of the free space of the storage medium is not less than the expected space size, it selects space of the expected space size from all the free space in the storage medium, or part of the space with continuous addresses, as the second space, and formats it into a second file system for access by the second OS.
[0071] In this way, the second OS can determine the free space in the storage medium to be used according to actual needs (i.e., the expected space size), avoiding over-allocation or space waste, and achieving efficient and accurate use of storage resources. Moreover, it is possible to dynamically create an independent second file system area for the second OS on the storage medium without interfering with the first OS and its file system, thus achieving harmonious coexistence of file systems between different OSes and meeting the needs for supporting diverse file systems in a multi-system environment.
[0072] In some embodiments, the free space of the storage medium is located after the used space, and the selecting the space of the expected size as the second space and formatting it into a second file system for access by the second OS includes:
[0073] Starting from the starting address of the free space of the storage medium, moving backward to a second address, the space size between the starting address and the second address matches the expected space size;
[0074] The space from the starting address to the second address is used as a second space and formatted into a second file system for access by a second OS.
[0075] For example, it is assumed that the total space of the storage medium is 100 GB, the first space occupies 80 GB, and the free space of the storage medium is 20 GB.
[0076] If you want to deploy a second OS on this storage medium, and the second OS requires a 10G second space, you can follow the steps below:
[0077] Step 1: Determine that the free space of the storage medium is located after the used space, that is, the 20G area from 81G to 100G.
[0078] Step 2: Start calculating from the starting address of the free space of the storage medium (81G), and move backward to 90G (because the space size between 81G and 90G is exactly 10G, which meets the expected space size requirement of the second OS).
[0079] Step 3: After determining the range, the second OS will format the 10G space from 81G to 90G as the second file system.
[0080] In this way, the second space is selected by moving backward sequentially from the starting address of the free space of the storage medium, thereby ensuring the continuity of the first space and the second space on the storage medium. Compared with non-continuous allocation, continuous space allocation reduces the overhead in managing file fragments and updating file allocation tables. This continuous space allocation strategy further enhances the operating efficiency and response speed of the entire system.
[0081] In some embodiments, it also includes:
[0082] Lock information is set at the start address and the end address of the second space of the storage medium; the lock information prevents the first OS from accessing the second space of the storage medium.
[0083] The lock information includes header information and tail information.
[0084] Exemplarily, after the start address of the second space of the storage medium, header information is added as lock information, for example, using the sequence 0xCC, 0xBB, 0xAA to mark the beginning of the area. At the same time, after the last address of the second space of the storage medium, tail information is added as lock information, for example, using the sequence 0x55, 0x5A, 0x88 to mark the end of the area. In this way, when the first OS encounters these specific lock information marks, it can recognize that the area is reserved for the second OS, and therefore cannot access or modify this area.
[0085] In this way, the introduction of lock information can clearly divide the storage boundaries of the first OS and the second OS, ensuring that the first OS cannot cross the boundary to access the second file system of the second OS, effectively preventing data misoperation and potential security risks, and enhancing the security of data isolation in a multi-system environment.
[0086] In some embodiments, after the second space is formatted as the second file system, the step of the first OS expanding the current first space includes:
[0087] The first OS determines the size of the space to be expanded, interacts with the second OS, and provides the size of the space to be expanded to the second OS;
[0088] When the second OS determines that the free space in the second space of the storage medium is larger than the space used by the second OS, and the sum of the space sizes of the first space, the space to be expanded by the first OS, and the space used by the second OS in the second space is smaller than the total space size of the storage medium:
[0089] The second OS determines a third address in the second space of the storage medium according to the size of the space to be expanded by the first OS, wherein the size of the space from the start address to the third address in the second space matches the size of the space to be expanded by the first OS;
[0090] The second OS moves the data in the space used by it backward to the space where the third address is the starting address;
[0091] The first OS formats the space between the start address of the second space and the third address into a first file system for access by the first OS.
[0092] For example, the total space of the storage medium is 120G, the first space occupies 60G, the second space immediately after the first space occupies 20G, wherein the used space of the second space is 5G, and the free space of the second space is 15G.
[0093] If you want to expand the first space of the first OS on this storage medium, you need to add 15G space. You can follow the steps below:
[0094] Step 1: The first OS determines that 15G of space needs to be added.
[0095] Step 2: The first OS interacts with the second OS, indicating that the first OS needs to be expanded by 15G. The second OS determines whether the conditions are met.
[0096] Specifically, the free space in the second space is larger than the space used by the second OS (15G is larger than 5G), and the sum of the space sizes of the first space, the space to be expanded by the first OS, and the space used by the second OS in the second space is smaller than the total space size of the storage medium (60G+15G+5G is smaller than 120G).
[0097] Step 3: When the conditions are met, the second OS moves its own data backward by 15G from the current location according to the expansion requirements of the first OS.
[0098] Step 4: After the second OS data is moved, the first OS is notified, and the first OS formats the 15G space released by the second OS into the first file system, thereby expanding the first space.
[0099] In this way, when the first OS needs to expand its storage space, the second OS can migrate the data in its used storage space backwards through information interaction with the second OS, ensuring the integrity and consistency of all data during the migration process, and at the same time releasing a continuous area at the front of the space originally occupied by the second OS, which just meets the size required for the expansion of the first OS. Therefore, not only is the available free space on the storage medium effectively utilized, but the impact on the running state of the second OS is also minimized, realizing the flexible adjustment and optimized allocation of storage resources between the first OS and the second OS.
[0100] In some embodiments, when the start address and the end address of the second space of the storage medium have lock information, the method further includes:
[0101] Before the first OS provides the size of the space to be expanded to the second OS, the first OS sends an unlock request to the second OS;
[0102] After the second OS moves the data in its used space backward to the empty space with the third address as the starting address, it removes the lock information of the original starting address and the last address of the second space, and sets the lock information for the third address and the last address of the second space.
[0103] In this way, by introducing the unlocking and re-locking process before and after the first OS expands the storage space, the security and coordination of storage management in a multi-operating system environment are enhanced. Specifically, the first OS needs to request the second OS to unlock, ensuring the authorization and control of the space adjustment operation and avoiding unauthorized access; and after the second OS completes the data movement, it adds lock information in time, re-establishes the access rights to the storage area, and maintains the isolation between the first OS and the second OS.
[0104] In some embodiments, the free space of the storage medium is located after the used space, and the selecting the space of the expected size as the second space and formatting it into a second file system for access by the second OS includes:
[0105] Starting from the last address of the free space of the storage medium, moving forward to a fourth address, the space between the fourth address and the last address forms a space of the expected space size;
[0106] The space from the fourth address to the last address is used as a second space and formatted into a second file system for access by a second OS.
[0107] For example, it is assumed that the total space of the storage medium is 100 GB, the first space occupies 80 GB, and the free space of the storage medium is 20 GB.
[0108] If you want to deploy a second OS on this storage medium, and the second OS requires a 10G second space, you can follow the steps below:
[0109] Step 1: Determine that the free space of the storage medium is located after the used space, that is, the 20G area from 81G to 100G.
[0110] Step 2: Start calculating from the last address of the free space of the storage medium (100G), and move forward to 90G (because the space size between 100G and 90G is exactly 10G, which meets the expected space size requirement of the second OS).
[0111] Step 3: After determining the range, the second OS will format the 10G space from the 90th G to the 100th G as the second file system.
[0112] In the above example, there is 10 GB of free space between the first space and the second space. If the first OS needs to expand the first space at this time, the following two examples are used to explain it in detail.
[0113] Example 1: Take the need to increase 2G space as an example.
[0114] First, the first OS determines that it needs to increase the space by 2G. The first OS interacts with the second OS, indicating that the first OS needs to expand by 2G. At this time, according to the address range of the first space and the second space, it can be determined that there is 10G of free space between the first space and the second space, which is larger than the 2G required to be expanded by the first OS. Therefore, the second OS or the first OS can determine that the expansion of 2G does not involve operations on the second file system, that is, it is determined that the free space 10G between the first space and the second space can be operated, and finally the first 2G is formatted as the first file system for access by the first OS.
[0115] Example 2: Take the need to increase 15G space as an example.
[0116] First, the first OS determines that 15G of space needs to be added. The first OS interacts with the second OS, indicating that the first OS needs to expand by 15G. At this time, according to the address range of the first space and the second space, it can be determined that there is 10G of free space between the first space and the second space, which is less than the 15G required for the first OS to expand. Therefore, the 10G of free space between the first space and the second space can be formatted as the first file system. In addition, the second OS can determine that 5G of space needs to be released from its second file system, so the second OS moves the data of its used space backward by 5G, and the released 5G space is formatted by the first OS as the first file system for access by the first OS, and finally the first space is expanded by 15G.
[0117] In this way, by allocating space in the above manner, the first space of the first OS is naturally separated from the second space of the second OS, reducing the risk of cross-data access due to misoperation, and to a certain extent, enhancing the stability of the system and data security.
[0118] On the other hand, when the second OS needs to expand the space, it expands forward. The principle is basically similar to the backward expansion of the first OS mentioned above, so it will not be repeated here.
[0119] In order to more clearly illustrate the above method, the present application provides two specific embodiments.
[0120] Embodiment 1: The first OS is a Linux operating system (a type of GPOS), and the second OS is an Intel operating system.
[0121] like Figure 2As shown, the total space size of the storage medium (eMMC) is 8G, the first space of the storage medium is formatted as the ext4 file system for access by the Linux operating system, the first space occupies 8G, the used space of the first space is 2G, and the free space of the first space is 6G.
[0122] Continue to see Figure 2 As shown in the figure, if the user wants to allocate 6G of storage media from 8G space to the Intewell operating system and format it as Fat32 file system, the Intewell operating system first confirms the size of the space occupied by the Linux operating system, which is 2G. Then, starting from the 2G position of the storage medium, 6G is allocated from the remaining 6G space, and the Intewell operating system formats it as Fat32 file system for access by the Intewell operating system.
[0123] Embodiment 2:
[0124] This embodiment is based on the first embodiment. If the user wants to expand the storage space of the Linux operating system by 3G, that is, from the original 2G to 5G, the space used by the Intewell operating system is 1G, and the free space is 5G.
[0125] like Figure 3 As shown, the Linux operating system needs to send an access request (Block E request) to the Intewell operating system and send an expansion space request, which includes the 3G space to be expanded. After receiving the Block E request sent by the Linux operating system, the Intewell operating system determines whether the following two conditions are met.
[0126] Condition 1: The free space in the second space of the storage medium is larger than the space used by the second OS (5G is larger than 1G);
[0127] Condition 2: The sum of the sizes of the first space, the space to be expanded by the first OS, and the space already used by the second OS in the second space is smaller than the total size of the storage medium (2G+3G+1G is smaller than 8G).
[0128] If the conditions are met, the Intewell operating system sends the information of Block Y (indicating acceptance of the request of Block E) to the Linux operating system. The Intewell operating system moves backward according to the size of the space to be expanded by the Linux operating system (3G), thereby reserving 3G of space for the Linux operating system, and notifies the Linux operating system, so that the Linux operating system formats the 3G space as the ext4 file system, and realizes the continuous space of 5G in total as the ext4 file system for access by the Linux operating system, so that the Linux operating system realizes the expansion of the first space.
[0129] If the condition is not met, the Intel operating system sends a Block N message to the Linux operating system (indicating rejection of the request for Block E), that is, the Linux operating system cannot expand the first space.
[0130] In summary, the first and second embodiments described above realize flexible expansion allocation of respective file systems when the Linux operating system and the Intel operating system are running on the same hardware device. The above embodiments can be applied to Figure 4 The hardware devices shown, where Figure 4 There are two virtual machines running on the hardware device in the embodiment shown, and the two virtual machines respectively run the above Linux operating system (a GPOS) and the Intel operating system, and both can access the same storage medium (eMMC). Through the above embodiment of the present application, the two operating systems format different address spaces on the same eMMC into ext4 and fat32 file systems respectively. Figure 4 The Hypervisor in the example is a virtual machine management module, which can be used to implement communication between the Linux operating system and the Intewell operating system respectively running in two virtual machines, and to implement information interaction between the two operating systems.
[0131] Figure 5 1 is a structural schematic diagram of an apparatus for using a storage medium by devices running different OSs provided in an embodiment of the present application. The embodiment of the present application provides an apparatus 500 for using a storage medium by devices running different OSs, wherein the different OSs include a first OS supporting a first file system and a second OS supporting a second file system; a first space of the storage medium is formatted as a first file system for access by the first OS; wherein the first space is the entire space of the storage medium or a portion of the space with continuous addresses, and the apparatus includes:
[0132] An information interaction unit 501 is used for the second OS to interact with the first OS, so that the second OS can learn from the first OS the used space in the first space; wherein the used space refers to the space where data has been written, and the space where data has not been written is the free space;
[0133] A determining unit 502, configured for the second OS to determine free space of the storage medium, where the free space of the storage medium includes free space of the first space;
[0134] The formatting unit 503 is used for the second OS to use the entire free space of the storage medium, or a portion of the space with continuous addresses, as the second space, and format it into a second file system for access by the second OS.
[0135] Figure 6 600 is a structural diagram of a computing device 600 provided in an embodiment of the present application. The computing device executes the above method, such as Figure 6 As shown, the computing device 600 includes: a processor 610 , a memory 620 , and a communication interface 630 .
[0136] It should be understood that Figure 6 The communication interface 630 in the computing device 600 shown may be used to communicate with other devices, and may specifically include one or more transceiver circuits or interface circuits.
[0137] The processor 610 may be connected to a memory 620. The memory 620 may be used to store the program code and data. Therefore, the memory 620 may be a storage unit inside the processor 610, or an external storage unit independent of the processor 610, or a component including a storage unit inside the processor 610 and an external storage unit independent of the processor 610.
[0138] Optionally, the computing device 600 may further include a bus. The memory 620 and the communication interface 830 may be connected to the processor 610 via the bus. The bus may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 6 A line without an arrow is used to represent the bus, but this does not mean that there is only one bus or one type of bus.
[0139] It should be understood that in the embodiment of the present application, the processor 610 can adopt a central processing unit (CPU). The processor can also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. Or the processor 610 uses one or more integrated circuits to execute related programs to implement the technical solutions provided in the embodiments of the present application.
[0140] The memory 620 may include a read-only memory and a random access memory, and provides instructions and data to the processor 610. A portion of the processor 610 may also include a nonvolatile random access memory. For example, the processor 610 may also store information on the device type.
[0141] When the computing device 600 is running, the processor 610 executes the computer-executable instructions in the memory 620 to perform any operation step of the above method and any optional embodiment thereof.
[0142] It should be understood that the computing device 600 according to the embodiment of the present application can correspond to the corresponding subjects in the methods according to the embodiments of the present application, and the above-mentioned and other operations and / or functions of each module in the computing device 600 are respectively for implementing the corresponding processes of each method of the present embodiment. For the sake of brevity, they will not be repeated here.
[0143] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0144] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0145] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0146] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0147] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0148] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0149] An embodiment of the present application also provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, it is used to execute the above method, which includes at least one of the solutions described in the above embodiments.
[0150] The computer storage medium of the embodiment of the present application can adopt any combination of one or more computer-readable media. Computer-readable media can be computer-readable signal media or computer-readable storage media. Computer-readable storage media can be, for example, but not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or devices, or any combination of the above. More specific examples (non-exhaustive lists) of computer-readable storage media include: electrical connections with one or more wires, portable computer disks, hard disks, random access memories (RAM), read-only memories (ROM), erasable programmable read-only memories (EPROM or flash memory), optical fibers, portable compact disk read-only memories (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the above. In this document, computer-readable storage media can be any tangible medium containing or storing programs, which can be used by instruction execution systems, devices or devices or used in combination with them.
[0151] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0152] The program code embodied on the computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0153] Computer program code for performing the operation of the present application can be written in one or more programming languages or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as an independent software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (e.g., using an Internet service provider to connect through the Internet).
[0154] In addition, the words "first, second, third, etc." or module A, module B, module C and other similar terms in the specification and claims are only used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that the specific order or sequence can be interchanged where permitted so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.
[0155] In the above description, the numbers representing the steps, such as S110, S120, etc., do not necessarily mean that the steps will be executed in this manner. If permitted, the order of the steps can be interchanged or they can be executed simultaneously.
[0156] The term "comprising" as used in the description and claims should not be interpreted as being limited to what is listed thereafter; it does not exclude other elements or steps. Therefore, it should be interpreted as specifying the presence of the features, integers, steps or components mentioned, but does not exclude the presence or addition of one or more other features, integers, steps or components and groups thereof. Therefore, the expression "a device comprising means A and B" should not be limited to a device consisting of components A and B only.
[0157] References to "one embodiment" or "an embodiment" in this specification mean that a particular feature, structure, or characteristic described in conjunction with the embodiment is included in at least one embodiment of the present application. Therefore, the phrases "in one embodiment" or "in an embodiment" appearing in various places in this specification do not necessarily refer to the same embodiment, but may refer to the same embodiment. In addition, in one or more embodiments, the particular features, structures, or characteristics can be combined in any appropriate manner, as would be apparent to one of ordinary skill in the art from this disclosure.
[0158] Note that the above are only preferred embodiments of the present application and the technical principles used. Those skilled in the art will understand that the present application is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present application. Therefore, although the present application is described in more detail through the above embodiments, the present application is not limited to the above embodiments, and may also include more other equivalent embodiments without departing from the concept of the present application, all of which belong to the scope of protection of the present application.
Claims
1. A method for using a storage medium by devices running different OSs, It is characterized in that The different OSs include a first OS supporting a first file system and a second OS supporting a second file system; a first space of the storage medium is formatted as the first file system for access by the first OS; wherein the first space is the entire space of the storage medium or a portion of the space with continuous addresses; the method includes: The second OS interacts with the first OS and obtains from the first OS the used space in the first space; wherein the used space is the space where data has been written, and the space where data has not been written is the free space; The second OS determines the free space of the storage medium, where the free space of the storage medium includes the free space of the first space; The second OS uses the entire free space of the storage medium, or a portion of the space with continuous addresses, as the second space, and formats it into a second file system for access by the second OS.
2. The method according to claim 1, It is characterized in that The second OS determines the free space of the storage medium, takes all the free space of the storage medium or a portion of the free space with continuous addresses as the second space, and formats it into a second file system for access by the second OS, including: The second OS determines an expected space size, where the expected space size is the space size of the storage medium that it expects to use; When the second OS determines that the size of the free space of the storage medium is not less than the expected space size, it selects space of the expected space size from all the free space in the storage medium, or part of the space with continuous addresses, as the second space, and formats it into a second file system for access by the second OS.
3. The method according to claim 2, It is characterized in that The free space of the storage medium is located after the used space, and the space of the expected size is selected as the second space, and formatted into a second file system for access by the second OS, including: Starting from the starting address of the free space of the storage medium, moving backward to a second address, the space size between the starting address and the second address matches the expected space size; The space from the starting address to the second address is used as a second space and formatted into a second file system for access by a second OS.
4. The method according to any one of claims 1 to 3, It is characterized in that Also includes: Setting lock information at the start address and the end address of the second space of the storage medium; The lock information prevents the first OS from accessing the second space of the storage medium.
5. The method according to claim 3, It is characterized in that After the second space is formatted as the second file system, the step of the first OS expanding the current first space includes: The first OS determines the size of the space to be expanded, interacts with the second OS, and provides the size of the space to be expanded to the second OS; When the second OS determines that the free space in the second space of the storage medium is larger than the space used by the second OS, and the sum of the space sizes of the first space, the space to be expanded by the first OS, and the space used by the second OS in the second space is smaller than the total space size of the storage medium: The second OS determines a third address in the second space of the storage medium according to the size of the space to be expanded by the first OS, wherein the size of the space from the start address to the third address in the second space matches the size of the space to be expanded by the first OS; The second OS moves the data in the space used by it backward to the space where the third address is the starting address; The first OS formats the space between the start address of the second space and the third address into a first file system for access by the first OS.
6. The method according to claim 5, It is characterized in that When the start address and the end address of the second space of the storage medium have lock information, the method further includes: Before the first OS provides the size of the space to be expanded to the second OS, the first OS sends an unlock request to the second OS; After the second OS moves the data of its used space backward to the empty space with the third address as the starting address, it removes the lock information of the starting address and the last address of the second space, and sets the lock information of the third address and the last address of the second space.
7. The method according to claim 2, It is characterized in that The free space of the storage medium is located after the used space, and the space of the expected size is selected as the second space, and formatted into a second file system for access by the second OS, including: Starting from the last address of the free space of the storage medium, moving forward to a fourth address, the space between the fourth address and the last address forms the space of the expected space size; The space from the fourth address to the last address is used as a second space and formatted into a second file system for access by a second OS.
8. An apparatus for using a storage medium by devices running different OSs, It is characterized in that The different OSs include a first OS supporting a first file system and a second OS supporting a second file system; a first space of the storage medium is formatted as the first file system for access by the first OS; wherein the first space is the entire space of the storage medium or a portion of the space with continuous addresses; the device includes: an information interaction unit, used for the second OS to interact with the first OS, so that the second OS can learn from the first OS the used space in the first space; wherein the used space refers to the space where data has been written, and the space where data has not been written is the free space; A determining unit, configured for the second OS to determine free space of the storage medium, wherein the free space of the storage medium includes free space of the first space; The formatting unit is used for the second OS to format the entire free space of the storage medium, or a portion of the space with continuous addresses, as a second space into a second file system for access by the second OS.
9. A computing device, It is characterized in that include: processor, and A memory having program instructions stored thereon, wherein when the program instructions are executed by the processor, the processor is caused to execute the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, It is characterized in that Program instructions are stored thereon, and when the program instructions are executed by a computer, the computer is caused to execute the method according to any one of claims 1 to 7.
