File system implementation method based on equipment mapping mechanism

文档序号:829300 发布日期:2021-03-30 浏览:15次 中文

阅读说明:本技术 一种基于设备映射机制的文件系统的实现方法 (File system implementation method based on equipment mapping mechanism ) 是由 唐鑫 于 2019-09-29 设计创作,主要内容包括:本发明提供一种基于设备映射机制的文件系统的实现方法,包括以下步骤:S1,在硬件分区中设定一预定目录,并在其中安装device mapper软件包;S2,设置文件系统属性为ro的一只读文件系统;设置一个可读写文件;S3,调用device mapper软件包里面的指令利用设备映射机制把所述的只读文件系统后面挂载一个可读写分区,用于存放所述的可读写文件;S4,获得一个带有可读写分区的只读文件系统。(The invention provides a method for realizing a file system based on a device mapping mechanism, which comprises the following steps: s1, setting a preset directory in the hardware partition, and installing the device mapper software package in the preset directory; s2, setting the attribute of the file system as ro; setting a readable and writable file; s3, calling an instruction in the device mapper software package to mount a readable-writable partition behind the read-only file system by using a device mapping mechanism, wherein the readable-writable partition is used for storing the readable-writable file; s4, obtaining a read-only file system with a readable and writable partition.)

1. A method for implementing a file system based on a device mapping mechanism is characterized by comprising the following steps:

s1, setting a preset directory in the hardware partition, and installing the device mapper software package in the preset directory;

s2, setting the attribute of the file system as ro; setting a readable and writable file;

s3, calling an instruction in the device mapper software package to mount a readable-writable partition behind the read-only file system by using a device mapping mechanism, wherein the readable-writable partition is used for storing the readable-writable file;

s4, obtaining a read-only file system with a readable and writable partition.

2. The method as claimed in claim 1, wherein the read-only file system is named rootfs.

3. The method as claimed in claim 1, wherein the writable and readable file is named data.

4. The method as claimed in claim 1, wherein the read-only file system with readable and writable partitions is rootfs.ext4+ data.img.

5. The method as claimed in claim 1, wherein the file system is a Linux system, and the Linux system is a Red hat, CentOS or Ubuntu Server release system.

6. The method as claimed in claim 1, wherein the device map software package is a device map software package in Packages.

7. The method for implementing a file system based on a device mapping mechanism as claimed in claim 1, wherein the step S3 further includes: creating a mapping table according to the configuration information; and transmitting the mapping table constructed by the user space into the kernel, and enabling the kernel to construct a dm _ table structure corresponding to the mapped device.

Technical Field

The invention relates to the field of computer operating systems, in particular to a method for realizing a file system based on a device mapping mechanism.

Background

With the continuous development of science and technology, especially the development of computer technology, and the arrival of the era of big data technology, Device mapper is more and more widely used. A Device Mapper is a mapping framework mechanism from a logical Device to a physical Device provided in a Linux 2.6 kernel, under which a user can conveniently make a Management policy for implementing storage resources according to his own needs, and currently, popular logical Volume managers under Linux, such as LVM2(Linux Volume Manager 2version), evms (enterprise Volume Management system), and dmrai (Device Mapper Raid tool), are implemented based on the mechanism. The method provides a highly modular kernel architecture for realizing the block Device driver for storage resource management, and the kernel architecture comprises three important object concepts, namely Mapped Device, Mapped Table and Target Device. The Mapping relation (the starting address, the range and the information such as the address offset and the Target type of the physical Device where the Target Device is located) described by the Mapping Table establishes Mapping with the Target Device, and the Target Device represents the physical space segment Mapped by the Mapped Device.

The Device mapper further embodies the principle of policy and mechanism separation in Linux kernel design, all work related to the policy is put into a user space to be completed, and the kernel mainly provides a mechanism required for completing the policies. The Device mapper user space related part is mainly responsible for configuring specific policies and control logics, such as how mapping is established between the logical devices and which physical devices, how mapping relationships are established, and the like, and the specific filtering and redirection work of the IO requests is completed by related codes in the kernel. The Device mapper mechanism thus consists of two parts — a Device mapper driver for kernel space, a Device mapper library for user space, and the dmsetup tool it provides.

On the other hand, conventional file systems can be divided into two categories according to read-write attributes:

read-only file system: i.e. a read-only file system, with attributes ro.

Readable and writable file system: the attribute is rw.

The traditional Read-only file system is Read-only (ro), and the Read-only file system has the advantages of better safety, capability of effectively protecting data of the file system and reducing the risk of damage to the file system, but the defect is obvious, and the user can not modify the data in the file system, so that the debugging and the use of the user are difficult.

Disclosure of Invention

In order to solve the problems in the prior art, aiming at the defects of the conventional Read-only file system, we need a file system which can effectively ensure security and can be Read and written, two schemes are preliminarily conceived, namely: in order to satisfy this requirement, two readable and writable file systems (rw) may be used, so that after the current file system is damaged due to an abnormal power failure or an emergency, another readable and writable file system for backup may be started, and this scheme may initially achieve the predetermined goal, but occupies twice the space of the file system, and based on the above consideration, the present invention aims to: the Read-only file system can be mounted with a readable and writable (rw) file system to achieve the purpose of meeting the Read-write requirement and saving space, so that the cost can be greatly reduced.

Specifically, the invention provides a method for implementing a file system based on a device mapping mechanism, which comprises the following steps:

