2. Getting ready for SquashFS

2.1. Acquiring SquashFS

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 SqaushFS project page at SourceForge.

2.2. Preparing a SquashFS-capable kernel

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 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.

2.2.1. Patching the kernel source

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

2.2.2. Compiling a 2.6.x kernel

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

  1. 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).
  2. 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.
  3. If you want to be able to mount the squashed file system via a loopback devicein 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

2.2.3. Compiling a 2.4.x kernel

Configure the kernel:


	bash# make menuconfig

  1. 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).
  2. If you would like to use a squashed initial RAM disk, enable the "Initial RAM disk support"in the "Block devices"section.
  3. If you want to be able to mount the squashed file system via a loopback devicein 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

2.2.4. Installing and testing the kernel

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.

2.3. Compiling the mksquashfs tool

Now you need to compile mksquashfs - the tool for creating squashed file systems.


	bash# cd /usr/src/squashfs/squashfs-tools

Compile and install mksquashfs:


	bash# make
	bash# cp mksquashfs /usr/sbin

If everything went fine, typing mksquashfs at the shell prompt should print it's "usage" message.

Hosting by: Hurra Communications Ltd.
Generated: 2007-01-26 17:58:05