squashfs文件系统初识

日期: 2008.07.08 16:36
 
  squashfs其实对于我们来说并不陌生,live cd或是安装cd都是我们学习linux必经的一步。本人接触这个文件系统是对安装盘的认识开始的。以asianux2.0或3.0为例,同理可以用于一切red hat发行版。squashfs 是在linux下将目录或文件打包成只读文件系统。如果你想实现压缩的话,需要kernel的支持,请访问如下链接:
http://www.squashfs-lzma.org/
   以下是官方的对其特性的描述:Data, inodes and directories are compressed.
Squashfs stores full uid/gids (32 bits), and file creation time.
Files up to 2^64 bytes are supported.  Filesystems can be up to 2^64 bytes.
Inode and directory data are highly compacted, and packed on byte
boundaries.  Each compressed inode is on average 8 bytes in length (the exact
length varies on file type, i.e. regular file, directory, symbolic link,
and block/char device inodes have different sizes).
Squashfs can use block sizes up to 1Mbytes (the default size is 128K).
Using 128K blocks achieves greater compression ratios than the normal 4K
block size.
File duplicates are detected and removed.
Both big and little endian architectures are supported.  The mksquashfs
program can generate filesystems for different endian architectures for
cases where the host byte ordering is different to the target.  This is
useful for embedded systems.
squashfs可完整的存储uid/gid和文件建立的时间。支持2的64次方byte的文件。可以指定block大小来打包。另外LZMA还有一个权威的表格beachmark.
此处我们不谈LZMA,只谈squashfs能起到什么作用。
在安装盘的根目录里,有这么一个文件/images/stage2.img
lee@lee-laptop:/media/sda6/lee/tmp/anaconda$ file stage2.img 
stage2.img: Squashfs filesystem, little endian, version 3.0, 68102631
bytes, 4938 inodes, blocksize: 65536 bytes, created: Wed Aug 29
16:58:29 2007
lee@lee-laptop:/media/sda6/lee/tmp/anaconda$ sudo mount -t squashfs -o loop stage2.img stage2lee@lee-laptop:/media/sda6/lee/tmp/anaconda$ du -sh stage2175M    stage2lee@lee-laptop:/media/sda6/lee/tmp/anaconda$ du -sh stage2.img 66M    stage2.imglee@lee-laptop:/media/sda6/lee/tmp/anaconda/stage2$ ls
etc  lib  modules  proc  usr  var
这就是我们的安装程序的运行根目录!包括安装程序anaconda.busybox等程序。
这个东西最大的作用就是其只读,不管你是什么用户,所有的文件和目录都是只读的。
如果你想实现自己的东西不被修改,那么就用这个文件系统吧。      如果想将自己的发行版做成live-cd的话,请将你的内核打上支持LZMA的patch.
原文地址:https://www.cnblogs.com/huapox/p/3299982.html