CN112579345A - Method for realizing file system restoration based on device mapper mechanism - Google Patents
Method for realizing file system restoration based on device mapper mechanism Download PDFInfo
- Publication number
- CN112579345A CN112579345A CN201910931908.7A CN201910931908A CN112579345A CN 112579345 A CN112579345 A CN 112579345A CN 201910931908 A CN201910931908 A CN 201910931908A CN 112579345 A CN112579345 A CN 112579345A
- Authority
- CN
- China
- Prior art keywords
- file system
- read
- readable
- device mapper
- partition
- 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.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 18
- 238000005192 partition Methods 0.000 claims abstract description 26
- 238000013507 mapping Methods 0.000 claims abstract description 21
- 238000010586 diagram Methods 0.000 description 3
- 230000003287 optical effect Effects 0.000 description 3
- 101100226364 Arabidopsis thaliana EXT1 gene Proteins 0.000 description 2
- 230000007547 defect Effects 0.000 description 2
- 238000013461 design Methods 0.000 description 2
- 238000011161 development Methods 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 238000000926 separation method Methods 0.000 description 2
- 101100226366 Arabidopsis thaliana EXT3 gene Proteins 0.000 description 1
- 230000005540 biological transmission Effects 0.000 description 1
- 230000006835 compression Effects 0.000 description 1
- 238000007906 compression Methods 0.000 description 1
- 238000001914 filtration Methods 0.000 description 1
- 238000012423 maintenance Methods 0.000 description 1
- 208000034420 multiple type III exostoses Diseases 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/07—Responding to the occurrence of a fault, e.g. fault tolerance
- G06F11/14—Error detection or correction of the data by redundancy in operation
- G06F11/1402—Saving, restoring, recovering or retrying
- G06F11/1446—Point-in-time backing up or restoration of persistent data
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/10—File systems; File servers
- G06F16/11—File system administration, e.g. details of archiving or snapshots
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Quality & Reliability (AREA)
- Data Mining & Analysis (AREA)
- Databases & Information Systems (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The invention provides a method for realizing file system restoration based on device mapper mechanism, comprising the following steps: s1, installing a device mapper software package in the Linux system; s2, setting the file system as a read-only file system; s3, calling a mounting instruction in the device mapper software package to mount a readable and writable partition behind the read-only file system by using an equipment mapping mechanism to obtain a new file system with the readable and writable partition; performing read-write operation through the read-write partition, wherein the original read-only file system keeps read-only property; s4, the readable-writable partition in the step S3 copies the read-only file system in the step S2, and when the original read-only file system is damaged or unavailable, the copied read-only file system is started through the readable-writable partition.
Description
Technical Field
The invention relates to the field of computer operating systems, in particular to a method for restoring a file system based on a device mapper 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. In particular, when the system file system is damaged, there is no way to restore the file system.
Disclosure of Invention
In order to solve the problems in the prior art, the present invention aims to: in view of the defects of the conventional Read-only file system, a file system which can effectively ensure the security and can be Read and written is required. Therefore, a Read-only file system is 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. Especially, when the original read-only file system is damaged, the read-write attribute can be utilized for restoration, the system efficiency is effectively improved, and the problem caused when the original file system cannot be used is prevented.
Specifically, the invention provides a method for realizing file system restoration based on device mapper mechanism, comprising the following steps:
s1, installing a device mapper software package in the Linux system;
s2, setting the file system as a read-only file system;
s3, calling a mounting instruction in the device mapper software package to mount a readable and writable partition behind the read-only file system by using an equipment mapping mechanism to obtain a new file system with the readable and writable partition; performing read-write operation through the read-write partition, wherein the original read-only file system keeps read-only property;
s4, the readable-writable partition in the step S3 copies the read-only file system in the step S2, and when the original read-only file system is damaged or unavailable, the copied read-only file system is started through the readable-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.
3. When the original read-only file system is damaged or cannot be used, the backup file system can be quickly started, and the time and cost for maintenance are saved.
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 present invention specifically relates to a method for restoring a file system based on a device mapper mechanism, where the method includes the following steps:
s1, installing a device mapper software package in the Linux system;
s2, setting the file system as a read-only file system;
s3, calling a mounting instruction in the device mapper software package to mount a readable and writable partition behind the read-only file system by using an equipment mapping mechanism to obtain a new file system with the readable and writable partition; performing read-write operation through the read-write partition, wherein the original read-only file system keeps read-only property;
s4, the readable-writable partition in the step S3 copies the read-only file system in the step S2, and when the original read-only file system is damaged or unavailable, the copied read-only file system is started through the readable-writable partition.
The file system is named rootfs.
The readable and writable file is named data.
The read-only file system with the readable and writable partition is rootfs.
The file system is applied to a Linux system, and the Linux system is a Redhat, 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 writable and readable partition in step S4 copies the read-only file system in step S2 and stores the copied read-only file system in a specific directory for reading when the read-only file system needs to be restored.
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.
Claims (8)
1. A method for realizing file system restoration based on device mapper mechanism is characterized in that the method comprises the following steps:
s1, installing a device mapper software package in the Linux system;
s2, setting the file system as a read-only file system;
s3, calling a mounting instruction in the device mapper software package to mount a readable and writable partition behind the read-only file system by using an equipment mapping mechanism to obtain a new file system with the readable and writable partition; performing read-write operation through the read-write partition, wherein the original read-only file system keeps read-only property;
s4, the readable-writable partition in the step S3 copies the read-only file system in the step S2, and when the original read-only file system is damaged or unavailable, the copied read-only file system is started through the readable-writable partition.
2. The method for restoring a file system based on device mapper mechanism as claimed in claim 1, wherein said file system is named rootfs.
3. The method for implementing file system restoration based on device mapper mechanism as claimed in claim 1, wherein said readable and writable file is named data.
4. The method of claim 1, wherein the read-only file system with the readable and writable partition is rootfs.ext4+ data.img.
5. The method according to claim 1, wherein the file system is applied to a Linux system, and the Linux system is a Red hat, CentOS or Ubuntu Server release system.
6. The method for implementing file system restoration based on device mapper mechanism as claimed in claim 1, wherein said device mapper software package is a device mapper software package in Packages.
7. The method according to claim 1, wherein said step S3 further comprises: 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.
8. The method according to claim 1, wherein said writable-readable partition in step S4 copies the read-only file system in step S2 and stores it in a specific directory for reading when the read-only file system needs to be restored.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910931908.7A CN112579345A (en) | 2019-09-29 | 2019-09-29 | Method for realizing file system restoration based on device mapper mechanism |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910931908.7A CN112579345A (en) | 2019-09-29 | 2019-09-29 | Method for realizing file system restoration based on device mapper mechanism |
Publications (1)
Publication Number | Publication Date |
---|---|
CN112579345A true CN112579345A (en) | 2021-03-30 |
Family
ID=75111040
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910931908.7A Pending CN112579345A (en) | 2019-09-29 | 2019-09-29 | Method for realizing file system restoration based on device mapper mechanism |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112579345A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114546501A (en) * | 2022-01-28 | 2022-05-27 | 郑州信大捷安信息技术股份有限公司 | Method for starting Linux operating system in physical read-only disk |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102262568A (en) * | 2010-05-25 | 2011-11-30 | 上海中标软件有限公司 | Power-down prevention Linux system startup method |
CN106776128A (en) * | 2016-11-29 | 2017-05-31 | 邦彦技术股份有限公司 | Method for ensuring normal start of Linux operating system |
CN109445861A (en) * | 2018-10-18 | 2019-03-08 | 深圳市网心科技有限公司 | System start method, device, computer installation and storage medium |
CN110162429A (en) * | 2019-05-27 | 2019-08-23 | 深圳市网心科技有限公司 | System repair, server and storage medium |
-
2019
- 2019-09-29 CN CN201910931908.7A patent/CN112579345A/en active Pending
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102262568A (en) * | 2010-05-25 | 2011-11-30 | 上海中标软件有限公司 | Power-down prevention Linux system startup method |
CN106776128A (en) * | 2016-11-29 | 2017-05-31 | 邦彦技术股份有限公司 | Method for ensuring normal start of Linux operating system |
CN109445861A (en) * | 2018-10-18 | 2019-03-08 | 深圳市网心科技有限公司 | System start method, device, computer installation and storage medium |
CN110162429A (en) * | 2019-05-27 | 2019-08-23 | 深圳市网心科技有限公司 | System repair, server and storage medium |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114546501A (en) * | 2022-01-28 | 2022-05-27 | 郑州信大捷安信息技术股份有限公司 | Method for starting Linux operating system in physical read-only disk |
CN114546501B (en) * | 2022-01-28 | 2023-10-24 | 郑州信大捷安信息技术股份有限公司 | Method for starting Linux operating system in physical read-only disk |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US7603533B1 (en) | System and method for data protection on a storage medium | |
US8015157B2 (en) | File sharing system, file server, and method for managing files | |
US7953948B1 (en) | System and method for data protection on a storage medium | |
US5086502A (en) | Method of operating a data processing system | |
US8229897B2 (en) | Restoring a file to its proper storage tier in an information lifecycle management environment | |
JP4199993B2 (en) | How to get a snapshot | |
JP5164980B2 (en) | System and method for managing data deduplication in a storage system that uses a permanent consistency point image | |
US7865772B2 (en) | Management device and management method | |
US8370593B2 (en) | Method and apparatus to manage groups for deduplication | |
US8793447B2 (en) | Restoration of a parent LUN through modification of a read-write clone LUN as the parent LUN | |
US20110022811A1 (en) | Information backup/restoration processing apparatus and information backup/restoration processing system | |
US7617227B2 (en) | Storage control sub-system comprising virtual storage units | |
US9037541B2 (en) | Metadata for data storage array | |
US8402237B2 (en) | Presentation of a read-only clone LUN to a host device as a snapshot of a parent LUN | |
JP2005535962A (en) | Storage virtualization by layering virtual disk objects on the file system | |
US10572184B2 (en) | Garbage collection in data storage systems | |
US8341119B1 (en) | Flexible copies having different sub-types | |
US11321007B2 (en) | Deletion of volumes in data storage systems | |
US20070033361A1 (en) | Apparatus, system, and method for fastcopy target creation | |
US20040098394A1 (en) | Localized intelligent data management for a storage system | |
JP4779012B2 (en) | System and method for restoring data on demand for instant volume restoration | |
US20060271608A1 (en) | Methods and systems for automatically identifying a modification to a storage array | |
CN112579345A (en) | Method for realizing file system restoration based on device mapper mechanism | |
CN112988468A (en) | Method for virtualizing operating system using Ceph and computer-readable storage medium | |
CN110928840B (en) | Method for reading QNX6 file system |
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 |