In some projects, we do not want the system files to be modified, such as the router's system files and so on. We need to use a read-only file system to protect our system files from being modified.
Common read-only file systems are: Cramfs file system and SQUASHFS file system (successor to CRAMFS file system)
I.. cramfs file System: http://sourceforge.net/projects/cramfs/
1. Compressed ROM filesystem
Mainly used in embedded Linux system, simple and space efficient
2. Features:
Maximum partition support: 272MB (256MB + 16MB)
Maximum files Supported: 16MB
Compression format: Zlib, compression ratio can generally reach 1:2, each page compression processing ———— > Support Random Read
Dynamic decompression: Access to the data in real-time decompression access to the page to memory, saving memory space
Use transparency: in-memory data storage location after decompression and decompression is maintained by the Cramfs file system itself, transparent to external use
Ii. SQUASHFS File system: Substitution of Cramfs
1. http://www.squashfs.org
Designed for Universal read-only file systems
2. Features:
Maximum Partition support: 16EB
Maximum files Supported: 2TB
Supports multiple compression formats: GZIP lzma/lzma2 (XZ) LZO
Third, the production of Cramfs file system
1, installation and production tools
sudo apt-get install Cramfsprogs
There will be 2 commands when the installation is successful.
Mkcramfs: Creating a file system image
CRAMFSCK: Some operations on file system mirroring
2, making file system
MKCRAMFS option (can not) directory name Mirror name
CRAMFSCK Mirror Name: Verify that it is correct
Cramfsck-x image name: Unzip the image
Four, SQUASHFS file system production
1. Installation of production tools
sudo apt-get install Squashfs-tools
MKSQUASHFS: Making Images
UNSQUASHFS: Some operations on mirroring
2, making file system
MKSQUASHFS source1 source2 ... dest [options] [-e list of exclude dirs/files]
Main options:
-comp <comp> Specify compression algorithm: gzip (default)/LZO/XZ
-B <block_size> Set block size, unit Bytes, default 131072 Bytes (1MB)
-no-exports does not support NFS file system export
-no-sparse does not detect sparse files
-no-xattrs does not store extended file attributes (xattr)
-xattrs Storage Extension file properties (default)
-noi inode node Table not compressed
-nod do not compress data blocks
-nof do not compress fragment blocks
-nox do not compress extended file properties
-no-fragments not using Fragment management
-always-use-fragments contrast block size file is also used fragment block
-no-duplicates do not check files repeatedly
-all-root Modify all file owners as root
-force-uid UID Sets the UID of all files to the specified UID
-force-gid GID set all files of GID for the specified GID
-nopad file system is not 4K byte aligned
-keep-as-directory If there is a directory in the specified source, create the root directory in the file system that contains the directory, not the contents of the directory
MKSQUASHFS Directory name Mirror name-no-exports-no-xattrs-all-root
Content extraction:
UNSQUASHFS [Options] filesystem [directories or files to extract]
Main options:
-d[est] <pathname> extract to the specified directory, default to "Squashfs-root"
-n[o-progress] do not show progress bar
-no[-xattrs] does not extract the Xattr property, the default extraction
-l[s] List file system contents without extracting extract
Because some files involve administrator rights, it is recommended that you use administrator privileges to create and decompress file system images to avoid some permissions errors.
Read-Only file system