P1. patch kernek to support the squashfs plus lzma
P2. Must Use Same squashfs-tools version else still will got exeception. (example : use squashfs3.4.tar.gz
to do patch kernel ,but using OpenWrt squashfs-tools () ,this will
cause exeception "WARNING: at fs/squashfs/uncomp.c:136 sqlzma_un().....sb_bread failed
reading block 0x1f4b" ) .
------------------ STEP BY STEP ----------------------
for the kernel 2.6.22 as example:
1. put 3 patch file into floder near your Kernel Source path.
3 files is (1) lzma457.tar.bz2
(2) squashfs3.4.tar.gz
(3) sqlzma3.4-457.tar.bz2
you can find these files on http://www.squashfs-lzma.org/ left side .
2. Extract the sqlzma3.4-457.tar.bz2 , find the build.sample , rename it as sqlzma.sh
follow is my modify to fit my make system .
#!/bin/bash
#
# LZMA support for SquashFS 3.4 in kernel 2.6.27.4
#
# How to use this script:
# download all required files, copy them to current directory, run this script
# it will unpack kernel sources and other archives, and will make .ko modules
# as well as mksquashfs and unsquashfs binaries
export BUILD=bin
#export KERNELPATH=../kernel-linux_2.6.22.19-4.05.0
export KERNELPATH=$LINUX_KERNEL_SOURCE
echo "sqlzma shellscript detect LINUX PATH="$LINUX_KERNEL_SOURCE
if [ ! -f squashfs3.4.tar.gz -o ! -f lzma457.tar.bz2 -o ! -f sqlzma3.4-457.tar.bz2 ]; then
echo "missing required file"
exit
fi
rm -rf squashfs3.4 lzma457
tar xjf sqlzma3.4-457.tar.bz2
tar xzf squashfs3.4.tar.gz
# tar xjf linux-2.6.27.4.tar.bz2
mkdir lzma457
tar -C lzma457 -xjf lzma457.tar.bz2
#Jacky.Xue:I have do follow kernel squashfs patch already
#patch -d $KERNELPATH -p1 < squashfs3.4/kernel-patches/linux-2.6.22/squashfs3.4-patch
patch -N -d $KERNELPATH -p1 < sqlzma2k-3.4.patch
patch -N -d squashfs3.4 -p1 < sqlzma2u-3.4.patch
patch -N -d lzma457 -p1 < sqlzma1-457.patch
ln -s ../../$KERNELPATH squashfs3.4/kernel-patches
echo "cp .config $KERNELPATH"
echo "cd $KERNELPATH"
echo "make oldconfig"
echo "make prepare"
echo "make scripts"
echo "cd -"
echo "initialize kernel sources now, by using the commands mentioned above"
echo "and then press ENTER..."
#read
make
mkdir -p $BUILD
cp ./$KERNELPATH/fs/squashfs/squashfs.ko $BUILD
cp ./lzma457/C/Compress/Lzma/kmod/sqlzma.ko $BUILD
cp ./lzma457/C/Compress/Lzma/kmod/unlzma.ko $BUILD
cp ./squashfs3.4/squashfs-tools/unsquashfs $BUILD
cp ./squashfs3.4/squashfs-tools/mksquashfs $BUILD
strip --strip-unneeded $BUILD/mksquashfs $BUILD/unsquashfs
3. after success run the script on step 2.
you will get the tools (to generate the squashfs lzma rootfile system )
mksquashfs
unsquashfs
the mksquashfs example :
mksquashfs ROOTFS_PATH IMAGE_NAME -noappend
also will get 2 ko (kernel modules)
sqlzma.ko and unlzma.ko
IF you don't want use kernel module to support squashfs-lzma ,the try step 4.
4. Modify to support kernel build-in ,
(1) modify YOUR kernelsource/fs/squashfs/Makefile
#
# Makefile for the linux squashfs routines.
#
# the environment variables are not inherited since 2.6.23
ifdef SQLZMA_EXTRA_CFLAGS
EXTRA_CFLAGS += ${SQLZMA_EXTRA_CFLAGS}
endif
obj-$(CONFIG_SQUASHFS) += unlzma.o sqlzma.o squashfs.o
unlzma-y += module.o
sqlzma-y += uncomp.o
squashfs-y += inode.o
squashfs-y += squashfs2_0.o
(2) Makesure your kernelsource/fs/squashfs/ path have follow source files:
inode.c
uncomp.c
module.c
sqlzma.h
sqmagic.h
LzmaDecode.c
LzmaDecode.h
LzmaTypes.h
squashfs2_0.c
squashfs.h
the module.c include the LzmaDecode.c file path should be change
from
#include "../LzmaDecode.c"
to
#include "LzmaDecode.c"
(3) rebuild your kernel (note i suupose that you have know how to add CONFIG_SQUASHFS in
your kernel default config)
CC fs/ramfs/inode.o
CC fs/ramfs/file-mmu.o
LD fs/ramfs/ramfs.o
LD fs/ramfs/built-in.o
CC fs/squashfs/uncomp.o
CC fs/squashfs/inode.o
CC fs/squashfs/squashfs2_0.o
CC fs/squashfs/module.o
LD fs/squashfs/unlzma.o
LD fs/squashfs/sqlzma.o
LD fs/squashfs/squashfs.o
LD fs/squashfs/built-in.o
CC fs/sysfs/inode.o
CC fs/sysfs/file.o
Ok ~ done!