The SquashFS home site is located at http://squashfs.sourceforge.net/ - it contains news for the latest release and it's changelog, as well as general information about SquashFS. You can grab the latest version at the SquashFS project page at SourceForge.
Squashfs is also avaliable with LZMA compression at http://www.squashfs-lzma.org/
In order to read SquashFS, you need it supported in your kernel - just as if it was a reiserfs or ext3 file system. You have to make sure there is an appropriate patch for your kernel version. It should be located in kernel-patches/linux-2.x.y subdirectory of the SquashFS source tree. Also, remember that in most cases you will need a clean (original) Linux kernel source from kernel.org. If your kernel source is from a distro vendor, it may be already pre-patched with custom vendor patches, and patching with a SquashFS patch will almost surely not work, as SquashFS patches are made against original Linux kernels. However some distributions make avaliable SquashFS-kernel-modules and SquashFS-tools packages from the repositories. If you consider to use these packages from your distro, you don't need to patch your kernel or to build SquashFS tools from source. In such case, make sure to get the proper module for your kernel from the distro repositories. Please note that doing so you will have an easy installation step, but no control on kernel configuration parameters if you mind to use SquashFS for particular purposes (eg. for embedded systems).
With a kernel source and a proper SquashFS patch present, all you have to do is (we'll assume that you have your Linux kernel source in /usr/src/linux and that you have the SquashFS source in /usr/src/squashfs):
Change to the SquashFS source directory and copy the kernel patch (we'll assume it's named squashfs-patch) to /usr/src/linux.
bash# cd /usr/src/squashfs bash# cp linux-2.x.y/squashfs-patch /usr/src/linux |
Go to the linux kernel source directory /usr/src/linux:
bash# cd /usr/src/linux |
Note: please remember that we will not be leaving this directory during all further kernel-related procedures, and all paths will be given relative to /usr/src/linux.
Now patch the source with the SquashFS patch:
bash# patch -p1 < squashfs-patch |
Cleanup and prepare the kernel source:
bash# make distclean bash# make mrproper |
Configure the kernel using your favourite method (config/menuconfig/xconfig/gconfig):
bash# make menuconfig |
In the "File systems" section, "Miscellaneous file systems" subsection, enable the "Squashed filesystem" option, whether as module or bundled with the kernel. It is only obligatory to compile SquashFS inside the kernel if you plan using squashed initial RAM disks (initrd).
In the same subsection, "do NOT" enable the "Additional option for memory-constrained system", unless you are configuring your kernel for an embedded system.
If you would like to use a squashed initial RAM disk, enable the "Initial RAM disk support" in the "Device drivers" section, "Block devices" subsection.
If you want to be able to mount the squashed file system via a loopback device in future, you should enable "Loopback device support" in the "Device drivers" section, "Block devices" subsection.
Now you may compile the kernel and modules:
bash# make |
Configure the kernel:
bash# make menuconfig |
In the "File systems" section, enable the "Squashed filesystem" option, whether as module or bundled with the kernel. It is only obligatory to compile SquashFS inside the kernel if you plan using squashed initial RAM disks (initrd).
If you would like to use a squashed initial RAM disk, enable the "Initial RAM disk support" in the "Block devices" section.
If you want to be able to mount the squashed file system via a loopback device in future, you should enable " Loopback device support " in the "Block devices " section.
Now you may compile the kernel and modules:
bash# make dep bash# make bzImage bash# make modules |
It's time to install your new SquashFS-enabled kernel. The instructions below are for installing and booting the kernel on the host machine. You may want to install and test it on the target system.
We assume that the kernel was compiled for a x86 architecture, and the compressed kernel image is located in the arch/i386/boot/ subdirectory of the kernel tree. Now copy the kernel to the /boot directory (and name it bzImage-sqsh for convenience, if you like):
bash# cp arch/i386/boot/bzImage /boot/bzImage-sqsh |
Don't forget to install the kernel modules if you have any:
bash# make modules_install |
Modify your boot loader's configuration file to include your new kernel and install (update) the boot loader. Now you may reboot with your new kernel. When it boots, check that everything went fine:
bash# cat /proc/filesystems |
Or, if you built SquashFS support as a kernel module:
bash# insmod squashfs bash# cat /proc/filesystems |
If you see the squashfs line among other file systems, this means you have successfully enabled SquashFS in your kernel.
Now you need to compile mksquashfs - the tool for creating squashed file systems and the unsquashfs which extracts files from an existing squashed file system.
bash# cd /usr/src/squashfs/squashfs-tools |
Compile and install the tools:
bash# make bash# cp mksquashfs /usr/sbin bash# cp unsquashfs /usr/sbin |
If everything went fine, typing mksquashfs or unsquashfs at the shell prompt should print the "usage" message.
If you use Debian (or onother Linux distribution) you may want to get SquashFS module and tools from the distro repositories. With Debian you have to install the proper kernel module and the tools with the following commands:
(Assuming your architecture is x86)
bash# apt-get install squashfs-modules-2.6-486 squashfs-tools |
Now load the squashfs module for the Linux kernel and if it was correctly loaded you should find it in the relative list
bash# modprobe squashfs bash# lsmod|grep squash squashfs 39620 0 |
Then you have to add the squashfs module to /etc/modules if you need it loaded at boot time.
bash# echo squashfs >> /etc/modules |
Note that at the time of writing, the Debian packages (Etch. 4.0 r2) relates to squashfs 3.1 release. Some latest options and features of 3.2 release may be not supported. Look at the next section for details.