CN116166205A - File system storage and mounting method, device, equipment and storage medium - Google Patents

File system storage and mounting method, device, equipment and storage medium Download PDF

Info

Publication number
CN116166205A
CN116166205A CN202310436413.3A CN202310436413A CN116166205A CN 116166205 A CN116166205 A CN 116166205A CN 202310436413 A CN202310436413 A CN 202310436413A CN 116166205 A CN116166205 A CN 116166205A
Authority
CN
China
Prior art keywords
file system
partition
mounting
storage
read
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202310436413.3A
Other languages
Chinese (zh)
Other versions
CN116166205B (en
Inventor
余乐勋
范善翔
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangzhou Shiju Network Technology Co Ltd
Original Assignee
Guangzhou Shiju Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangzhou Shiju Network Technology Co Ltd filed Critical Guangzhou Shiju Network Technology Co Ltd
Priority to CN202310436413.3A priority Critical patent/CN116166205B/en
Publication of CN116166205A publication Critical patent/CN116166205A/en
Application granted granted Critical
Publication of CN116166205B publication Critical patent/CN116166205B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/0608Saving storage space on storage systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0638Organizing or formatting or addressing of data
    • G06F3/064Management of blocks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0638Organizing or formatting or addressing of data
    • G06F3/0643Management of files
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0638Organizing or formatting or addressing of data
    • G06F3/0644Management of space entities, e.g. partitions, extents, pools
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0668Interfaces specially adapted for storage systems adopting a particular infrastructure
    • G06F3/0671In-line storage system
    • G06F3/0673Single storage device
    • G06F3/0674Disk device
    • G06F3/0676Magnetic disk device
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0668Interfaces specially adapted for storage systems adopting a particular infrastructure
    • G06F3/0671In-line storage system
    • G06F3/0673Single storage device
    • G06F3/0674Disk device
    • G06F3/0677Optical disk device, e.g. CD-ROM, DVD
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0668Interfaces specially adapted for storage systems adopting a particular infrastructure
    • G06F3/0671In-line storage system
    • G06F3/0673Single storage device
    • G06F3/0679Non-volatile semiconductor memory device, e.g. flash memory, one time programmable memory [OTP]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0668Interfaces specially adapted for storage systems adopting a particular infrastructure
    • G06F3/0671In-line storage system
    • G06F3/0673Single storage device
    • G06F3/0682Tape device
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The embodiment of the application provides a file system storage and mounting method, a device, equipment and a storage medium, and relates to the technical field of storage, wherein the method comprises the following steps: the method comprises the steps of obtaining and analyzing a partition table, wherein the partition table is used for recording partition information corresponding to each partition in a storage device; if a first partition corresponding to the first file system is recorded in the partition table, acquiring header information corresponding to the first file system in the partition information; carrying out validity verification on the first file system according to the header information and preset verification conditions; if the first file system passes the validity verification, creating target block equipment correspondingly stored in the second file system; and mounting each file system on a mounting point corresponding to the block equipment associated with the first partition based on the read-write attribute preset by the file system. The scheme can effectively utilize the storage space and avoid the waste of storage resources.

Description

File system storage and mounting method, device, equipment and storage medium
Technical Field
The embodiment of the application relates to the technical field of storage, in particular to a file system storage and mounting method, device and equipment and a storage medium.
Background
The root file system of the embedded communication device may be stacked by an overlay fs from a first file system (e.g., squarfs) and a second file system (e.g., ext4 (Fourth extended filesystem, fourth generation extended file system)). Furthermore, the embedded communication device comprises one or more solid state storage devices, which may be divided into one or more logical partitions, the first and second file systems typically each occupying a separate logical partition in the storage devices.
The partition of the storage device is usually established when the hardware is initially used, and when the corresponding partition is allocated to the first file system and the second file system, a larger storage space is usually allocated to each partition, so that storage resources are wasted.
Disclosure of Invention
The embodiment of the application provides a file system storage and mounting method, device, equipment and storage medium, which can effectively utilize storage space and avoid waste of storage resources.
In a first aspect, an embodiment of the present application provides a method for storing and mounting a file system, where the method includes:
the method comprises the steps of obtaining and analyzing a partition table, wherein the partition table is used for recording partition information corresponding to each partition in a storage device;
if a first partition corresponding to and storing a first file system is recorded in the partition table, acquiring header information corresponding to the first file system;
carrying out validity verification on the first file system according to the header information and preset verification conditions;
if the first file system passes the validity verification, creating target block equipment corresponding to the second file system, wherein the target block equipment corresponds to a target sector in the first partition;
and mounting each file system on a mounting point corresponding to the block equipment associated with the first partition based on the read-write attribute preset by the file system.
In a second aspect, an embodiment of the present application provides a file system mounting and storing device, including:
the first information acquisition module is configured to acquire and analyze a partition table, and the partition table is used for recording partition information corresponding to each partition in the storage device;
the second information acquisition module is configured to acquire header information corresponding to the first file system if a first partition corresponding to the first file system is recorded in the partition table;
the information verification module is configured to verify the validity of the first file system according to the header information and the verification conditions;
the partition creation module is configured to create target block equipment corresponding to the second file system if the first file system passes the validity verification, wherein the target block equipment corresponds to a target sector in the first partition;
and the mounting module is configured to mount each file system on a mounting point corresponding to the block equipment associated with the first partition based on the read-write attribute preset by the file system.
In a third aspect, embodiments of the present application further provide an electronic device, including:
one or more processors;
and storage means for storing one or more programs which, when executed by the one or more processors, cause the one or more processors to implement the file system storage and mounting method as provided in the above aspect.
In a fourth aspect, embodiments of the present application also provide a storage medium storing computer-executable instructions that, when executed by a processor, are used to perform a file system storage and mounting method as provided in the above aspects.
According to the method and the device, the first partition stored with the first file system is determined through analysis of the partition table, validity check is conducted based on the header information of the first file system, so that the empty storage space of the partition where the first file system is located is detected, a virtual partition block device file is created in the empty storage space and used as an independently accessible space for mounting the second file system, the first file system and the second file system are stored in a single partition, the available space of the second file system is determined according to the actual size of the first file system, the storage space is reasonably utilized, waste of storage resources is avoided, and the reliability of the system is improved.
Drawings
Fig. 1 is a flowchart of steps of a file system storing and mounting method according to an embodiment of the present application.
Fig. 2 is a flowchart of steps for creating a target block device according to an embodiment of the present application.
Fig. 3 is a flowchart illustrating steps for creating a first partition according to an embodiment of the present application.
Fig. 4 is a schematic diagram of a logical partition according to an embodiment of the present application.
Fig. 5 is a schematic diagram of a file system storage and mounting device according to an embodiment of the present application.
Fig. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
Embodiments of the present application are described in further detail below with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the embodiments of the application and are not limiting of the embodiments of the application. It should be further noted that, for convenience of description, only some, but not all of the structures related to the embodiments of the present application are shown in the drawings.
The terms first, second and the like in the description and in the claims, are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged, as appropriate, such that embodiments of the present application may be implemented in sequences other than those illustrated or described herein, and that the objects identified by "first," "second," etc. are generally of a type and not limited to the number of objects, e.g., the first object may be one or more. In the description of the specification and claims, "a plurality" means two or more.
In an embedded communication device, one or more solid-state storage devices are usually matched, and the storage devices can be divided into one or more logical partitions, wherein the related information of the logical partitions such as a starting sector number, a sector number and the like is recorded in a partition table. The embedded communication device has at least one operating system, such as Linux system, windows system, etc., and the operating system is used to control and coordinate the embedded communication device and the external device (such as a storage device), that is, the operating system may read the partition table from the storage device by controlling the processor of the embedded communication device to obtain the related information of the logical partition.
The file system storage and mounting method provided by the application can be applied to the embedded device, as shown in fig. 1, and comprises the following steps:
step S110, obtaining and analyzing the partition table.
The partition table is stored in the storage device, and partition information of each partition is recorded in the partition table. The operating system can read the partition table from the storage device through the control processor, and obtain partition information corresponding to each partition through analysis of the partition table, such as partition numbers of each partition, related information (such as length and initial offset of each partition) of each partition, and the like.
Step S120, if a first partition corresponding to and storing the first file system is recorded in the partition table, acquiring header information corresponding to the first file system.
The partition table has recorded therein a first partition corresponding to the first file system, that is, there is a partition signal associated with the first partition in the partition table, it can be determined that there is a first partition among the logical partitions divided in the storage device, the first partition storing the first file system, and thus, the relevant information of the first partition, such as the position of the first partition, the partition number, etc., is recorded in the partition information of the partition table. In addition, header information of the first file system is stored in the first partition. Correspondingly, the processor reads the header information, thereby acquiring the file system length, version number and the like of the first file system.
And step 130, verifying the validity of the first file system according to the header information and preset verification conditions.
The validity of the first file system can be judged by analyzing the header information and combining with preset verification conditions. The verification condition is associated with a part of parameter items in the header information, so after the header information is analyzed, information of corresponding parameter items is acquired, and each parameter item is judged by combining the verification condition to determine whether the first file system passes the validity verification, and it is conceivable that the first file system passes the validity verification when all the parameter items meet the verification condition.
In one embodiment, the header information includes a magic word, a compression option, a version number, and a file system length, where the parameter entries occupy different numbers of bytes in the header information, for example, the magic word has an offset of 0 bytes and 4 bytes in the header information, the compression option has an offset of 20 bytes and 2 bytes in the header information, the version number has an offset of 28 bytes and 4 bytes in the header information, and the file system length has an offset of 40 bytes and 8 bytes in the header information. It should be noted that in some embodiments, the version number includes a major version number and a minor version number, and each occupies 2 bytes. It is conceivable that the offset is determined based on the start position of the header information. Therefore, the operating system can acquire the corresponding numerical value of each parameter item from the head information according to the offset of each parameter item on the head information and the occupied byte number.
The verification conditions are correspondingly set in plurality, and when all the parameter items meet the verification conditions, the validity of the first file system is verified. For example, the device needs to determine whether the magic word is a first preset value, whether the compression option is a second preset value, whether the version corresponding to the version number is a version supported by the system, and whether the file system length is smaller than the length of the first partition; when the magic word is a first preset value, the compression option is a second preset value, the version corresponding to the version number is a version supported by the system, and the length of the file system of the first file system is smaller than that of the first partition, determining that the first file system passes the validity verification. Therefore, the validity of the first file system is verified through the preset verification conditions, and reasonable distribution of storage resources is facilitated.
And step 140, if the first file system passes the validity verification, creating a target block device for storing the second file system correspondingly.
It will be appreciated that the target block device corresponds to a target sector within the first partition, which is a continuous segment of space within the first partition that includes a number of sectors, such as a plurality of consecutive sectors, e.g., sector I, sector II, etc. The current first file system passes the validity verification, namely, the first file system stored in the first partition meets the preset verification condition, and the partition length of the first partition is larger than the file system length of the first file system, so that a spare storage space exists in the first partition, the first partition is used as a virtual partition, namely, a second partition, in the storage space, and a target block device is created and can be used for storing the second file system. It is noted that the second partition is used as a virtual partition, and no entry corresponding to the second partition exists in the partition table, i.e., the relevant information of the second partition is not recorded in the partition table.
In an embodiment, referring to fig. 2, for creation of the target block device, the file system storage and mounting method provided in the present application further includes the following steps:
step S210, according to the file system length carried by the header information, determining a field value corresponding to the file system length of the first file system.
Step S220, based on the field value, determining an offset value which is larger than the field value and aligns with the sector boundary.
Step S230, the position of the offset value on the first partition is used as the start position of the target sector, and the end position of the first partition is used as the end position of the target sector.
It will be appreciated that the parameter item carried in the header information includes a file system length, in which the file system length of the first file system is recorded, for example, a 64-bit integer value that occupies 8 bytes, i.e. a field value, so that by parsing the header information, a corresponding field value can be obtained.
The bytes occupied by each sector in the storage device are the same, i.e., the sector boundaries of each sector are present in multiples, so that after determining the file system length of the first file system, the sector occupied by the first file system can be determined.
Further, correspondingly, a value larger than the field value and corresponding to the sector boundary of the next sector, i.e., an offset value aligned with the sector boundary, may also be determined. For example, the 4K sectors represent 4096 bytes occupied by the sectors, and the data corresponding to each sector boundary satisfies a multiple relationship with the 4K bytes; if the first file system occupies 4 sectors (e.g., sectors I-IV), the offset value is a data value aligned to a 4 kbyte boundary, i.e., a value aligned to a sector boundary of a multiple of 4 kbyte, e.g., a value of a sector boundary of sector V (a next sector of sector IV) is used as the offset value.
After determining the offset value, the location of the offset value on the first partition is taken as the starting location of the target sector, and the ending location of the first partition is taken as the ending location of the target sector, that is, the storage space corresponding to the location corresponding to the offset value to the ending location (that is, the ending boundary of the first partition) in the first partition is taken as the second partition. For example, if the first partition occupies 5 sectors of the storage device, and the first file system occupies 4 consecutive sectors, the remaining sectors serve as the storage space corresponding to the second partition. Therefore, the virtual partition is created in the residual storage space of the first partition to store the second file system, and the waste of storage resources can be effectively reduced.
And S150, mounting each file system on the block equipment associated with the first partition based on the read-write attribute preset by the file system.
After detecting the storage device, the operating system of the embedded communication device creates a block device corresponding to the storage device, and it can be understood that the block device is a logical entity corresponding to a section of continuous space in the storage device in the operating system, for example, a corresponding disk symbol corresponds to a block device in a Windows operating system, and for a C disk, a D disk, etc. divided after disk partition, corresponds to a block device and is associated with a section of continuous space in the storage device. Likewise, after parsing the partition table, corresponding block devices are created for each partition, and it should be appreciated that in the Windows operating system, the block devices are represented in the form of disks; in the Linux operating system, the block device is represented in the form of a disk device file.
For example, the root file system of the embedded communication device includes a first file system and a second file system, where the first file system is a squarewas, the second file system is Ext4, and the corresponding read-write attributes are respectively: the read-write attribute of the squarfs is read-only, while the read-write attribute of Ext4 is read-write.
After the first partition and the second partition are determined, corresponding block devices are created, and because the second partition serves as a virtual partition in the first partition, the target block devices created corresponding to the second partition in the application are associated with the first partition, such as the first block device corresponding to the first partition, and the target block devices corresponding to the second partition, such as the second block device, are associated with the first partition.
The first file system is mounted on a mounting point corresponding to the first block device, and the second file system is mounted on a mounting point corresponding to the second block device. It will be appreciated that for a legitimate file system in a storage device, it may be possible to provide the user with access to the files and directories of that file system by way of a mount operation. For example, in the Windows operating system, the mount operation is to execute corresponding disk symbols, such as a D disk, an E disk, etc., on the block device where the file system is located; in Linux operating systems, the mount operation is to mount the block device where the specified file system is located to an existing directory. Thus, the corresponding mount point includes an icon, a directory, and the like. In addition, the read-write authority of the first block device and the second block device is determined according to the read-write attribute of the mounted file system.
In an embodiment, when the read-write attribute of the first file system is read-only, correspondingly, the read-write authority of the first block device is set to be read-only, and the first file system is mounted on a mounting point corresponding to the first block device, and the first block device is used as a read-only layer of the root file system.
In an embodiment, the read-write attribute of the second file system is readable and writable, and the block device corresponding to the second partition is a second block device. And under the condition that the read-write attribute of the second file system is readable and writable, the second file system is mounted on a mounting point corresponding to the second block device, and the second block device is also used as a readable and writable upper layer of the root file system.
It should be noted that, in the Linux operating system, the overlay fs is a Linux-oriented file system service, which implements joint mount for other file systems, and the second file system and the first file system may be stacked through the overlay fs, and mount the second file system as a readable and writable upper layer of the root file system.
According to the scheme, validity check is carried out through the head information of the first file system, so that the empty storage space of the partition where the first file system is located is detected, a virtual partition block device file is created in the empty storage space and used as an independently accessible space for mounting the second file system, the first file system and the second file system are stored in a single partition, the available space of the second file system is determined according to the actual size of the first file system, the storage space is reasonably utilized, waste of storage resources is avoided, and the reliability of the system is improved.
In an embodiment, before the partition table is acquired and parsed, that is, in the data initialization stage, for the creation of the first partition, referring to fig. 3, the file system storage and mounting method provided in the embodiment of the present application further includes the following steps:
step S310, creating an image file of the first file system.
Step S320, a first partition is created on the storage device, and an image file is written in the starting position of the first partition.
Step S330, the first partition is used as a mounting partition of the root file system and is recorded in the kernel starting parameter.
It will be appreciated that, when the first partition is created, the number of sectors occupied by the first partition, the sector number, and other information are recorded in the partition table, so as to facilitate resolving the information of each partition in the storage device. Of course, the image of the first file system is written from the start position of the first partition, where the start position is the boundary of the sector that starts in the storage space occupied by the first partition.
The first partition is used as a mounting partition of the root file system, namely, the root file system is mounted on block equipment corresponding to the first partition. When the kernel starting parameter is used as a configuration parameter and the first partition is recorded in the kernel starting parameter as a mounting partition of the root file system, if the first partition is recorded in the root parameter, block equipment corresponding to the first partition can be designated as block equipment mounted on the root file system during equipment initialization.
After the logical partition is divided in the storage device, the first partition corresponding to the first file system is recorded in the kernel starting parameter after the mirror image file of the first file system is written in, so that the first partition is used as a mounting partition of the root file system after the equipment is started, storage space is allocated for the first file system and the second file system in the first partition, storage resources of the first partition are reasonably utilized, and waste of the storage resources is avoided.
Fig. 4 is a schematic diagram of a logical partition provided in an embodiment of the present application, where in practical application, a storage device is divided into a plurality of logical partitions, and partition information of each partition, such as a start offset, a partition length, a partition name, and the like, of each partition is recorded in a partition table stored in the storage device.
After the operating system detects the storage device, the partition table is acquired and parsed to create corresponding block devices for each partition. When partition information of a first partition (i.e., partition B) is recorded in the partition table, for example, it is determined whether or not the first partition exists by checking the naming of each partition, and when the partition name of the corresponding partition B is detected, it may be determined that the first partition storing the first file system exists in the storage device.
Correspondingly, header information of the first file system is read from the partition B, for example, the first file system (e.g., squarfs) is stored in the partition B, and the header information is stored in a starting position of the partition B. And determining the validity of the first file system in the partition B through judging the head information and the preset verification conditions.
In the case that there is a legal squarfs, an offset value D that is greater than the file system length C and aligned with a 4 kbyte boundary is calculated according to the file system length C carried in the header information of the first file system, so that a virtual partition is divided in the partition B with the offset value D as a starting position, and a second file system (e.g., ext 4) is created in the virtual partition. In addition, based on the read-only attribute of the first file system, the first file system is mounted on a mounting point corresponding to a first piece of equipment corresponding to the partition B, and the first piece of equipment is used as a read-only layer of the root file system; based on the readable and writable attribute of the second file system, the second file system is mounted on a mounting point corresponding to a second block device of the corresponding virtual partition, and the second block device is used as a readable and writable upper layer of the root file system.
Fig. 5 is a schematic diagram of a file system storage and mounting device according to an embodiment of the present application, where the device is configured to execute the file system storage and mounting method according to the foregoing embodiment, and has functional modules and beneficial effects of executing the foregoing method. As shown in the figure, the device specifically comprises: a first information acquisition module 501, a second information acquisition module 502, an information verification module 503, a partition creation module 504, and a mounting module 505.
The first information obtaining module 501 is configured to obtain and parse a partition table, where the partition table is used to record partition information corresponding to each partition in the storage device.
The second information obtaining module 502 is configured to obtain header information corresponding to the first file system if a first partition corresponding to the first file system is recorded in the partition table.
The information verification module 503 is configured to perform validity verification on the first file system according to the header information and a preset verification condition.
The partition creation module 504 is configured to create a target block device corresponding to storing the second file system, the target block device corresponding to a target sector within the first partition, if the first file system passes the validation.
The mounting module 505 is configured to mount each file system on a mounting point corresponding to a block device associated with the first partition based on a read-write attribute preset by the file system.
On the basis of the above embodiment, the header information includes a magic word, a compression option, a version number, and a file system length; the information verification module 503 is further configured to:
confirming whether the magic word is a first preset value, whether the compression option is a second preset value, whether the version corresponding to the version number is a version supported by the system and whether the length of the file system is smaller than that of the first partition;
when the magic word is a first preset value, the compression option is a second preset value, the version number is a version supported by the system and the length of the file system is smaller than that of the first partition, determining that the first file system passes the validity verification.
On the basis of the above embodiment, the partition creation module 504 is further configured to:
determining a field value corresponding to the file system length of the first file system according to the file system length carried by the header information;
determining an offset value that is greater than the field value and that aligns with the sector boundary based on the field value;
the position of the offset value on the first partition is taken as the starting position of the target sector, and the ending position of the first partition is taken as the ending position of the target sector.
On the basis of the above embodiment, the method further includes an initialization module configured to:
creating an image file of the first file system;
creating a first partition on a storage device, and writing an image file in the starting position of the first partition;
the first partition is used as a mounting partition of the root file system and is recorded in a kernel starting parameter.
On the basis of the embodiment, the root file system comprises a first file system and a second file system, and the first block device is associated with the first partition; mounting module 505 is further configured to:
if the read-write attribute of the first file system is read-only, the read-write authority of the first block device is set to be read-only, the first file system is mounted on a mounting point corresponding to the first block device, and the first block device is used as a read-only layer of the root file system.
On the basis of the above embodiment, the target block device includes a second block device, where the second block device is associated with the first partition, and the mounting module 505 is further configured to:
and if the read-write attribute of the second file system is readable and writable, mounting the second file system on a mounting point corresponding to the second block device, and taking the second block device as a readable and writable upper layer of the root file system.
On the basis of the above embodiment, mounting module 505 is further configured to:
the second file system is mounted as a readable and writable upper layer of the root file system through the overlay fs.
It should be noted that, in the above embodiment of the file system storage and mounting apparatus, each included functional module is only divided according to the functional logic, but not limited to the above division, so long as the corresponding function can be implemented; in addition, the specific names of the functional modules are only for distinguishing from each other, and are not used for limiting the protection scope of the application.
Fig. 6 is a schematic structural diagram of an electronic device provided in the embodiment of the present application, where the device may be used to execute the file system storage and mounting method provided in the foregoing embodiment, and has corresponding functional modules and beneficial effects of the execution method, and as shown in the drawing, the device includes a processor 601, a memory 602, an input device 603, and an output device 604, where the number of processors 601 in the device may be one or more, and in the drawing, one processor 601 is taken as an example. The processor 601, memory 602, input means 603 and output means 604 in the device may be connected by a bus or other means, in the figure by way of example. The memory 602 is used as a computer readable storage medium for storing a software program, a computer executable program, and modules, such as program instructions/modules corresponding to the file system storage and mounting method in the embodiments of the present application. The processor 601 executes various functional applications of the device and data processing, i.e., implements the file system storage and mounting methods described above, by running software programs, instructions, and modules stored in the memory 602.
The memory 602 may include primarily a program storage area and a data storage area, wherein the program storage area may store an operating system, at least one application program required for functionality; the storage data area may store data created according to the use of the terminal device, etc. In addition, the memory 602 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid-state storage device. In some examples, memory 602 may further include memory located remotely from processor 310, which may be connected to the terminal device via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The input means 603 may be used to receive input numeric or character information and to generate key signal inputs related to user settings and function control of the device. The output means 604 may be used to send or display key signal outputs related to user settings and function control of the device.
The present embodiments also provide a storage medium storing computer-executable instructions that, when executed by a processor, are configured to perform related operations in a file system storage and mounting method provided by the embodiments of the present application.
Computer-readable storage media, including both permanent and non-permanent, removable and non-removable media, may be implemented in any method or technology for storage of information. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of storage media for a computer 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 technology, compact disc read only memory (CD-ROM), digital Versatile Disks (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices, or any other non-transmission medium which can be used to store information that can be accessed by a computing device.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article or apparatus that comprises an element.
Note that the above is only a preferred embodiment of the present application and the technical principle applied. Those skilled in the art will appreciate that the present application is not limited to the particular embodiments described herein, but is capable of numerous obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the present application. Therefore, while the present application has been described in connection with the above embodiments, the present application is not limited to the above embodiments, but may include many other equivalent embodiments without departing from the spirit of the present application, the scope of which is defined by the scope of the appended claims.

Claims (10)

1. A method for storing and mounting a file system, comprising:
the method comprises the steps of obtaining and analyzing a partition table, wherein the partition table is used for recording partition information corresponding to each partition in a storage device;
if a first partition corresponding to and storing a first file system is recorded in the partition table, acquiring header information corresponding to the first file system;
carrying out validity verification on the first file system according to the header information and preset verification conditions;
if the first file system passes the validity verification, creating target block equipment for correspondingly storing a second file system, wherein the target block equipment corresponds to a target sector in the first partition;
and mounting each file system on a mounting point corresponding to the block equipment associated with the first partition based on the read-write attribute preset by the file system.
2. The file system storage and mounting method of claim 1, wherein the header information includes a magic word, a compression option, a version number, and a file system length;
the verifying the validity of the first file system according to the header information and the preset verification condition comprises the following steps:
confirming whether the magic word is a first preset value, whether the compression option is a second preset value, whether the version corresponding to the version number is a version supported by a system, and whether the length of the file system is smaller than that of the first partition;
and when the magic word is the first preset value, the compression option is the second preset value, the version number is the version supported by the system and the length of the file system is smaller than that of the first partition, determining that the first file system passes the validity verification.
3. The file system storage and mounting method according to claim 1 or 2, wherein if the first file system passes the validity verification, creating a target block device corresponding to storing a second file system, the target block device corresponding to a target sector in the first partition includes:
determining a field value corresponding to the file system length of the first file system according to the file system length carried by the header information;
determining an offset value that is greater than the field value and aligns with a sector boundary based on the field value;
the position of the offset value on the first partition is taken as the starting position of the target sector, and the ending position of the first partition is taken as the ending position of the target sector.
4. The file system storage and mounting method of claim 1, further comprising, prior to acquiring and parsing the partition table:
creating an image file of the first file system;
creating the first partition on a storage device, and writing the image file in the starting position of the first partition;
and taking the first partition as a mounting partition of the root file system and recording the first partition in a kernel starting parameter.
5. The file system storage and mounting method of claim 1, wherein a root file system comprises the first file system and the second file system, a first piece of equipment being associated with the first partition;
the mounting each file system on the mounting point corresponding to the block device associated with the first partition based on the read-write attribute preset by the file system includes:
if the read-write attribute of the first file system is read-only, setting the read-write permission of the first block device to be read-only, and mounting the first file system on a mounting point corresponding to the first block device, wherein the first block device is used as a read-only layer of the root file system.
6. The file system storage and mounting method of claim 5, wherein the target block device comprises a second block device, the second block device being associated with the first partition; the mounting each file system on the mounting point corresponding to the block device associated with the first partition based on the read-write attribute preset by the file system further comprises:
and if the read-write attribute of the second file system is readable and writable, mounting the second file system on a mounting point corresponding to the second block device, and taking the second block device as a readable and writable upper layer of the root file system.
7. The method for storing and mounting a file system according to claim 6, wherein if the read-write attribute of the second file system is readable and writable, mounting the second file system on a mounting point corresponding to the second block device, and taking the second block device as a readable and writable upper layer of the root file system includes:
and mounting the second file system as a readable and writable upper layer of the root file system through an overlay FS.
8. A file system mount and storage device, comprising:
the first information acquisition module is configured to acquire and analyze a partition table, wherein the partition table is used for recording partition information corresponding to each partition in the storage device;
the second information acquisition module is configured to acquire header information corresponding to a first file system if a first partition corresponding to the first file system is recorded in the partition table;
the information verification module is configured to verify the validity of the first file system according to the header information and the verification conditions;
the partition creation module is configured to create target block equipment for correspondingly storing a second file system if the first file system passes the validity verification, wherein the target block equipment corresponds to a target sector in the first partition;
and the mounting module is configured to mount each file system on a mounting point corresponding to the block equipment associated with the first partition based on the read-write attribute preset by the file system.
9. An electronic device, the device comprising:
one or more processors;
storage means for storing one or more programs which when executed by the one or more processors cause the one or more processors to implement the file system storage and mounting method of any of claims 1-7.
10. A storage medium storing computer executable instructions which, when executed by a processor, are for performing the file system storage and mounting method of any of claims 1-7.
CN202310436413.3A 2023-04-23 2023-04-23 File system storage and mounting method, device, equipment and storage medium Active CN116166205B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310436413.3A CN116166205B (en) 2023-04-23 2023-04-23 File system storage and mounting method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310436413.3A CN116166205B (en) 2023-04-23 2023-04-23 File system storage and mounting method, device, equipment and storage medium

Publications (2)

Publication Number Publication Date
CN116166205A true CN116166205A (en) 2023-05-26
CN116166205B CN116166205B (en) 2023-07-04

Family

ID=86414945

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310436413.3A Active CN116166205B (en) 2023-04-23 2023-04-23 File system storage and mounting method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN116166205B (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5675769A (en) * 1995-02-23 1997-10-07 Powerquest Corporation Method for manipulating disk partitions
US5930831A (en) * 1995-02-23 1999-07-27 Powerquest Corporation Partition manipulation architecture supporting multiple file systems
US20030084368A1 (en) * 2001-09-13 2003-05-01 International Business Machines Corporation Method and system for root filesystem replication
CN102693283A (en) * 2012-05-07 2012-09-26 深圳市共进电子股份有限公司 Data partition storage method and system boot method of embedded system
KR20140026821A (en) * 2012-08-23 2014-03-06 한국전자통신연구원 Method and apparatus for recovering partition using backup boot record
CN113553006A (en) * 2021-07-12 2021-10-26 山东华芯半导体有限公司 Secure encrypted storage system for realizing data writing to read-only partition
CN115562590A (en) * 2022-10-21 2023-01-03 济南浪潮数据技术有限公司 Method, system, equipment and storage medium for using cloud hard disk by cloud host

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5675769A (en) * 1995-02-23 1997-10-07 Powerquest Corporation Method for manipulating disk partitions
US5930831A (en) * 1995-02-23 1999-07-27 Powerquest Corporation Partition manipulation architecture supporting multiple file systems
US20030084368A1 (en) * 2001-09-13 2003-05-01 International Business Machines Corporation Method and system for root filesystem replication
CN102693283A (en) * 2012-05-07 2012-09-26 深圳市共进电子股份有限公司 Data partition storage method and system boot method of embedded system
KR20140026821A (en) * 2012-08-23 2014-03-06 한국전자통신연구원 Method and apparatus for recovering partition using backup boot record
CN113553006A (en) * 2021-07-12 2021-10-26 山东华芯半导体有限公司 Secure encrypted storage system for realizing data writing to read-only partition
CN115562590A (en) * 2022-10-21 2023-01-03 济南浪潮数据技术有限公司 Method, system, equipment and storage medium for using cloud hard disk by cloud host

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
姚罡;李大军;梅顺良;: "硬盘分区链表结构分析与应用", 微计算机信息, no. 09 *

Also Published As

Publication number Publication date
CN116166205B (en) 2023-07-04

Similar Documents

Publication Publication Date Title
KR101403305B1 (en) Method and apparatus for recovering partition using backup boot record
CN111125447A (en) Metadata access method, device and equipment and readable storage medium
CN107506221A (en) Application program updating method, apparatus and equipment
WO2016183951A1 (en) System upgrade method and terminal
CN107479823B (en) Data verification method and device in random read-write file test
CN110659257B (en) Metadata object repairing method, device, equipment and readable storage medium
CN109710286B (en) System upgrading method, device, equipment and storage medium
WO2022095844A1 (en) Elastic block service mounting method and apparatus thereof
CN112148794A (en) Version management method and device of intelligent contract and storage medium
CN109634524B (en) Data partition configuration method, device and equipment of data processing daemon
US7814334B2 (en) Method and apparatus for changing and adding activation keys for functions of digital content without having to change and recompile the digital content
CN116166205B (en) File system storage and mounting method, device, equipment and storage medium
US7617374B2 (en) Hard disk testing method under extensible firmware interface
CN110990207B (en) BPS memory test method, system, terminal and storage medium based on Whitley platform
CN108197041B (en) Method, device and storage medium for determining parent process of child process
CN110321133B (en) H5 application deployment method and device
CN110968888B (en) Data processing method and device
CN107766196B (en) Method and device for starting check of computing device
US8359456B2 (en) Generating random addresses for verification of distributed computerized devices
CN112015672A (en) Data processing method, device, equipment and storage medium in storage system
CN111143418A (en) Data reading method, device and equipment for database and storage medium
CN111813416A (en) File packaging method, device and equipment and storage medium
CN116382785B (en) Method and device for data processing, computing equipment and storage medium
CN111726373A (en) Communication link construction method, device and equipment
CN115220977A (en) Method, device, equipment and readable medium for solving drive letter drift

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant