quashfs是以linux 内核源码补丁的形式发布,附带mksquashfs工具,用于创建squash文件系统。squashfs可以将整个文件系统或者某个单一的目录压缩在一起, 存放在某个设备, 某个分区或者普通的文件中. 如果你将其压缩到一个设备中, 那么你可以将其直接mount起来使用; 而如果它仅仅是个文件,你可以将其当为一个loopback 设备使用. squashfs文件系统的设计令人欣喜. For archiving purposes, 它可以让你更加灵活的使用, 而且它比.tar.gz文档有更快的响应速度。
以下是squash文件系统的特点:
· 数据(data),节点(inode)和目录(directories)都被压缩。
· 保存了全部的32位UID/GIDS和文件的创建时间. (注: cramfs是8位,没有创建时间)。
· 支持多达4G的文件系统. (cramfs是16M)。
· 节点和目录都是高度压缩, 而且都是存储在字节边界(packed on byte boundaries); 所有压缩的节点长度平均在8个字节左右.(具体的长度根据文件的类型是不同的. 比如, 普通文件,目录,符号链接,块设备和字符设备的节点的大小就不一样)。
· squashfs可以允许块大小(block size)达32Kb(1.x)和64kb(2.x), 这样可以达到比4K块大小更大的压缩率。
· squashfs 2引进了碎片块(fragment blocks)的概念: 一种将许多比块size 小的文件存储在一个块中, 以达到更大的压缩率。
· 重复的文件会被检测并删除掉。
· 同时支持big和little endian架构. SQ可以将文件系统MOUNT到不同的字节顺序(byte-order)的机器上面
1.重新打包和编译Linux内核, 使之支持SQ.
2.编译mksquashfs工具.
3.使用mksquashf创建压缩文件系统.
4.试用: mount suqash文件系统到一个临时目录.
5.如果需要的话,更改/etc/fstab 或者起始脚本, 以使linux操作系统自动加载新的 squashfs 文件系统.
mksquashfs rootfs_station ${ZRT_ENV_TMP_STATION_ROOTFS_FILE_PATH} -comp xz
rootfs_station这个目录下是我们的文件系统,把他已xz的压缩方式,制作成squashfs,输出到**${ZRT_ENV_TMP_STATION_ROOTFS_FILE_PATH}**
使用:
mount -t squashfs /dev/mtdblock5 /system
首先要保证内核支持squashfs
https://blog.csdn.net/qq_38350702/article/details/106497628
https://manpages.debian.org/testing/squashfs-tools/mksquashfs.1.en.html
mksquashfs SOURCE [SOURCE2 …] DESTINATION [OPTIONS]
OPTIONS
Filesystem build options
-comp COMPRESSION
select COMPRESSION compression. Compressors available: gzip (default), lzo, xz.
-b BLOCK_SIZE
set data block to BLOCK_SIZE. Default 131072 bytes.
-no-exports
don’t make the filesystem exportable via NFS.
-no-sparse
don’t detect sparse files.
-no-xattrs
don’t store extended attributes.
-xattrs
store extended attributes (default).
-noI
do not compress inode table.
-noD
do not compress data blocks.
-noF
do not compress fragment blocks.
-noX
do not compress extended attributes.
-no-fragments
do not use fragments.
-always-use-fragments
use fragment blocks for files larger than block size.
-no-duplicates
do not perform duplicate checking.
-all-root
make all files owned by root.
-force-uid uid
set all file uids to uid.
-force-gid gid
set all file gids to gid.
-nopad
do not pad filesystem to a multiple of 4K.
-keep-as-directory
if one source directory is specified, create a root directory containing that directory, rather than the contents of the directory.
Filesystem filter options
-p PSEUDO_DEFINITION
Add pseudo file definition.
-pf PSEUDO_FILE
Add list of pseudo file definitions.
-sort SORT_FILE
sort files according to priorities in SORT_FILE. One file or dir with priority per line. Priority -32768 to 32767, default priority 0.
-ef EXCLUDE_FILE
list of exclude dirs/files. One per line.
-wildcards
Allow extended shell wildcards (globbing) to be used in exclude dirs/files
-regex
Allow POSIX regular expressions to be used in exclude dirs/files.
Filesystem append options
-noappend
do not append to existing filesystem.
-root-becomes NAME
when appending source files/directories, make the original root become a subdirectory in the new root called NAME, rather than adding the new source items to the original root.
Mksquashfs runtime options:
-version
print version, licence and copyright message.
-recover NAME
recover filesystem data using recovery file NAME.
-no-recovery
don’t generate a recovery file.
-info
print files written to filesystem.
-no-progress
don’t display the progress bar.
-processors NUMBER
Use NUMBER processors. By default will use number of processors available.
-read-queue SIZE
Set input queue to SIZE Mbytes. Default 64 Mbytes.
-write-queue SIZE
Set output queue to SIZE Mbytes. Default 512 Mbytes.
-fragment-queue SIZE
Set fragment queue to SIZE Mbytes. Default 64 Mbytes.
Miscellaneous options
-root-owned
alternative name for -all-root.
-noInodeCompression
alternative name for -noI.
-noDataCompression
alternative name for -noD.
-noFragmentCompression
alternative name for -noF.
-noXattrCompression
alternative name for -noX.
Compressors available and compressor specific options
gzip (no options) (default)
lzo (no options)
xz
-Xbcj filter1,filter2,…,filterN
Compress using filter1,filter2,…,filterN in turn (in addition to no filter), and choose the best compression. Available filters: x86, arm, armthumb, powerpc, sparc, ia64.
-Xdict-size DICT_SIZE
Use DICT_SIZE as the XZ dictionary size. The dictionary size can be specified as a percentage of the block size, or as an absolute value. The dictionary size must be less than or equal to the block size and 8192 bytes or larger. It must also be storable in the xz header as either 2^n or as 2n+2(n+1). Example dict-sizes are 75%, 50%, 37.5%, 25%, or 32K, 16K, 8K etc.