mirror of https://github.com/tLDP/LDP
updated
This commit is contained in:
parent
01eb7421f7
commit
72facf846d
|
@ -302,7 +302,7 @@ How to reject junk mail in incoming SMTP transactions. </Para>
|
|||
SquashFS-HOWTO</ULink>,
|
||||
<CiteTitle>SquashFS HOWTO</CiteTitle>
|
||||
</Para><Para>
|
||||
<CiteTitle>Updated: Mar 2005</CiteTitle>.
|
||||
<CiteTitle>Updated: Jan 2008</CiteTitle>.
|
||||
Describes the usage of SquashFS - a highly-compressed
|
||||
file system for Linux, which is intended for use in tiny/embedded
|
||||
Linux systems, as well as for read-only archiving and general
|
||||
|
|
|
@ -4261,7 +4261,7 @@ describes some of the available software. </Para>
|
|||
SquashFS-HOWTO</ULink>,
|
||||
<CiteTitle>SquashFS HOWTO</CiteTitle>
|
||||
</Para><Para>
|
||||
<CiteTitle>Updated: Mar 2005</CiteTitle>.
|
||||
<CiteTitle>Updated: Jan 2008</CiteTitle>.
|
||||
Describes the usage of SquashFS - a highly-compressed
|
||||
file system for Linux, which is intended for use in tiny/embedded
|
||||
Linux systems, as well as for read-only archiving and general
|
||||
|
|
|
@ -896,7 +896,7 @@ been deleted. </Para>
|
|||
SquashFS-HOWTO</ULink>,
|
||||
<CiteTitle>SquashFS HOWTO</CiteTitle>
|
||||
</Para><Para>
|
||||
<CiteTitle>Updated: Mar 2005</CiteTitle>.
|
||||
<CiteTitle>Updated: Jan 2008</CiteTitle>.
|
||||
Describes the usage of SquashFS - a highly-compressed
|
||||
file system for Linux, which is intended for use in tiny/embedded
|
||||
Linux systems, as well as for read-only archiving and general
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
<articleinfo>
|
||||
|
||||
<title>SquashFS HOWTO</title>
|
||||
|
||||
<authorgroup>
|
||||
<author>
|
||||
<firstname>Artemiy</firstname>
|
||||
<othername>I.</othername>
|
||||
|
@ -25,10 +25,18 @@
|
|||
<orgname><ulink url="http://artemiolabs.com/">ArtemioLabs</ulink></orgname>
|
||||
<address><email>ap (at) artemio (dot) net</email></address>
|
||||
</affiliation>
|
||||
|
||||
</author>
|
||||
|
||||
<pubdate>2005-03-25</pubdate>
|
||||
|
||||
<author>
|
||||
<firstname>Marco</firstname>
|
||||
<othername></othername>
|
||||
<surname>Cecchetti</surname>
|
||||
<affiliation>
|
||||
<address><email>mrc (dot) ildp (dot) com</email></address>
|
||||
</affiliation>
|
||||
</author>
|
||||
</authorgroup>
|
||||
<keywordset>
|
||||
<keyword>linux</keyword>
|
||||
<keyword>squashfs</keyword>
|
||||
|
@ -49,7 +57,8 @@
|
|||
read-only file system for Linux, which is intended for use in tiny-sized and
|
||||
embedded systems, and anywhere else you'd want to use a compressed file system.
|
||||
With this document, you'll learn how to prepare a SquashFS-ready
|
||||
Linux kernel, create a sqaushed file system and happily use it.</para>
|
||||
Linux kernel, create a squashed file system and happily use it.
|
||||
</para>
|
||||
|
||||
</abstract>
|
||||
|
||||
|
@ -67,53 +76,76 @@
|
|||
|
||||
<revhistory>
|
||||
|
||||
<revision>
|
||||
<revnumber>1.8</revnumber>
|
||||
<date>2008-01-06</date>
|
||||
<authorinitials></authorinitials>
|
||||
<revremark>Changes according to SquashFS release 3.3. Some parts added.
|
||||
</revremark>
|
||||
|
||||
</revision>
|
||||
|
||||
<revision>
|
||||
<revnumber>1.7</revnumber>
|
||||
<date>2005-03-25</date>
|
||||
<authorinitials></authorinitials>
|
||||
<revremark>Changes according to SquashFS release 2.1.
|
||||
</revremark>
|
||||
|
||||
</revision>
|
||||
|
||||
<revision>
|
||||
<revnumber>1.6</revnumber>
|
||||
<date>2004-11-10</date>
|
||||
<authorinitials></authorinitials>
|
||||
<revremark>Changes according to SquashFS release 2.0.
|
||||
Text corrections.
|
||||
</revremark>
|
||||
|
||||
</revision>
|
||||
|
||||
|
||||
<revision>
|
||||
<revnumber>1.5</revnumber>
|
||||
<date>2004-06-07</date>
|
||||
<authorinitials></authorinitials>
|
||||
<revremark>Changes according to SquashFS release 2.0 alpha.
|
||||
Lots of description improvements and clarifications. Split
|
||||
instructions for Linux kernels of 2.6.x (new) and 2.4.x series.
|
||||
</revremark>
|
||||
|
||||
</revision>
|
||||
|
||||
<revision>
|
||||
<revnumber>1.1</revnumber>
|
||||
<date>2004-05-22</date>
|
||||
<authorinitials></authorinitials>
|
||||
<revremark>Changes according to SquashFS release 1.3r3.</revremark>
|
||||
|
||||
</revision>
|
||||
|
||||
<revision>
|
||||
<revnumber>1.0</revnumber>
|
||||
<date>2004-02-19</date>
|
||||
<authorinitials></authorinitials>
|
||||
<revremark>Initial Release, reviewed by LDP.</revremark>
|
||||
|
||||
</revision>
|
||||
|
||||
<revision>
|
||||
<revnumber>0.2</revnumber>
|
||||
<date>2003-12-08</date>
|
||||
<authorinitials></authorinitials>
|
||||
<revremark>Text corrections, license added.</revremark>
|
||||
|
||||
</revision>
|
||||
|
||||
<revision>
|
||||
<revnumber>0.1</revnumber>
|
||||
<date>2003-11-24</date>
|
||||
<authorinitials></authorinitials>
|
||||
<revremark>Initial version. Instructions for SquashFS release 1.3r2.</revremark>
|
||||
|
||||
</revision>
|
||||
|
||||
</revhistory>
|
||||
|
|
|
@ -18,19 +18,20 @@ for archiving purposes. For huge public archives, as well as for personal media
|
|||
SquashFS brings all this to a new level. It is a read-only file system that lets you compress whole file systems or
|
||||
single directories, write them to other devices/partitions or to ordinary files, and then mount them directly (if
|
||||
a device) or using a loopback device (if it is a file). The modular, compact system design of SquashFS is bliss.
|
||||
For archiving purposes, SquashFS gives you a lot more flexibility and performance speed than a .tar.gz archive.
|
||||
For archiving purposes, SquashFS gives you a lot more flexibility and performance speed than a tarball archive.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
SquashFS is distributed as a Linux kernel source patch (which enables SquashFS read support in your kernel),
|
||||
and the <command>mksquashfs</command> tool, which creates squashed file systems (in a file or on a block device).
|
||||
the <command>mksquashfs</command> tool, which creates squashed file systems (in a file or on a block device) and
|
||||
the <command>unsquashfs</command> tool, which extracts multiple files from an existing squashed file system.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The latest SquashFS release tree is 2.x, the former one was 1.x. This document
|
||||
The latest SquashFS release tree is 3.x, the former one was 2.x. This document
|
||||
describes both these releases with proper notes given. For example, if some feature or
|
||||
parameter is different in these release trees, it will be written as follows: <emphasis>new value
|
||||
(2.x) or old value (1.x)</emphasis>
|
||||
parameter is different in these release trees, it will be written as follows:
|
||||
<emphasis>new value (3.x) or old value (2.x)</emphasis>
|
||||
</para>
|
||||
|
||||
</sect2>
|
||||
|
@ -47,7 +48,7 @@ parameter is different in these release trees, it will be written as follows: <e
|
|||
<listitem>SquashFS stores full uid/gids (32 bits), and file creation time
|
||||
</listitem>
|
||||
|
||||
<listitem>Files up to 2^32 bytes are supported; file systems can be up to 2^32 bytes
|
||||
<listitem>Files up to 2^64 bytes are supported; file systems can be up to 2^64 bytes
|
||||
</listitem>
|
||||
|
||||
<listitem>Inode and directory data are highly compacted, and packed on byte
|
||||
|
@ -56,11 +57,11 @@ boundaries; each compressed inode is on average 8 bytes in length
|
|||
symbolic link, and block/character device inodes have different sizes)
|
||||
</listitem>
|
||||
|
||||
<listitem>SquashFS can use block sizes up to 32 Kb (1.x) and 64Kb (2.x), which achieves
|
||||
<listitem>SquashFS can use block sizes up to up to 64 Kb (2.x) and 1Mb (3.x). The default size is 128Kb (3.x), which achieves
|
||||
greater compression ratios than the normal 4K block size
|
||||
</listitem>
|
||||
|
||||
<listitem>SquashFS 2.x inroduced the concept of <emphasis>fragment blocks</emphasis>:
|
||||
<listitem>By the 2.x release it was introduced the concept of <emphasis>fragment blocks</emphasis>:
|
||||
an ability to join multiple files smaller than block size into a single
|
||||
block, achieving greater compression ratios
|
||||
</listitem>
|
||||
|
@ -82,8 +83,8 @@ mount file systems created on different byte-order machines
|
|||
|
||||
<para>
|
||||
Now let's make sure any further discussions will be clearer
|
||||
fro you to understand.
|
||||
The procedure of getting SquashFS working, basically,
|
||||
for you to understand.
|
||||
The procedure of getting SquashFS working basically
|
||||
consists of the following steps:
|
||||
</para>
|
||||
|
||||
|
@ -92,7 +93,7 @@ consists of the following steps:
|
|||
<listitem>Patching and recompiling the target Linux kernel to enable SquashFS support
|
||||
</listitem>
|
||||
|
||||
<listitem>Compiling the <command>mksquashfs</command> tool
|
||||
<listitem>Compiling the <command>mksquashfs </command> and the <command>unsquashfs </command> tools
|
||||
</listitem>
|
||||
|
||||
<listitem>Creating a compressed file system with <command>mksquashfs</command>
|
||||
|
@ -101,7 +102,7 @@ consists of the following steps:
|
|||
<listitem>Testing: mounting a squashed file system to a temporary location
|
||||
</listitem>
|
||||
|
||||
<listitem>Modifying the <filename>/etc/fstab</filename> or startup scripts of
|
||||
<listitem>Modifying the <filename>/etc/fstab </filename> or startup scripts of
|
||||
your target Linux system to mount the new squashed file system when needed
|
||||
</listitem>
|
||||
|
||||
|
@ -109,4 +110,4 @@ your target Linux system to mount the new squashed file system when needed
|
|||
|
||||
</sect2>
|
||||
|
||||
</sect1>
|
||||
</sect1>
|
||||
|
|
|
@ -12,11 +12,18 @@
|
|||
The SquashFS home site is located at
|
||||
<ulink url="http://squashfs.sourceforge.net/">http://squashfs.sourceforge.net/</ulink>
|
||||
- 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
|
||||
about SquashFS. You can grab the latest version at the SquashFS
|
||||
<ulink url="http://sourceforge.net/project/showfiles.php?group_id=63835">project page</ulink>
|
||||
at SourceForge.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Squashfs is also avaliable with LZMA compression at
|
||||
<ulink url="http://www.squashfs-lzma.org/">http://www.squashfs-lzma.org/</ulink>
|
||||
</para>
|
||||
|
||||
|
||||
|
||||
</sect2>
|
||||
|
||||
<sect2 id="preparing">
|
||||
|
@ -26,13 +33,18 @@ at SourceForge.
|
|||
<para>
|
||||
In order to read SquashFS, you need it supported in your kernel - just as if it was a
|
||||
<filename>reiserfs</filename> or <filename>ext3</filename> file system. You have to make sure
|
||||
there is an appropriate patch for your kernel version - it should be located in
|
||||
<filename>linux-2.x.y</filename> subdirectory of the SquashFS source tree. Also, remember
|
||||
there is an appropriate patch for your kernel version. It should be located in
|
||||
<filename>kernel-patches/linux-2.x.y</filename> subdirectory of the SquashFS source tree. Also, remember
|
||||
that in most cases you will need a <emphasis>clean</emphasis> (original) Linux kernel
|
||||
source from <ulink url="http://kernel.org/">kernel.org</ulink>. 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
|
||||
<emphasis>original</emphasis> Linux kernels.
|
||||
<emphasis>original</emphasis> 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).
|
||||
</para>
|
||||
|
||||
<sect3 id="patching">
|
||||
|
@ -104,18 +116,23 @@ module or bundled with the kernel. It is only obligatory to compile SquashFS ins
|
|||
the kernel if you plan using squashed initial RAM disks (<command>initrd</command>).
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
In the same subsection, <command>"do NOT"</command> enable the <quote><emphasis>Additional option for memory-constrained system</emphasis></quote>, unless
|
||||
you are configuring your kernel for an embedded system.
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
If you would like to use a squashed initial RAM disk, enable the
|
||||
<quote><emphasis>Initial RAM disk support</emphasis></quote> in the
|
||||
<quote><emphasis>Device drivers</emphasis></quote> section,
|
||||
<quote><emphasis>Block devices</emphasis></quote> subsection.
|
||||
<quote><emphasis>Initial RAM disk support</emphasis></quote> in the
|
||||
<quote><emphasis>Device drivers</emphasis></quote> section,
|
||||
<quote><emphasis>Block devices</emphasis></quote> subsection.
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
If you want to be able to mount the squashed file system via a <emphasis>loopback device</emphasis> in future, you should enable
|
||||
<quote><emphasis>Loopback device support</emphasis></quote> in the
|
||||
<quote><emphasis>Device drivers</emphasis></quote> section,
|
||||
<quote><emphasis>Block devices</emphasis></quote> subsection.
|
||||
<quote><emphasis>Loopback device support</emphasis></quote> in the
|
||||
<quote><emphasis>Device drivers</emphasis></quote> section,
|
||||
<quote><emphasis>Block devices</emphasis></quote> subsection.
|
||||
</listitem>
|
||||
|
||||
</orderedlist>
|
||||
|
@ -141,22 +158,22 @@ If you want to be able to mount the squashed file system via a <emphasis>loopbac
|
|||
<orderedlist>
|
||||
|
||||
<listitem>
|
||||
In the <quote><emphasis>File systems</emphasis></quote> section, enable
|
||||
the <quote><emphasis>Squashed filesystem</emphasis></quote> option, whether as
|
||||
In the <quote><emphasis>File systems</emphasis></quote> section, enable
|
||||
the <quote><emphasis>Squashed filesystem</emphasis></quote> 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 (<command>initrd</command>).
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
If you would like to use a squashed initial RAM disk, enable the
|
||||
<quote><emphasis>Initial RAM disk support</emphasis></quote> in the <quote><emphasis>Block
|
||||
devices</emphasis></quote> section.
|
||||
<quote><emphasis>Initial RAM disk support</emphasis></quote> in the <quote><emphasis>Block
|
||||
devices</emphasis></quote> section.
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
If you want to be able to mount the squashed file system via a <emphasis>loopback
|
||||
device</emphasis> in future, you should enable <quote><emphasis>Loopback device
|
||||
support</emphasis></quote> in the <quote><emphasis>Block devices</emphasis></quote> section.
|
||||
device</emphasis> in future, you should enable <quote><emphasis> Loopback device
|
||||
support </emphasis></quote> in the <quote><emphasis>Block devices </emphasis></quote> section.
|
||||
</listitem>
|
||||
|
||||
</orderedlist>
|
||||
|
@ -228,12 +245,13 @@ this means you have successfully enabled SquashFS in your kernel.
|
|||
|
||||
</sect2>
|
||||
|
||||
<sect2 id="mksquashfs">
|
||||
<sect2 id="tools">
|
||||
|
||||
<title>Compiling the <command>mksquashfs</command> tool</title>
|
||||
<title>Compiling the SquashFS tools</title>
|
||||
|
||||
<para>
|
||||
Now you need to compile <command>mksquashfs</command> - the tool for creating squashed file systems.
|
||||
Now you need to compile <command>mksquashfs</command> - the tool for creating squashed file systems and the
|
||||
<command>unsquashfs</command> which extracts files from an existing squashed file system.
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
|
@ -241,18 +259,61 @@ Now you need to compile <command>mksquashfs</command> - the tool for creating sq
|
|||
</programlisting>
|
||||
|
||||
<para>
|
||||
Compile and install <command>mksquashfs</command>:
|
||||
Compile and install the tools:
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
bash# make
|
||||
bash# cp mksquashfs /usr/sbin
|
||||
bash# cp unsquashfs /usr/sbin
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
If everything went fine, typing <command>mksquashfs</command> at the shell prompt should print it's <quote>usage</quote> message.
|
||||
If everything went fine, typing <command>mksquashfs</command> or <command>unsquashfs</command> at the shell prompt should print the <quote>usage</quote> message.
|
||||
</para>
|
||||
|
||||
</sect2>
|
||||
|
||||
</sect1>
|
||||
<sect2 id="debian">
|
||||
|
||||
<title>Installing SquashFS on Debian</title>
|
||||
|
||||
<para>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:
|
||||
</para>
|
||||
|
||||
<para>
|
||||
(Assuming your architecture is x86)
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
bash# apt-get install squashfs-modules-2.6-486
|
||||
|
||||
bash# apt-get install squashfs-tools
|
||||
</programlisting>
|
||||
|
||||
<para> Now load the squashfs module for the Linux kernel and if it was correctly loaded you should find it in the relative list
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
bash# modprobe squashfs
|
||||
|
||||
bash# lsmod|grep squash
|
||||
squashfs 39620 0
|
||||
|
||||
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
Then you have to add the squashfs module to /etc/modules if you need it loaded at boot time.
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
bash# echo squashfs >> /etc/modules
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
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.
|
||||
</para>
|
||||
</sect2>
|
||||
|
||||
</sect1>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
<sect1 id="mksqoverview">
|
||||
|
||||
<title>The mksquashfs tool, exposed</title>
|
||||
<title>The SquashFS tools exposed</title>
|
||||
|
||||
<sect2 id="mksqusing">
|
||||
|
||||
|
@ -21,7 +21,7 @@ systems. The general command-line format for <command>mksquashfs</command> is:
|
|||
<itemizedlist>
|
||||
|
||||
<listitem><filename>source1</filename>, <filename>source2</filename>, etc.: files and directories to be
|
||||
added to the resulting filke system, given with relative and/or absolute paths
|
||||
added to the resulting file system, given with relative and/or absolute paths
|
||||
</listitem>
|
||||
|
||||
<listitem><filename>destination</filename>: a regular file (filesystem
|
||||
|
@ -39,7 +39,7 @@ Notes for default <command>mksquashfs</command> behavior:
|
|||
|
||||
<listitem>
|
||||
When the new files are added to the new file system or appended to an existing one,
|
||||
<command>mksquashfs</command> will automatically rename files with duplicate names:
|
||||
<command>mksquashfs </command> will automatically rename files with duplicate names:
|
||||
if two or more files named <filename>text</filename> will appear in the same
|
||||
resulting directory, the second file will be renamed to
|
||||
<filename>text_1</filename>, third one to <filename>text_2</filename> and so on.
|
||||
|
@ -47,19 +47,15 @@ resulting directory, the second file will be renamed to
|
|||
|
||||
<listitem>
|
||||
Duplicate files will be removed, so there will be only one physical instance
|
||||
(with SquashFS 2.x, you can disable the detection/rtemoval of the duplicates
|
||||
with the <command>-no-duplicates</command> option).
|
||||
(By the SquashFS 2.x, you can disable the detection/removal of the duplicates
|
||||
with the <command>-no-duplicates </command> option).
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
If <emphasis>destination</emphasis> has a pre-existing SquashFS
|
||||
If <emphasis>destination </emphasis> has a pre-existing SquashFS
|
||||
file system on it, by default, the new <emphasis>source</emphasis> items will be appended to
|
||||
the existing root directory. Examine the options table below to force <command>mksquashfs</command> to overwrite the whole destination
|
||||
and/or change the way new source items are added. Please note that it is not possible to
|
||||
append to a file system created with <command>mksquashfs</command> 1.x using
|
||||
<command>mksquashfs</command> 2.x. You will need to mount the SquashFS-1.x file system
|
||||
and copy the files to some location, and then join them with other needed files
|
||||
to create a SquashFS-2.x file system.
|
||||
the existing root directory. Examine the options table below to force <command>mksquashfs </command> to overwrite the whole destination
|
||||
and/or change the way new source items are added.
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
|
@ -71,7 +67,7 @@ the new file system.
|
|||
<listitem>
|
||||
The resulting filesystem will be padded to a multiple of 4 Kb: this
|
||||
is required for filesystems to be used on block devices. If you are very sure
|
||||
you don't ned this, use the <command>-nopad</command> option to disable this
|
||||
you don't ned this, use the <command>-nopad </command> option to disable this
|
||||
operation.
|
||||
</listitem>
|
||||
|
||||
|
@ -109,7 +105,7 @@ All possible options for <command>mksquashfs</command> are shown in the table be
|
|||
<tbody>
|
||||
|
||||
<row>
|
||||
<entry><command>-2.0</command></entry>
|
||||
<entry><command>-2.0 </command></entry>
|
||||
<entry>force <command>mksquashfs</command> version 2.1 to create a version 2.0
|
||||
filesystem</entry>
|
||||
</row>
|
||||
|
@ -122,13 +118,13 @@ filesystem</entry>
|
|||
|
||||
<row>
|
||||
<entry><command>-always-use-fragments</command></entry>
|
||||
<entry>divide all files greater than block size into fragments (2.x only,
|
||||
will result in greater compression ratios)</entry>
|
||||
<entry>divide all files greater than block size into fragments (by the version 2.x).
|
||||
It will result in greater compression ratios</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry><command>-b [block size]</command></entry>
|
||||
<entry>use [block size] filesystem block size (32 Kbytes default) - this can be either 512, 1024, 2048, 4096, 8192, 16384 or 32768</entry>
|
||||
<entry>use [block size] filesystem block size (32 Kbytes default for 2.x, 128 kbytes for 3.x) - this can be either 4096, 8192, 16384, 32768, 65536 or 131072</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
|
@ -196,12 +192,12 @@ overwrite it, rather than append the new data to an existing file system</entry>
|
|||
|
||||
<row>
|
||||
<entry><command>-noF</command> or <command>-noFragmentCompression</command></entry>
|
||||
<entry>do not compress the fragments (2.x only)</entry>
|
||||
<entry>do not compress the fragments (avaliable by 2.x)</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry><command>-no-fragments</command></entry>
|
||||
<entry>do not generate fragment blocks (2.x only, this will
|
||||
<entry>do not generate fragment blocks (avaliable by 2.x, this will
|
||||
produce almost the same filesystem as 1.x did)</entry>
|
||||
</row>
|
||||
|
||||
|
@ -224,9 +220,65 @@ and [name] directory will contain all pre-existing files/directories
|
|||
|
||||
<row>
|
||||
<entry><command>-version</command></entry>
|
||||
<entry>print the version, copyright and license message</entry>
|
||||
<entry>print the version, copyright and license message
|
||||
</entry>
|
||||
</row>
|
||||
|
||||
|
||||
<row>
|
||||
<entry><command>-recover [name]</command></entry>
|
||||
<entry>recover filesystem data using recovery file [name] (3.3)
|
||||
</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry><command>-no-recovery</command></entry>
|
||||
<entry>don't create a recovery file (3.3).
|
||||
</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry><command>-no-exports</command></entry>
|
||||
<entry>don't make avaliable file system to export via NFS (3.x)
|
||||
</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry><command>-no-sparse</command></entry>
|
||||
<entry>don't check for sparse files (3.x)</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry><command>-processors [number]</command></entry>
|
||||
<entry>set the number of CPU to create file system. By default it will be used all avaliable processors (3.x)</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry><command>--read-queue [size]</command></entry>
|
||||
<entry>set input queue to [size] Mb. (Default is 64 Mb)(3.x)</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry><command>-write-queue [size]</command></entry>
|
||||
<entry>-write-queue [size] (3.x)</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry><command>-sort [sort_file]</command></entry>
|
||||
<entry>sort files relating to priorities in [sort_file] (3.x)</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry><command>-wildcards</command></entry>
|
||||
<entry>enable the extended shell wildcards to exclude directories/files (to be used with -e)</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry><command>-regex</command></entry>
|
||||
<entry>enable to use POSIX regular expressions (3.3)</entry>
|
||||
</row>
|
||||
|
||||
|
||||
</tbody>
|
||||
|
||||
</tgroup>
|
||||
|
@ -240,4 +292,127 @@ In most cases, you should leave all compression/block options by default, as the
|
|||
|
||||
</sect2>
|
||||
|
||||
</sect1>
|
||||
<sect2 id="unsquashing">
|
||||
<title>Using unsquashfs</title>
|
||||
|
||||
<para>
|
||||
<command>unsquashfs</command> is the tool for extracting data from squashed
|
||||
file systems. The general command-line format for <command>unsquashfs</command> is:
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
unsquashfs [options] target [files/directories to extract]
|
||||
</programlisting>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
target is the squashed file system to extract.
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
<para>
|
||||
Notes for <command>unsquashfs</command> behavior:
|
||||
</para>
|
||||
|
||||
<itemizedlist>
|
||||
|
||||
<listitem>
|
||||
By not specifying any <emphasis>destination path</emphasis>, unsquashfs extracts the compressed file system in the
|
||||
<emphasis>./squashfs-root </emphasis> directory.
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
The tool does not extract a squashed file system on already exsisting directory
|
||||
unless the <command>-f</command> option is specified.
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
You can specify on the command line, a multiple number of files/directories to extract and the items
|
||||
to be extracted can be also be given in a file with <command>-e [file]</command> option.
|
||||
</listitem>
|
||||
|
||||
|
||||
</itemizedlist>
|
||||
|
||||
|
||||
<para>
|
||||
All possible options for <command>unsquashfs</command> are shown in the table below.
|
||||
</para>
|
||||
|
||||
<table frame="all">
|
||||
|
||||
<title>Command-line options of the <command>unsquashfs</command> tool</title>
|
||||
|
||||
<tgroup cols="2">
|
||||
|
||||
<thead>
|
||||
<row>
|
||||
<entry>Option</entry>
|
||||
<entry>Description</entry>
|
||||
</row>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
|
||||
<row>
|
||||
<entry><command>-v[ersion] </command></entry>
|
||||
<entry>print the version, licence and copyright message
|
||||
</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry><command>-i[nfo]</command></entry>
|
||||
<entry>print the files as they are extracted from the file system</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry><command>-l[ist]</command></entry>
|
||||
<entry>list the squashed file system without extracting files</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry><command>-li</command></entry>
|
||||
<entry>list files with theyr attributes as they are unsquashed (3.3)</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry><command>-ll</command></entry>
|
||||
<entry>list the squashed file system files with attributes without any extraction (3.3)</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry><command>-d[estination] path</command></entry>
|
||||
<entry>specify a destination path for unsquashed items</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry><command>-f[orce]</command></entry>
|
||||
<entry>if files exist overwrite them</entry>
|
||||
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry><command>-s[tat]</command></entry>
|
||||
<entry>display file system's superblock informations (it can discover the file system version and the options used to compress it - 3.3)</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry><command>-e[f] [extract file] (3.3)</command></entry>
|
||||
<entry>list of directories or files to extract (entries given one per line)</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry><command>-r[egex] (3.3)</command></entry>
|
||||
<entry>treat extract names as POSIX regular expressions</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
|
||||
</tgroup>
|
||||
|
||||
</table>
|
||||
|
||||
<para>
|
||||
Note that by 3.x release you can extract 1.x and 2.x squashed file system too.
|
||||
</para>
|
||||
</sect2>
|
||||
</sect1>
|
||||
|
|
|
@ -1,324 +1,431 @@
|
|||
<?xml version='1.0' encoding='ISO-8859-1'?>
|
||||
<?xml version='1.0' encoding='ISO-8859-1'?>
|
||||
|
||||
<sect1 id="creatingandusing">
|
||||
|
||||
<title>Creating and using squashed file systems</title>
|
||||
|
||||
<sect2 id="creating">
|
||||
<title>Basic steps</title>
|
||||
|
||||
<para>
|
||||
In order to create a squashed file system out of a single directory
|
||||
(say, <filename>/some/dir</filename>), and output it to a regular file
|
||||
(thus, producing a file system image), you need to say only one magic phrase:
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
bash# mksquashfs /some/dir dir.sqsh
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
<command>mksquashfs</command> will perform the squashing and print the resulting
|
||||
number of inodes and size of data written, as well as the average compression ratio.
|
||||
Now you have your <filename>/some/dir</filename> directory image in the
|
||||
<filename>dir.sqsh</filename> file. You can now use the <command>mount</command> command
|
||||
to mount it using a loopback device:
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
bash# mkdir /mnt/dir
|
||||
bash# mount dir.sqsh /mnt/dir -t squashfs -o loop
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
To check if you have what's expected:
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
bash# ls /mnt/dir
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
If you want to output the file system directly into a device (say, your floppy at
|
||||
<filename>/dev/fd0</filename>):
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
bash# mksquashfs /some/dir /dev/fd0
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
Then just <command>mount</command> the device:
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
bash# mount /dev/fd0 /mnt/floppy -t squashfs
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
And check if it's okay:
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
bash# ls /mnt/floppy
|
||||
</programlisting>
|
||||
|
||||
</sect2>
|
||||
|
||||
|
||||
<sect2 id="squashing">
|
||||
|
||||
<title>Squashing file systems</title>
|
||||
|
||||
<para>
|
||||
Operations described here correspond to most cases where a read-only compressed file
|
||||
system can be used, whether you want it to be on a block device or in a file. This
|
||||
could be anything from large FTP/HTTP-served archives that don't change often, to
|
||||
having a squashed <filename>/usr</filename> partition and anything alike
|
||||
with these.
|
||||
</para>
|
||||
|
||||
<sect3 id="squashing-ex1">
|
||||
<title>Example 1</title>
|
||||
|
||||
<para>
|
||||
Let's suppose you have a <filename>/var/arch</filename> directory with lots of files and
|
||||
that you want to turn it into a squashed file system and keep it on your root partition
|
||||
as a file (it will be a file system image that you will mount via a loopback device).
|
||||
The operations needed to perform are as follows.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Squash the directory, then mount it via loopback to test it:
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
bash# mksquashfs /var/arch /var/arch.sqsh
|
||||
bash# mkdir /mnt/tmp
|
||||
bash# mount /var/arch.sqsh /mnt/tmp -t squashfs -o loop
|
||||
bash# ls /mnt/tmp
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
If everything is as expected, make this file system mount automatically at boot time by
|
||||
adding this line to your <filename>/etc/fstab</filename>:
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
/var/arch.sqsh /var/arch squashfs ro,defaults 0 0
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
Unmount the file system from the temporary mount point, and mount using it's fstab entry:
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
bash# umount /mnt/tmp
|
||||
bash# mount /var/arch
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
Now just ensure that everything works fine:
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
bash# ls /var/arch
|
||||
</programlisting>
|
||||
|
||||
</sect3>
|
||||
|
||||
<sect3 id="squashing-ex2">
|
||||
|
||||
<title>Example 2</title>
|
||||
|
||||
<para>
|
||||
Say you have two hard disk partitions, <filename>/dev/hda6</filename> (which
|
||||
is empty) and <filename>/dev/hda7</filename> (which is bigger than <filename>/dev/hda6</filename>,
|
||||
mounted at <filename>/var/arch</filename>, contains some data and is full). Now, say you want to squash the <filename>/dev/hda7</filename> file system and move it to <filename>/dev/hda6</filename>,
|
||||
then use <filename>/dev/hda7</filename> for some other purposes. We will suppose you have
|
||||
the following line in <filename>/etc/fstab</filename> (<command>reiserfs</command> is just an example file system
|
||||
used on <filename>/dev/hda7</filename>):
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
/dev/hda7 /var/arch reiserfs defaults 0 0
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
In the same fashion as with the previous example:
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
bash# mksquashfs /var/arch /var/arch.sqsh
|
||||
bash# mkdir /mnt/tmp
|
||||
bash# mount /var/arch.sqsh /mnt/tmp -t squashfs -o loop
|
||||
bash# ls /mnt/tmp
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
If everything went fine, unmount <filename>/dev/hda7</filename> (if needed) and
|
||||
use <command>dd</command> to copy <filename>/var/arch.sqsh</filename>
|
||||
to <filename>/dev/hda6</filename>:
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
bash# umount /dev/hda7
|
||||
bash# dd if=/var/arch.sqsh of=/dev/hda6
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
Now change the line in <filename>/etc/fstab</filename> for <filename>/dev/hda7</filename> to:
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
/dev/hda6 /var/arch squashfs ro,defaults 0 0
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
Mount the new file system and check to see if all went fine:
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
bash# mount /var/arch
|
||||
bash# ls /var/arch
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
Don't forget to erase the unneeded file system image:
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
bash# rm /var/arch.sqsh
|
||||
</programlisting>
|
||||
|
||||
</sect3>
|
||||
|
||||
</sect2>
|
||||
|
||||
<sect2 id="tinyemb">
|
||||
|
||||
<title>Creating tiny/embedded systems</title>
|
||||
|
||||
<para>
|
||||
By saying "tiny/embedded", I mean Linux systems that are being built for
|
||||
booting from floppy disks, IDE/USB flash disks, iso9660 CD-ROMs, small-sized hard drives and the like.
|
||||
Whether you want to have your whole root file system on a single media (a single partition, a single floppy),
|
||||
or have a modular system (several floppies or disk partitions), the procedure is almost identical.
|
||||
Creating such Linux systems themselves is out of scope of this HOWTO - there are dedicated HOWTOs and guides
|
||||
for this (like the <emphasis>Bootdisk HOWTO</emphasis> and <emphasis>Linux From Scratch</emphasis> - visit
|
||||
<ulink url="http://www.tldp.org">www.tldp.org</ulink> to retrieve these documents).
|
||||
</para>
|
||||
|
||||
<sect3 id="sqflash">
|
||||
<title>Squashed file systems on floppy/flash/hard disks</title>
|
||||
|
||||
<para>
|
||||
In order to use SquashFS for creating Linux systems on small disks, you just have to follow
|
||||
the usual steps for creating a minimal system, performing the following operations
|
||||
at respective points:
|
||||
</para>
|
||||
|
||||
<orderedlist>
|
||||
|
||||
<listitem><para>
|
||||
When developing a kernel for your system, make sure you enable SquashFS support
|
||||
so it can mount squashed file systems
|
||||
</para></listitem>
|
||||
|
||||
<listitem><para>
|
||||
Use <command>mksquashfs</command> for creating read-only initial ram disks and/or root and/or other file systems
|
||||
</para></listitem>
|
||||
|
||||
<listitem><para>
|
||||
Don't forget to set file system types to <filename>squashfs</filename> in <filename>/etc/fstab</filename>
|
||||
and/or the startup scripts of your system for mounting squashed file systems
|
||||
</para></listitem>
|
||||
|
||||
</orderedlist>
|
||||
|
||||
<para>
|
||||
<emphasis>Floppy example</emphasis>. Let's say you have your floppy system tree at
|
||||
<filename>/home/user/floppylinux</filename> and you want to place the root file system on one
|
||||
floppy and <filename>/usr</filename> on another. What you should do is:
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
bash# cd /home/user
|
||||
bash# mksquashfs floppylinux root.sqsh -e usr
|
||||
bash# mksquashfs floppylinux/usr usr.sqsh
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
<emphasis>Note 1</emphasis>: you can see here how we use the <command>-e</command>
|
||||
option to exclude the <filename>/usr</filename> directory for root file system's image.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
<emphasis>Note 2</emphasis>: don't forget to specify <filename>squashfs</filename> in your root disk's
|
||||
<filename>/etc/fstab</filename> or startup scripts when mounting the <filename>/usr</filename> file system.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Insert a root disk in your 3.5" floppy drive (I assume you have a lilo or grub on it, and, thus, a file system exists on this floppy,
|
||||
and the root file system will reside under the <filename>/boot</filename> directory of this file system):
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
bash# mount /mnt/floppy
|
||||
bash# cp root.sqsh /mnt/floppy/boot
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
When done, unmount the root floppy, change the floppy to a <filename>/usr</filename> disk and use <command>dd</command> to
|
||||
transfer the <filename>usr</filename> file system:
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
bash# dd if=usr.sqsh of=/dev/fd0
|
||||
</programlisting>
|
||||
|
||||
</sect3>
|
||||
|
||||
|
||||
<sect3 id="sqfloppy">
|
||||
<title>Squashed file systems on CD-ROMs</title>
|
||||
|
||||
<para>
|
||||
With SquashFS, you can compress large file systems that
|
||||
will be used in live CDs (just as an example). For this purpose SquashFS is also used with UnionFS.
|
||||
|
||||
</para>
|
||||
|
||||
<orderedlist>
|
||||
|
||||
<listitem>
|
||||
Enable SquashFS in the linux kernel of the target system
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
Create a squashed root file system
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
Modify the <filename>/etc/fstab</filename> or startup scripts of the target system
|
||||
to mount the squashd file system when you need it
|
||||
</listitem>
|
||||
|
||||
</orderedlist>
|
||||
|
||||
<para>
|
||||
|
||||
If you create a root file system out of a running Linux system,
|
||||
use the <command>-e</command> option for <command>mksquashfs</command> to exclude
|
||||
all pseudo-filesystems such as <filename>/proc</filename>, <filename>/sys</filename>
|
||||
(on linux kernels after 2.5.x) and <filename>/dev</filename>
|
||||
(when using DevFS). Also, don't forget to add the file system image itself that is
|
||||
being created with <command>mksquashfs</command> (I think you know the reasons
|
||||
for these exclusions).
|
||||
|
||||
</para>
|
||||
|
||||
</sect3>
|
||||
<sect2 id="sqwrite">
|
||||
<title>Making it writeble</title>
|
||||
<para>
|
||||
As mentioned, another interesting use for <command>SquashFS</command> is with <command>Unionfs</command> filesystem, which
|
||||
provides <emphasis>copy-on-write</emphasis> semantics for the read-only file systems, enahancing the possibilities. (For unionfs you can
|
||||
look at <ulink url="http://www.filesystems.org/project-unionfs.html">http://www.filesystems.org/project-unionfs.html</ulink> the Project site)
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Just to make an example, you may want to make your /home/user squashed, to compress and backup your files without losing the possibility to apply changes or writing new files.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Create the <filename>ro.fs</filename> squashed file system and the <filename>rw.fs</filename> dir.
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
bash# mksquashfs /home/user1 ro.fs
|
||||
bash# mkdir /home/rw.fs
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
Mount the squashed ro.fs file system using the loopback device
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
bash# mount -t squashfs ro.fs /mnt -o loop
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
mount the unionfs file system, that makes <filename>/mnt</filename> and <filename>/home/rw.fs</filename> apparently merged under <filename>/home/user1</filename> location.
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
bash# cd /home
|
||||
bash# mount -t unionfs -o dirs=rw.fs=rw:/mnt=ro unionfs user1
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
As you can see now you can apparently create new files in /home/user1.
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
bash# cd /home/user1
|
||||
bash# touch file1
|
||||
bash# ls
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
umount the unionfs and the squashfs file systems and list the content of /home/user1 and /home/rw.fs dir
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
bash# cd ..
|
||||
bash# umount /home/user1
|
||||
bash# umount /mnt
|
||||
|
||||
bash# ls /home/user1
|
||||
bash# ls /home/rw.fs
|
||||
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
You can see that the new <filename>file1</filename> was created in <filename>/home/rw.fs</filename> that's the phisical location of the real writeble <filename>branch</filename> of the "merged" file system.
|
||||
</para>
|
||||
|
||||
<sect1 id="creatingandusing">
|
||||
|
||||
<title>Creating and using squashed file systems</title>
|
||||
|
||||
<sect2 id="creating">
|
||||
<title>Basic steps</title>
|
||||
|
||||
<para>
|
||||
In order to create a squashed file system out of a single directory
|
||||
(say, <filename>/some/dir</filename>), and output it to a regular file
|
||||
(thus, producing a file system image), you need to say only one magic phrase:
|
||||
<para>
|
||||
When you want to add the new created files to the <emphasis>stable</emphasis> and <emphasis>compressed</emphasis> squashed file system, you have to add them to the exsisting one.
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
bash# mksquashfs /home/rw.fs /home/ro.fs
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
Now, to mount your squashed user home directory at system startup, you
|
||||
can do as follow:
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Make squashfs and unionfs modules loaded at boot time.
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
bash# mksquashfs /some/dir dir.sqsh
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
<command>mksquashfs</command> will perform the squashing and print the resulting
|
||||
number of inodes and size of data written, as well as the average compression ratio.
|
||||
Now you have your <filename>/some/dir</filename> directory image in the
|
||||
<filename>dir.sqsh</filename> file. You can now use the <command>mount</command> command
|
||||
to mount it using a loopback device:
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
bash# mkdir /mnt/dir
|
||||
bash# mount dir.sqsh /mnt/dir -t squashfs -o loop
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
To check if you have what's expected:
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
bash# ls /mnt/dir
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
If you want to output the file system directly into a device (say, your floppy at
|
||||
<filename>/dev/fd0</filename>):
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
bash# mksquashfs /some/dir /dev/fd0
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
Then just <command>mount</command> the device:
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
bash# mount /dev/fd0 /mnt/floppy -t squashfs
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
And check if it's okay:
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
bash# ls /mnt/floppy
|
||||
</programlisting>
|
||||
|
||||
</sect2>
|
||||
|
||||
|
||||
<sect2 id="squashing">
|
||||
|
||||
<title>Squashing file systems</title>
|
||||
|
||||
<para>
|
||||
Operations described here correspond to most cases where a read-only compressed file
|
||||
system can be used, whether you want it to be on a block device or in a file. This
|
||||
could be anything from large FTP/HTTP-served archives that don't change often, to
|
||||
having a squashed <filename>/usr</filename> partition and anything alike
|
||||
with these.
|
||||
</para>
|
||||
|
||||
<sect3 id="squashing-ex1">
|
||||
<title>Example 1</title>
|
||||
|
||||
<para>
|
||||
Let's suppose you have a <filename>/var/arch</filename> directory with lots of files and
|
||||
that you want to turn it into a squashed file system and keep it on your root partition
|
||||
as a file (it will be a file system image that you will mount via a loopback device).
|
||||
The operations needed to perform are as follows.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Squash the directory, then mount it via loopback to test it:
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
bash# mksquashfs /var/arch /var/arch.sqsh
|
||||
bash# mkdir /mnt/tmp
|
||||
bash# mount /var/arch.sqsh /mnt/tmp -t squashfs -o loop
|
||||
bash# ls /mnt/tmp
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
If everything is as expected, make this file system mount automatically at boot time by
|
||||
adding this line to your <filename>/etc/fstab</filename>:
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
/var/arch.sqsh /var/arch squashfs ro,defaults 0 0
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
Unmount the file system from the temporary mount point, and mount using it's fstab entry:
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
bash# umount /mnt/tmp
|
||||
bash# mount /var/arch
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
Now just ensure that everything works fine:
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
bash# ls /var/arch
|
||||
</programlisting>
|
||||
|
||||
</sect3>
|
||||
|
||||
<sect3 id="squashing-ex2">
|
||||
|
||||
<title>Example 2</title>
|
||||
|
||||
<para>
|
||||
Say you have two hard disk partitions, <filename>/dev/hda6</filename> (which
|
||||
is empty) and <filename>/dev/hda7</filename> (which is bigger than <filename>/dev/hda6</filename>,
|
||||
mounted at <filename>/var/arch</filename>, contains some data and is full). Now, say you want to squash the <filename>/dev/hda7</filename> file system and move it to <filename>/dev/hda6</filename>,
|
||||
then use <filename>/dev/hda7</filename> for some other purposes. We will suppose you have
|
||||
the following line in <filename>/etc/fstab</filename> (<command>reiserfs</command> is just an example file system
|
||||
used on <filename>/dev/hda7</filename>):
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
/dev/hda7 /var/arch reiserfs defaults 0 0
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
In the same fashion as with the previous example:
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
bash# mksquashfs /var/arch /var/arch.sqsh
|
||||
bash# mkdir /mnt/tmp
|
||||
bash# mount /var/arch.sqsh /mnt/tmp -t squashfs -o loop
|
||||
bash# ls /mnt/tmp
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
If everything went fine, unmount <filename>/dev/hda7</filename> (if needed) and
|
||||
use <command>dd</command> to copy <filename>/var/arch.sqsh</filename>
|
||||
to <filename>/dev/hda6</filename>:
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
bash# umount /dev/hda7
|
||||
bash# dd if=/var/arch.sqsh of=/dev/hda6
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
Now change the line in <filename>/etc/fstab</filename> for <filename>/dev/hda7</filename> to:
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
/dev/hda6 /var/arch squashfs ro,defaults 0 0
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
Mount the new file system and check to see if all went fine:
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
bash# mount /var/arch
|
||||
bash# ls /var/arch
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
Don't forget to erase the unneeded file system image:
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
bash# rm /var/arch.sqsh
|
||||
</programlisting>
|
||||
|
||||
</sect3>
|
||||
|
||||
</sect2>
|
||||
|
||||
<sect2 id="tinyemb">
|
||||
|
||||
<title>Creating tiny/embedded systems</title>
|
||||
|
||||
<para>
|
||||
By saying "tiny/embedded", I mean Linux systems that are being built for
|
||||
booting from floppy disks, IDE/USB flash disks, iso9660 CD-ROMs, small-sized hard drives and the like.
|
||||
Whether you want to have your whole root file system on a single media (a single partition, a single floppy),
|
||||
or have a modular system (several floppies or disk partitions), the procedure is almost identical.
|
||||
Creating such Linux systems themselves is out of scope of this HOWTO - there are dedicated HOWTOs and guides
|
||||
for this (like the <emphasis>Bootdisk HOWTO</emphasis> and <emphasis>Linux From Scratch</emphasis> - visit
|
||||
<ulink url="http://www.tldp.org">www.tldp.org</ulink> to retrieve these documents).
|
||||
</para>
|
||||
|
||||
<sect3 id="sqflash">
|
||||
<title>Squashed file systems on floppy/flash/hard disks</title>
|
||||
|
||||
<para>
|
||||
In order to use SquashFS for creating Linux systems on small disks, you just have to follow
|
||||
the usual steps for creating a minimal system, performing the following operations
|
||||
at respective points:
|
||||
</para>
|
||||
|
||||
<orderedlist>
|
||||
|
||||
<listitem><para>
|
||||
When developing a kernel for your system, make sure you enable SquashFS support
|
||||
so it can mount squashed file systems
|
||||
</para></listitem>
|
||||
|
||||
<listitem><para>
|
||||
Use <command>mksquashfs</command> for creating read-only initial ram disks and/or root and/or other file systems
|
||||
</para></listitem>
|
||||
|
||||
<listitem><para>
|
||||
Don't forget to set file system types to <filename>squashfs</filename> in <filename>/etc/fstab</filename>
|
||||
and/or the startup scripts of your system for mounting squashed file systems
|
||||
</para></listitem>
|
||||
|
||||
</orderedlist>
|
||||
|
||||
<para>
|
||||
<emphasis>Floppy example</emphasis>. Let's say you have your floppy system tree at
|
||||
<filename>/home/user/floppylinux</filename> and you want to place the root file system on one
|
||||
floppy and <filename>/usr</filename> on another. What you should do is:
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
bash# cd /home/user
|
||||
bash# mksquashfs floppylinux root.sqsh -e usr
|
||||
bash# mksquashfs floppylinux/usr usr.sqsh
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
<emphasis>Note 1</emphasis>: you can see here how we use the <command>-e</command>
|
||||
option to exclude the <filename>/usr</filename> directory for root file system's image.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
<emphasis>Note 2</emphasis>: don't forget to specify <filename>squashfs</filename> in your root disk's
|
||||
<filename>/etc/fstab</filename> or startup scripts when mounting the <filename>/usr</filename> file system.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Insert a root disk in your 3.5" floppy drive (I assume you have a lilo or grub on it, and, thus, a file system exists on this floppy,
|
||||
and the root file system will reside under the <filename>/boot</filename> directory of this file system):
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
bash# mount /mnt/floppy
|
||||
bash# cp root.sqsh /mnt/floppy/boot
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
When done, unmount the root floppy, change the floppy to a <filename>/usr</filename> disk and use <command>dd</command> to
|
||||
transfer the <filename>usr</filename> file system:
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
bash# dd if=usr.sqsh of=/dev/fd0
|
||||
</programlisting>
|
||||
|
||||
</sect3>
|
||||
|
||||
|
||||
<sect3 id="sqfloppy">
|
||||
<title>Squashed file systems on CD-ROMs</title>
|
||||
|
||||
<para>
|
||||
With SquashFS, you can compress large file systems that
|
||||
will be used in live CDs (just as an example).
|
||||
</para>
|
||||
|
||||
<orderedlist>
|
||||
|
||||
<listitem>
|
||||
Enable SquashFS in the linux kernel of the target system
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
Create a squashed root file system
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
Modify the <filename>/etc/fstab</filename> or startup scripts of the target system
|
||||
to mount the squashd file system when you need it
|
||||
</listitem>
|
||||
|
||||
</orderedlist>
|
||||
|
||||
<para>
|
||||
|
||||
If you create a root file system out of a running Linux system,
|
||||
use the <command>-e</command> option for <command>mksquashfs</command> to exclude
|
||||
all pseudo-filesystems such as <filename>/proc</filename>, <filename>/sys</filename>
|
||||
(on linux kernels after 2.5.x) and <filename>/dev</filename>
|
||||
(when using DevFS). Also, don't forget to add the file system image itself that is
|
||||
being created with <command>mksquashfs</command> (I think you know the reasons
|
||||
for these exclusions).
|
||||
|
||||
</para>
|
||||
|
||||
</sect3>
|
||||
|
||||
</sect2>
|
||||
|
||||
</sect1>
|
||||
|
||||
<programlisting>
|
||||
bash# echo squashfs >> /etc/modules
|
||||
bash# echo unionfs >> /etc/modules
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
Change the owner of the writeble branch to match user1.
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
chown user1 /home/rw.fs
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
Add these lines to /etc/fstab file to mount squashfs and unionfs
|
||||
at boot time.
|
||||
</para>
|
||||
|
||||
<programlisting>
...
|
||||
/home/ro.fs /mnt squashfs loop 0 0
|
||||
unionfs /home/user1 unionfs dirs=/home/rw.fs=rw:/mnt=ro 0 0
|
||||
</programlisting>
|
||||
|
||||
</sect2>
|
||||
</sect2>
|
||||
|
||||
</sect1>
|
||||
|
|
|
@ -48,4 +48,4 @@ the HOWTO under the main condition that you keep the author and copyright the ar
|
|||
The full text of the licence is available at <ulink url="http://www.opencontent.org/opl.shtml">http://www.opencontent.org/opl.shtml</ulink>
|
||||
</para>
|
||||
|
||||
</sect1>
|
||||
</sect1>
|
||||
|
|
Loading…
Reference in New Issue