old-www/HOWTO/SquashFS-HOWTO/gettingready.html

836 lines
13 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML
><HEAD
><TITLE
>Getting ready for SquashFS</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="SquashFS HOWTO"
HREF="index.html"><LINK
REL="PREVIOUS"
TITLE="What is SquashFS"
HREF="whatis.html"><LINK
REL="NEXT"
TITLE="The SquashFS tools exposed"
HREF="mksqoverview.html"></HEAD
><BODY
CLASS="sect1"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>SquashFS HOWTO</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="whatis.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="mksqoverview.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="sect1"
><H1
CLASS="sect1"
><A
NAME="gettingready"
></A
>2. Getting ready for SquashFS</H1
><DIV
CLASS="sect2"
><H2
CLASS="sect2"
><A
NAME="acquiring"
></A
>2.1. Acquiring SquashFS</H2
><P
>&#13;The SquashFS home site is located at
<A
HREF="http://squashfs.sourceforge.net/"
TARGET="_top"
>http://squashfs.sourceforge.net/</A
>
- 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
<A
HREF="http://sourceforge.net/project/showfiles.php?group_id=63835"
TARGET="_top"
>project page</A
>
at SourceForge.
</P
><P
>&#13;Squashfs is also avaliable with LZMA compression at
<A
HREF="http://www.squashfs-lzma.org/"
TARGET="_top"
>http://www.squashfs-lzma.org/</A
>
</P
></DIV
><DIV
CLASS="sect2"
><H2
CLASS="sect2"
><A
NAME="preparing"
></A
>2.2. Preparing a SquashFS-capable kernel</H2
><P
>&#13;In order to read SquashFS, you need it supported in your kernel - just as if it was a
<TT
CLASS="filename"
>reiserfs</TT
> or <TT
CLASS="filename"
>ext3</TT
> file system. You have to make sure
there is an appropriate patch for your kernel version. It should be located in
<TT
CLASS="filename"
>kernel-patches/linux-2.x.y</TT
> subdirectory of the SquashFS source tree. Also, remember
that in most cases you will need a <EM
>clean</EM
> (original) Linux kernel
source from <A
HREF="http://kernel.org/"
TARGET="_top"
>kernel.org</A
>. 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
<EM
>original</EM
> 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).
</P
><DIV
CLASS="sect3"
><H3
CLASS="sect3"
><A
NAME="patching"
></A
>2.2.1. Patching the kernel source</H3
><P
>&#13;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 <TT
CLASS="filename"
>/usr/src/linux</TT
> and
that you have the SquashFS source in <TT
CLASS="filename"
>/usr/src/squashfs</TT
>):
</P
><P
>&#13;Change to the SquashFS source directory and
copy the kernel patch (we'll assume it's named <TT
CLASS="filename"
>squashfs-patch</TT
>) to
<TT
CLASS="filename"
>/usr/src/linux</TT
>.
</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>&#13; bash# cd /usr/src/squashfs
bash# cp linux-2.x.y/squashfs-patch /usr/src/linux
</PRE
></FONT
></TD
></TR
></TABLE
><P
>&#13;Go to the linux kernel source directory <TT
CLASS="filename"
>/usr/src/linux</TT
>:
</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>&#13; bash# cd /usr/src/linux
</PRE
></FONT
></TD
></TR
></TABLE
><P
><EM
>Note:</EM
> please remember that we will not be leaving this
directory during all further kernel-related procedures, and all paths
will be given relative to <TT
CLASS="filename"
>/usr/src/linux</TT
>.</P
><P
>Now patch the source with the SquashFS patch:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>&#13; bash# patch -p1 &#60; squashfs-patch
</PRE
></FONT
></TD
></TR
></TABLE
></DIV
><DIV
CLASS="sect3"
><H3
CLASS="sect3"
><A
NAME="compiling1"
></A
>2.2.2. Compiling a 2.6.x kernel</H3
><P
>Cleanup and prepare the kernel source:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>&#13; bash# make distclean
bash# make mrproper
</PRE
></FONT
></TD
></TR
></TABLE
><P
>Configure the kernel using your favourite method
(config/menuconfig/xconfig/gconfig):</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>&#13; bash# make menuconfig
</PRE
></FONT
></TD
></TR
></TABLE
><P
></P
><OL
TYPE="1"
><LI
><P
>&#13;In the <SPAN
CLASS="QUOTE"
>"<EM
>File systems</EM
>"</SPAN
> section,
<SPAN
CLASS="QUOTE"
>"<EM
>Miscellaneous file systems</EM
>"</SPAN
> subsection, enable
the <SPAN
CLASS="QUOTE"
>"<EM
>Squashed filesystem</EM
>"</SPAN
> 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 (<B
CLASS="command"
>initrd</B
>).
</P
></LI
><LI
><P
>&#13;In the same subsection, <B
CLASS="command"
>"do NOT"</B
> enable the <SPAN
CLASS="QUOTE"
>"<EM
>Additional option for memory-constrained system</EM
>"</SPAN
>, unless
you are configuring your kernel for an embedded system.
</P
></LI
><LI
><P
>&#13;If you would like to use a squashed initial RAM disk, enable the
<SPAN
CLASS="QUOTE"
>"<EM
>Initial RAM disk support</EM
>"</SPAN
> in the
<SPAN
CLASS="QUOTE"
>"<EM
>Device drivers</EM
>"</SPAN
> section,
<SPAN
CLASS="QUOTE"
>"<EM
>Block devices</EM
>"</SPAN
> subsection.
</P
></LI
><LI
><P
>&#13;If you want to be able to mount the squashed file system via a <EM
>loopback device</EM
> in future, you should enable
<SPAN
CLASS="QUOTE"
>"<EM
>Loopback device support</EM
>"</SPAN
> in the
<SPAN
CLASS="QUOTE"
>"<EM
>Device drivers</EM
>"</SPAN
> section,
<SPAN
CLASS="QUOTE"
>"<EM
>Block devices</EM
>"</SPAN
> subsection.
</P
></LI
></OL
><P
>Now you may compile the kernel and modules:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>&#13; bash# make
</PRE
></FONT
></TD
></TR
></TABLE
></DIV
><DIV
CLASS="sect3"
><H3
CLASS="sect3"
><A
NAME="compiling2"
></A
>2.2.3. Compiling a 2.4.x kernel</H3
><P
>Configure the kernel:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>&#13; bash# make menuconfig
</PRE
></FONT
></TD
></TR
></TABLE
><P
></P
><OL
TYPE="1"
><LI
><P
>&#13;In the <SPAN
CLASS="QUOTE"
>"<EM
>File systems</EM
>"</SPAN
> section, enable
the <SPAN
CLASS="QUOTE"
>"<EM
>Squashed filesystem</EM
>"</SPAN
> 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 (<B
CLASS="command"
>initrd</B
>).
</P
></LI
><LI
><P
>&#13;If you would like to use a squashed initial RAM disk, enable the
<SPAN
CLASS="QUOTE"
>"<EM
>Initial RAM disk support</EM
>"</SPAN
> in the <SPAN
CLASS="QUOTE"
>"<EM
>Block
devices</EM
>"</SPAN
> section.
</P
></LI
><LI
><P
>&#13;If you want to be able to mount the squashed file system via a <EM
>loopback
device</EM
> in future, you should enable <SPAN
CLASS="QUOTE"
>"<EM
> Loopback device
support </EM
>"</SPAN
> in the <SPAN
CLASS="QUOTE"
>"<EM
>Block devices </EM
>"</SPAN
> section.
</P
></LI
></OL
><P
>Now you may compile the kernel and modules:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>&#13; bash# make dep
bash# make bzImage
bash# make modules
</PRE
></FONT
></TD
></TR
></TABLE
></DIV
><DIV
CLASS="sect3"
><H3
CLASS="sect3"
><A
NAME="installkernel"
></A
>2.2.4. Installing and testing the kernel</H3
><P
>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.
</P
><P
>We assume that the kernel was compiled for a x86
architecture, and the compressed kernel image is located in the
<TT
CLASS="filename"
>arch/i386/boot/</TT
> subdirectory of the kernel tree.
Now copy the kernel to the <TT
CLASS="filename"
>/boot</TT
> directory (and name it
<TT
CLASS="filename"
>bzImage-sqsh</TT
> for convenience, if you like):</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>&#13; bash# cp arch/i386/boot/bzImage /boot/bzImage-sqsh
</PRE
></FONT
></TD
></TR
></TABLE
><P
>&#13;Don't forget to install the kernel modules
if you have any:
</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>&#13; bash# make modules_install
</PRE
></FONT
></TD
></TR
></TABLE
><P
>&#13;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:
</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>&#13; bash# cat /proc/filesystems
</PRE
></FONT
></TD
></TR
></TABLE
><P
>&#13;Or, if you built SquashFS support as a kernel module:
</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>&#13; bash# insmod squashfs
bash# cat /proc/filesystems
</PRE
></FONT
></TD
></TR
></TABLE
><P
>&#13;If you see the <TT
CLASS="computeroutput"
>squashfs</TT
> line among other file systems,
this means you have successfully enabled SquashFS in your kernel.
</P
></DIV
></DIV
><DIV
CLASS="sect2"
><H2
CLASS="sect2"
><A
NAME="tools"
></A
>2.3. Compiling the SquashFS tools</H2
><P
>&#13;Now you need to compile <B
CLASS="command"
>mksquashfs</B
> - the tool for creating squashed file systems and the
<B
CLASS="command"
>unsquashfs</B
> which extracts files from an existing squashed file system.
</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>&#13; bash# cd /usr/src/squashfs/squashfs-tools
</PRE
></FONT
></TD
></TR
></TABLE
><P
>&#13;Compile and install the tools:
</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>&#13; bash# make
bash# cp mksquashfs /usr/sbin
bash# cp unsquashfs /usr/sbin
</PRE
></FONT
></TD
></TR
></TABLE
><P
>&#13;If everything went fine, typing <B
CLASS="command"
>mksquashfs</B
> or <B
CLASS="command"
>unsquashfs</B
> at the shell prompt should print the <SPAN
CLASS="QUOTE"
>"usage"</SPAN
> message.
</P
></DIV
><DIV
CLASS="sect2"
><H2
CLASS="sect2"
><A
NAME="debian"
></A
>2.4. Installing SquashFS on Debian</H2
><P
>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:
</P
><P
>&#13;(Assuming your architecture is x86)
</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>&#13; bash# apt-get install squashfs-modules-2.6-486 squashfs-tools
</PRE
></FONT
></TD
></TR
></TABLE
><P
> Now load the squashfs module for the Linux kernel and if it was correctly loaded you should find it in the relative list
</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>&#13; bash# modprobe squashfs
bash# lsmod|grep squash
squashfs 39620 0
</PRE
></FONT
></TD
></TR
></TABLE
><P
>&#13;Then you have to add the squashfs module to /etc/modules if you need it loaded at boot time.
</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>&#13; bash# echo squashfs &#62;&#62; /etc/modules
</PRE
></FONT
></TD
></TR
></TABLE
><P
>&#13;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.
</P
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="whatis.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="mksqoverview.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>What is SquashFS</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
>&nbsp;</TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>The SquashFS tools exposed</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>