1 AUTHOR: Kevin Annies (kevinannies@hotmail.com)
6 LICENSE: GNU Free Documentation License Version 1.2
8 SYNOPSIS: Implement squashfs to create a compressed /usr image for a live cd.
11 This hint is a guide to creating a compressed /usr image as /usr usually tends
12 to be the larget directory on a system. The user is then given a quick example
13 of how to implement this on a Live CD by mounting the image at boot time.
16 http://squashfs.sourceforge.net/
20 The kernel source code
26 To start with a full explanation of Squashfs can be found at the following
27 link: http://squashfs.sourceforge.net/ if you have trouble undertanding this hint
28 If you are short of space on your
29 machine or would like to create a live cd containing lots of software, this hint is ideal for you
34 The source code can also be downloaded from this site
35 http://squashfs.sourceforge.net/
37 The package used in this hint is squashfs3.2-r2. The document
38 located at www.artemio.net/projects/linuxdoc/squashfs/SquashFS-HOWTO.html was
39 refrenced and adapted to the circumstance of the hint.
42 Patching and recompiling the Kernel
44 In order to use squashfs, the kernel needs to have a patch applied.Un pack the source tar ball.
45 tar xvfz squashfs3.2-r2.tar.gz
48 The patch can be found in /linux-2.6.16 of the source code directory. The patch we require
49 is called: linux-2.6.16.27-utf8_input-1.patch
51 Move the patch to the directory the kernel source is located at. apply the patch using the following command:
53 patch -Np1 -i ../linux-2.6.16.27-utf8_input-1.patch
55 The menu driven kernel configuration must then be initiated again and squashfs must be
56 selected within the supported file systems menu.
60 To compile the sourcecode, navigate to the /squashfs-tools directory within the sourcecode
61 and type make. Following compilation, copy the executable file to a more appropriate directory:
62 cp mksquashfs /usr/sbin
64 To check everything went accordingly, type mksquashfs and the help dialogue associated with
65 the command will be displayed.
69 On our system, /usr is by far the biggest directory. The most simple and logical approach
70 would be to compress this directory and then uncompress and mount during the system boot. As /usr
71 is not needed early during this boot process and exists generally as a read only directory this is
74 A compressed file can be created using the following command from the top level root directory:
75 mksquashfs /usr usr.sqsh
77 Depending on how large the /usr directory is, this command can take a while to execute so maybe go grab a cofee....
78 Once done, the resulting usr.sqsh file can be copied to the Live CD partition. The /usr directory on the CD must
83 Finally create a small start-up script in $LIVECD/etc/rc.d/init.d called usr or something similar.
84 Insert the following text:
88 mount /usr.sqsh /usr -o loop
90 Make the file executable. Next create a symbolic link:
92 ln –l $LIVECD/etc/rc.d/init.d/usr $LIVECD/etc/rc.d/rcsysinitt/S35usr
94 This will trigger the kernel to mount the usr.sqsh image to the /usr directory during the
95 system boot process. Upon logging on, the /usr directory will be fully populated and appear to be
96 exactly as it was before we compressed it.
99 Thats all there is to it. Please feel free to contact me if you have an alternative way of doing this.
101 As a final comment, I implemented this on a CD using an initrd using this procedure.
104 * Artemiy I. Pavlov - for writing the SquashFS HOWTO document
105 * Micheal Hernandez - For writing the begginers guide to creating a Live CD hint