s1, setting a preset directory in the hardware partition, and installing the device mapper software package in the preset directory;

s2, setting the attribute of the file system as ro; setting a readable and writable file;

s3, calling an instruction in the device mapper software package to mount a readable and writable partition behind the read-only file system by using a device mapping (device mapper) mechanism, wherein the readable and writable partition is used for storing the readable and writable file;

s4, obtaining a read-only file system with a readable and writable partition.

The application has the advantages that:

1. the file system made through the Device mapper mechanism inherits the security advantage of the Read-only file system and simultaneously meets the requirement of user space on the Read-write performance.

2. Compared to two readable writable (rw) file system schemes, the space of the file system is saved by one time.

Drawings

The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the invention and together with the description serve to explain the principles of the invention.

Fig. 1 is a schematic block diagram of the structure of a file system to which the present invention relates.

Fig. 2 is a block flow diagram of a method to which the present invention relates.

Detailed Description

Currently, the technical terms commonly used in the technical field include:

a file system: the software mechanism in the operating system that is responsible for managing and storing file information is called a file management system, referred to as a file system for short.

The Device mapper is a mapping frame mechanism from a logic Device to a physical Device provided in a Linux 2.6 kernel, and under the mapping frame mechanism, a user can conveniently make a management strategy for realizing storage resources according to the needs of the user. The Device mapper further embodies the principle of policy and mechanism separation in Linux kernel design, all work related to the policy is put into a user space to be completed, and the kernel mainly provides a mechanism required for completing the policies.

Read-only file system: a read-only file system.

ro-file/file system properties are read-only.

And rw, the file/file system attribute is readable and writable.

IMG is a file compression format (archive format), mainly for creating an image file (Disk image) of a Floppy Disk, which can be used to compress the content of an entire Floppy Disk (usually referred to as Floppy Disk, Floppy Disk or Disk) or an entire optical Disk. IMG this file format can be viewed as a superset of the ISO format. The IMG was developed because ISO can only compress storage media using both ISO9660 and UDF file systems, i.e., ISO can only take advantage of compressing CDs or DVDs. The opening mode can be optical disc burning, and can also be decompressed by software. IMG may be used for the following purposes: 1. digital storage, transmission, and copying of the contents of an entire floppy disk. 2. Can be mounted on a virtual floppy disk. In summary, the img format is a kind of mirroring. The IMG data files may be installed by making a data disc or using a virtual optical drive (e.g., WinMount).

EXT4 is a Fourth generation extended file system (english: four extended file system, abbreviated as EXT4) is a log file system under the Linux system, which is a successor version of the EXT3 file system.

The Device mapper is registered in the kernel as a block Device driver, and comprises three important object concepts, mapped Device, mapping table and target Device. The Mapped device is a logical abstraction, can be understood as a logical device provided outside the kernel, and establishes mapping through the mapping relation described by the mapping table and the target device. The mapping table from Mapped device to a target device is represented by a tuple consisting of variables representing the logical start address and range of the Mapped device, and the address offset of the physical device at the target device, and the type of the target (these addresses and offsets are in units of sectors of the disk, that is, 512 bytes in size). The Target device represents a physical space segment mapped by the mapped device, and for the logical device represented by the mapped device, the logical device is a physical device mapped to by the logical device. The three objects in Device mapper together with the target driver plug-in form an iterative Device tree. The top root node in the tree structure is mapped device which is finally provided as logic device, and the leaf node is the bottom physical device represented by target device.

As shown in fig. 1, the present application relates to a schematic block diagram of a structure of a document.

Assuming that a file system is named as a read-only file system with a rootfs.ext4 set attribute ro, a read-write file named as data.img is made, and a read-write partition data.img is spliced behind the rootfs.ext4 file system through a Device mapper mechanism, so that a read-only file system with a read-write (rw) partition which is spliced newly is obtained: rootfs. ext4+ data. img.

By utilizing a device map (device map) mechanism and a file system snapshot (snapshot) function of the Linux system, a Linux kernel or an existing program is not required to be modified. And the Linux system includes but is not limited to reddat, CentOS, Ubuntu Server, etc.

As shown in fig. 2, the method for implementing a file system based on a device mapping mechanism according to the present invention includes the following steps:

s1, setting a preset directory in the hardware partition, and installing the device mapper software package in the preset directory;

s2, setting the attribute of the file system as ro; setting a readable and writable file, wherein the read-only file system is named as rootfs.ext4;

s3, calling an instruction in the device mapper software package, and using a device mapping (device mapper) mechanism to mount a readable and writable partition behind the read-only file system for storing the readable and writable file, wherein the readable and writable file is named as data.img;

s4, obtaining a read-only file system with a readable and writable partition, wherein the read-only file system with the readable and writable partition is rootfs.ext4+ data.img.

The file system is applied to a Linux system, and the Linux system is a Red hat, CentOS or Ubuntu Server release system.

The device mapper software package is a device mapper software package in Packages.

The step S3 further includes: creating a mapping table according to the configuration information; and transmitting the mapping table constructed by the user space into the kernel, and enabling the kernel to construct a dm _ table structure corresponding to the mapped device.

The above description is only a preferred embodiment of the present invention, and is not intended to limit the present invention, and various modifications and changes may be made to the embodiment of the present invention by those skilled in the art. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

7页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种基于纠删码实现文件恢复的图文档管理系统

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!