website annotate en/doc/handbook/hacking-livecd.html @ rev 39

Add LightTPD to Handbook (en) & typos
author Paul Issott <paul@slitaz.org>
date Wed May 04 21:16:27 2011 +0000 (2011-05-04)
parents b0f82bed4355
children fb63123c9a72
rev   line source
paul@38 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
paul@38 2 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
paul@38 3
paul@38 4 <head>
paul@38 5 <title>SliTaz Handbook (en) - Template</title>
paul@38 6 <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
paul@38 7 <meta name="description" content="slitaz English handbook" />
paul@38 8 <meta name="expires" content="never" />
paul@38 9 <meta name="modified" content="2008-02-26 18:30:00" />
paul@38 10 <meta name="publisher" content="www.slitaz.org" />
paul@38 11 <meta name="author" content="Christophe Lincoln" />
paul@38 12 <link rel="shortcut icon" href="favicon.ico" />
paul@38 13 <link rel="stylesheet" type="text/css" href="book.css" />
paul@38 14 </head>
paul@38 15 <body bgcolor="#ffffff" >
paul@38 16
paul@38 17 <!-- Header and quick navigation -->
paul@38 18 <div id="header">
paul@38 19 <div id="quicknav" align="right">
paul@38 20 <a name="top"></a>
paul@39 21 <a href="web-server.html">Web server</a> |
paul@38 22 <a href="index.html">Table of contents</a>
paul@38 23 </div>
paul@38 24 <h1><font color="#3e1220">SliTaz Handbook (en)</font></h1>
paul@38 25 </div>
paul@38 26
paul@38 27 <!-- Content. -->
paul@38 28 <div id="content">
paul@38 29 <div class="content-right"></div>
paul@38 30
paul@38 31 <h2><font color="#df8f06">Hacking SliTaz LiveCD</font></h2>
paul@38 32
paul@38 33 <ul>
paul@38 34 <li><a href="#intro">Introduction.</a></li>
paul@38 35 <li><a href="#pre">Organisation and preparation.</a></li>
paul@38 36 <li><a href="#add-files">Add files to the ISO.</a></li>
paul@38 37 <li><a href="#isolinux">Modify the isolinux configuration.</a></li>
paul@38 38 <li><a href="#memtest">Install and use Memtest86.</a></li>
paul@38 39 <li><a href="#rootfs">Manipulate the Live root system.</a></li>
paul@38 40 <li><a href="#gen-iso">Generate a bootable ISO image with isolinux.</a></li>
paul@38 41 </ul>
paul@38 42
paul@38 43 <a name="intro"></a>
paul@38 44 <h3>Introduction</h3>
paul@38 45 <p>
paul@38 46 <em>Hacking SliTaz LiveCD</em> or how to have fun with the LiveCD ISO image. Note that you can also
paul@38 47 <a href="gen-livecd.html">create a custom flavor with Tazlito</a>.
paul@39 48 Creating your own bootable ISO image is easily achievable and the steps are carefully described here. The manipulation of a personal ISO image can add new files or modify existing
paul@38 49 ones found on the Slitaz Live CD. The Slitaz ISO image is less than 30 MB and a CD-R or CD-RW provides around 700 MB,
paul@38 50 so there's plenty of scope for expansion. For example, you could store your images and even provide a <em>live</em> slideshow
paul@38 51 using GQview. The <em>hacking</em> of the ISO image allows you to modify boot loader configuration files
paul@38 52 (<em>boot loader</em>), <em>splash</em> images and GRUB itself. You could also add the
paul@38 53 Memtest86 utility (tool used to test system RAM). Using the same techniques it's even possible to
paul@38 54 modify the filesystem - this does however require some extra manipulation and a bit more time.</p>
paul@38 55
paul@38 56 <a name="pre"></a>
paul@38 57 <h3>Organisation and preparation</h3>
paul@38 58 <p>
paul@38 59 To begin, first we must define where we are going to work by creating a directory and several sub directories
paul@38 60 to accomodate all the different files. The <em>hacking</em> of the ISO can be done from within a SliTaz system or any
paul@38 61 other GNU/Linux distribution such as Debian, Fedora, PCLinuxOS etc. If you use SliTaz LiveCD mode
paul@38 62 (where you can remove the CD once SliTaz has launched in RAM and burn your new ISO), It's advisible to use
paul@38 63 USB media to carry on working, otherwise your work will be lost on shutdown. To begin you need to create a
paul@38 64 <em>hacking</em> directory that you can use inside <code>/home/slitaz</code> within the
paul@38 65 root of your user space. The use of a <code>/home/slitaz</code> directory enables you to store an original
paul@38 66 ISO image and gives you the option to create a <code>src/</code> directory to download possible source packages.
paul@38 67 All the various stages of <em>hacking</em> can be done on the command line via a X terminal (Xterm) or in console mode
paul@38 68 on a Linux terminal. It's advisable to run all commands as <em>root</em> to avoid any permission problems.
paul@38 69 To become the (<em>root</em>) adminsistrator, create a <code>/home/slitaz/hacked</code> directory and proceed
paul@38 70 inside:
paul@38 71 </p>
paul@38 72 <pre> $ su
paul@38 73 # mkdir -p /home/slitaz/hacked
paul@38 74 (# mkdir -p /home/slitaz/src)
paul@38 75 # cd /home/slitaz/hacked
paul@38 76 </pre>
paul@38 77 <h4>Getting the contents of the ISO</h4>
paul@38 78 <p>
paul@38 79 Now that you are in the working directory, we must create the root of the amended CD-ROM and retrieve the files contained on the original Slitaz ISO - namely, the Linux Kernel (<code>bzImage</code>), the compressed
paul@38 80 filesystem (<code>rootfs.gz</code>) and the isolinux bootloader files. To recover these files you have two
paul@38 81 options, either take them from a burnt CD or from an ISO image stored locally. To create the root of your CD
paul@38 82 (<code>rootcd</code>) and copy files from the cdrom device <code>/dev/cdrom</code> mounted on
paul@38 83 <code>/media/cdrom</code>:
paul@38 84 </p>
paul@38 85 <pre> # mount -t iso9660 /dev/cdrom /media/cdrom
paul@38 86 # mkdir rootcd
paul@38 87 # cp -a /media/cdrom/* rootcd
paul@38 88 </pre>
paul@38 89 <p>
paul@38 90 To mount an ISO image using <em>loop</em> in the temporary directory <code>/tmp/loop</code>
paul@38 91 (with the ISO image <code>slitaz-cooking.iso</code>), create the root of the CD
paul@38 92 (<code>rootcd</code>), copy all the files and dismount the ISO image:
paul@38 93 </p>
paul@38 94 <pre> # mkdir /tmp/loop
paul@38 95 # mount -o loop slitaz-cooking.iso /tmp/loop
paul@38 96 # mkdir rootcd
paul@38 97 # cp -a /tmp/loop/* rootcd
paul@38 98 # umount /tmp/loop
paul@38 99 </pre>
paul@38 100 <p>
paul@38 101 Voilą, all the necessary files should now be present in the <code>rootcd/</code> directory.
paul@38 102 To be sure, you can list all of the files recursively with the <code>ls</code> command:
paul@38 103 </p>
paul@38 104 <pre> # ls -R rootcd
paul@38 105 </pre>
paul@38 106
paul@38 107 <a name="add-files"></a>
paul@38 108 <h3>Adding the files to the ISO</h3>
paul@38 109 <p>
paul@38 110 The addition of various files and directories to the ISO image simply consists of copying data to
paul@38 111 the root of the cdrom (<code>rootcd/</code>) and generating a new image. The data may be classified
paul@38 112 in one or two directories created in the root of the CD. Once the ISO image is burnt to a CD-R/CD-RW
paul@38 113 you can use SliTaz as before, mounted on <code>/media/cdrom</code> and navigate through your data using
paul@38 114 emelFM2, Clex or the command line. You data will also be legible from all GNU/Linux systems, BSD or even
paul@38 115 ... Windows.
paul@38 116 </p>
paul@38 117 <h4>Create directories and copy data</h4>
paul@38 118 <p>
paul@38 119 To create and copy files, you can start by using the command line and then continue on graphically as a simple
paul@38 120 user. We will create a <code>images/</code> directory as <em>root</em> and change the permissions so that all
paul@38 121 users can have write access:
paul@38 122 </p>
paul@38 123 <pre> # mkdir rootcd/images
paul@38 124 # chmod 777 rootcd/images
paul@38 125 </pre>
paul@38 126 <p>
paul@38 127 Now that a directory exists that anybody can write to, you can start to fill it. Once you've finished
paul@38 128 you can then <a href="#gen-iso">generate a bootable ISO image</a>.
paul@38 129 </p>
paul@38 130
paul@38 131 <a name="isolinux"></a>
paul@38 132 <h3>Modify the isolinux configuration</h3>
paul@38 133 <p>
paul@38 134 The modification of isolinux allows you to create custom entries with <em>pre-boot</em> parameters,
paul@38 135 for example you can add a <code>label</code> launching SliTaz with the <code>lang=en</code>
paul@38 136 and <code>kmap=en</code> options. At the design level you can easily change the <em>splash</em>
paul@38 137 image displayed at startup. The <code>isolinux</code> application manages the starting of the
paul@38 138 <em>boot loader</em> of the LiveCD and is provided by the Syslinux package. The source file of
paul@38 139 Syslinux provides various applications whose role it is to start a GNU/Linux system. The binary
paul@38 140 <code>isolinux.bin</code> controls the actual boot loading. The boot loader is simple, fast and easily
paul@38 141 configured either graphically or using a text editor. The syntax of the configuration file
paul@38 142 <code>isolinux.cfg</code> is easy to understand - to add new entries just copy and paste using the
paul@38 143 original file. To edit the file graphically using Leafpad:
paul@38 144 </p>
paul@38 145 <pre> # leafpad rootcd/boot/isolinux/isolinux.cfg &amp;
paul@38 146 </pre>
paul@38 147 <h4>Configuration file isolinux.cfg</h4>
paul@38 148 <p>
paul@38 149 The <code>isolinux.cfg</code> file found on the standard LiveCD of
paul@38 150 SliTaz, begins with the value <code>display</code>, this will either display
paul@38 151 a text file or a (<code>isolinux.msg</code>) file using 24 ASCII characters and
paul@38 152 a splash image. The <code>default</code> value defines the name of the <code>label</code>
paul@38 153 started by default after the (<code>timeout</code>) waiting time. <em>Timeout</em> is the
paul@38 154 number of seconds to wait before booting the system, you can make it 0 to start booting
paul@38 155 immediately or choose a waiting time as long as 80s. Finally the <code>prompt</code> can be
paul@38 156 deactivated using the value <code>0</code>, F1, F2, F3 display help files and F4 displays a text file:
paul@38 157 </p>
paul@38 158 <pre class="script">display isolinux.msg
paul@38 159 default slitaz
paul@38 160 label slitaz
paul@38 161 kernel /boot/bzImage
paul@38 162 append initrd=/boot/rootfs.gz rw root=/dev/null vga=788
paul@38 163 implicit 0
paul@38 164 prompt 1
paul@38 165 timeout 80
paul@38 166 F1 help.txt
paul@38 167 F2 options.txt
paul@38 168 F3 isolinux.msg
paul@38 169 F4 display.txt
paul@38 170 </pre>
paul@38 171 <p>
paul@38 172 Example of a label <code>slitazen</code> which you can add to the original
paul@38 173 to directly configure the language of the system as English and use the UK keyboard:</p>
paul@38 174 <pre class="script">label slitazen
paul@38 175 kernel /boot/bzImage
paul@38 176 append initrd=/boot/rootfs.gz rw root=/dev/null lang=en kmap=en</pre>
paul@38 177 <p>
paul@38 178 Once you've finished modifying the configuration file, don't forget to save your changes and
paul@38 179 <a href="#gen-iso">generate a bootable ISO image</a> with isolinux.
paul@38 180 </p>
paul@38 181
paul@38 182 <a name="memtest"></a>
paul@38 183 <h3>Install and use Memtest86</h3>
paul@38 184 <p>
paul@38 185 The application memtest86 (92 kB) is a tool for testing your system memory (RAM).
paul@38 186 Memtest86 performs in depth tests, that if failed, point heavily towards a hardware fault.
paul@38 187 The tool resides in the <code>boot/</code> directory and can be launched directly by typing
paul@38 188 <code>memtest</code> at the isolinux boot prompt. Navigate to <code>/home/slitaz/src</code>
paul@38 189 (if the directory dosen't exist: <code>mkdir -p /home/slitaz/src</code>), download the source
paul@38 190 and unpack:</p>
paul@38 191 <pre> # cd /home/slitaz/src
paul@38 192 # wget http://www.memtest86.com/memtest86-3.3.tar.gz
paul@38 193 # tar xzf memtest86-3.3.tar.gz
paul@38 194 </pre>
paul@38 195 <p>
paul@38 196 On unpacking the source of the memtest86 package you'll find a
paul@38 197 <code>README</code> providing information about the tool. Now you can install
paul@38 198 into the <em>root CD</em> of your ISO hacked. Based on the premise that you'll be
paul@38 199 working with a <code>/home/slitaz/hacked</code> directory, we will copy the binary
paul@38 200 you precompiled into the <code>boot/</code> directory of the root of the CD:
paul@38 201 </p>
paul@38 202 <pre> # cp memtest86-3.3/precomp.bin \
paul@38 203 /home/slitaz/hacked/rootcd/boot/memtest
paul@38 204 </pre>
paul@38 205 <p>
paul@38 206 Now that the binary is installed in the <em>root CD</em>, we can just add an entry for memtest86
paul@38 207 to the isolinux configuration file and <a href="#gen-iso">generate a bootable ISO image</a>.
paul@38 208 Navigate to <code>/home/slitaz/hacked</code> and edit <code>isolinux.cfg</code> using Leafpad:
paul@38 209 </p>
paul@38 210 <pre> # cd /home/slitaz/hacked
paul@38 211 # leafpad rootcd/boot/isolinux/isolinux.cfg &amp;
paul@38 212 </pre>
paul@38 213 <pre class="script">label memtest
paul@38 214 kernel /boot/memtest
paul@38 215 </pre>
paul@38 216 <p>
paul@38 217 Official website of <a href="http://www.memtest86.com/">Memtest86</a>
paul@38 218 </p>
paul@38 219
paul@38 220 <a name="rootfs"></a>
paul@38 221 <h3>Manipulate the Live root system</h3>
paul@38 222 <p>
paul@38 223 Changes to the Live root system allow you for example, to add a new user and password, customize graphics or
paul@38 224 execute commands automatically at boot time. The necessary operations for changing the root file system are:
paul@38 225 extract the compressed file system <code>rootfs.gz</code>, modify, rebuild the image and generate the ISO.
paul@38 226 Based on the assumption that you've <a href="#pre">prepared a working directory</a>, we begin by creating
paul@38 227 a directory to contain the files on the changed system. Since the compressed root file system is named
paul@38 228 <code>rootfs.gz</code>, we suggest you use <code>rootfs/</code> to extract to. Navigate to the <code>hacked/</code>
paul@38 229 directory, create the root directory and copy the compressed file system from <code>rootcd/boot/</code>
paul@38 230 (the root of the cdrom):
paul@38 231 </p>
paul@38 232 <pre> # cd /home/slitaz/hacked
paul@38 233 # mkdir rootfs
paul@38 234 # cp rootcd/boot/rootfs.gz rootfs
paul@38 235 </pre>
paul@38 236 <p>
paul@38 237 Now that you have the compressed copy of the system, just unpack with <code>cpio</code>.
paul@38 238 Technically <code>rootfs.gz</code> is a cpio file compressed with lzma or gzip. It's recognized like an
paul@38 239 <code>initramfs</code> image by the Linux Kernel. At the start up of the machine, the Kernel is loaded into
paul@38 240 memory, which then decompresses the system image and carries out the initialization scripts. </p>
paul@38 241 <p>To extract the file system
paul@38 242 into <code>rootfs/</code> and delete the unarchived copy (remember you can copy &amp; paste):
paul@38 243 </p>
paul@38 244 <pre> # cd rootfs
paul@38 245 # (zcat rootfs.gz 2&gt;/dev/null || lzma d rootfs.gz -so) | cpio -id
paul@38 246 # rm rootfs rootfs.gz
paul@38 247 </pre>
paul@38 248 <p>
paul@38 249 The system is now ready to be hacked, you can list all files at the root of your system by using the
paul@38 250 <code>ls</code> command.
paul@38 251 </p>
paul@38 252 <h4>Modify a file</h4>
paul@38 253 <p>
paul@38 254 To keep things simple and to help you understand the principle, we are going to change a script file in
paul@38 255 order to execute some commands to be carried out automatically when the CD starts up. The target is
paul@38 256 <code>etc/init.d/local.sh</code>, just open with your favorite text editor such as Geany:
paul@38 257 </p>
paul@38 258 <pre> # geany etc/init.d/local.sh &amp;
paul@38 259 </pre>
paul@38 260 <p>
paul@38 261 We'll add a command displaying a message and letting the system sleep for 4 seconds. Example using local script:
paul@38 262 </p>
paul@38 263 <pre class="script">echo "* Hacked SliTaz version booting..."
paul@38 264 sleep 4
paul@38 265 </pre>
paul@38 266 <h4>Rebuilding the image of the compressed system</h4>
paul@38 267 <p>
paul@38 268 Once the changes are completed, you can rebuild a compressed image of your system by using
paul@38 269 <code>find</code> to find the files, <code>cpio</code> for archiving, <code>lzma</code> and
paul@38 270 <code>gzip </code> for compression and the pipe <code>|</code> to connect
paul@38 271 everything together. This command must be launched from the root system (<code>rootfs/</code>)
paul@38 272 and creates a compressed file <code>rootfs.gz</code> in the preceding directory:
paul@38 273 </p>
paul@38 274 <pre> # find . -print | cpio -o -H newc | lzma e -si -so &gt; ../rootfs.gz
paul@38 275 Ou avec gzip :
paul@38 276 # find . -print | cpio -o -H newc | gzip -9 &gt; ../rootfs.gz
paul@38 277 </pre>
paul@38 278 <p>
paul@38 279 Finally copy the compressed file system into the <code>boot/</code> directory at the root of the CD and
paul@38 280 <a href="#gen-iso">generate a bootable ISO image</a> with isolinux. To copy the newly compressed
paul@38 281 <em>rootfs</em> into the working directory:
paul@38 282 </p>
paul@38 283 <pre> # cd ../
paul@38 284 # cp -a rootfs.gz rootcd/boot
paul@38 285 </pre>
paul@38 286
paul@38 287 <a name="gen-iso"></a>
paul@38 288 <h3>Generate a bootable ISO image</h3>
paul@38 289 <p>
paul@38 290 The following commands create an image with the
paul@38 291 <em>boot loader</em> <code>isolinux</code>, using the
paul@38 292 <code>genisoimage</code> application and a few options. The name of the ISO is
paul@38 293 specified at the beginning, after the <code>-o</code> option and the root directory
paul@38 294 (<code>rootcd/</code>) at the end, after the <code>-boot-info-table</code> option:
paul@38 295 </p>
paul@38 296 <pre> # genisoimage -R -o slitaz-hacked.iso -b boot/isolinux/isolinux.bin \
paul@38 297 -c boot/isolinux/boot.cat -no-emul-boot -boot-load-size 4 \
paul@38 298 -V "SliTaz-Hacked" -input-charset iso8859-1 -boot-info-table rootcd
paul@38 299 </pre>
paul@38 300 <p>
paul@38 301 If you want to check the contents of the ISO before burning, just mount the image in <code>loop</code>
paul@38 302 and list the files. On SliTaz and most GNU/Linux systems, you can burn images in ISO format with the
paul@38 303 <code>wodim</code> utility.
paul@38 304 </p>
paul@38 305 <h4>Generate a new ISO via a script</h4>
paul@38 306 <p>
paul@38 307 If you wish to test out a lot of new possibilities and generate a lot of ISO images, you may want to
paul@38 308 semi-automate the process via a simple SHell script. This tiny script can be created on the command line
paul@38 309 or edited graphically, but don't forget to make it executable. You can create the script with <code>cat</code>,
paul@38 310 note that <code>EOF</code> signifies <em>End Of File</em>. To create the script <code>gen_hacked_iso.sh</code>
paul@38 311 using two variables to change the name of the ISO image and the path to the root directory of the cdrom:
paul@38 312 </p>
paul@38 313 <pre> # cat &gt; gen_hacked_iso.sh &lt;&lt; "EOF"
paul@38 314 </pre>
paul@38 315 <pre class="script">#!/bin/sh
paul@38 316 # Gen a new hacked ISO image.
paul@38 317 #
paul@38 318 ISO_NAME="slitaz-hacked.iso"
paul@38 319 ROOTCD="rootcd"
paul@38 320
paul@38 321 genisoimage -R -o $ISO_NAME -b boot/isolinux/isolinux.bin \
paul@38 322 -c boot/isolinux/boot.cat -no-emul-boot -boot-load-size 4 \
paul@38 323 -V "SliTaz-Hacked" -input-charset iso8859-1 -boot-info-table $ROOTCD
paul@38 324
paul@38 325 EOF
paul@38 326 </pre>
paul@38 327 <p>
paul@38 328 To use the script, just make it executable and execute:
paul@38 329 </p>
paul@38 330 <pre> # chmod +x gen_hacked_iso.sh
paul@38 331 # ./gen_hacked_iso.sh
paul@38 332 </pre>
paul@38 333
paul@38 334 <!-- End of content -->
paul@38 335 </div>
paul@38 336
paul@38 337 <!-- Footer. -->
paul@38 338 <div id="footer">
paul@38 339 <div class="footer-right"></div>
paul@38 340 <a href="#top">Top of the page</a> |
paul@38 341 <a href="http://www.slitaz.org/en/doc/handbook/index.html">Table of contents</a>
paul@38 342 </div>
paul@38 343
paul@38 344 <div id="copy">
paul@38 345 Copyright © 2008 <a href="http://www.slitaz.org/en/">SliTaz</a> -
paul@38 346 <a href="http://www.gnu.org/licenses/gpl.html">GNU General Public License</a>;<br />
paul@38 347 Documentation is under
paul@38 348 <a href="http://www.gnu.org/copyleft/fdl.html">GNU Free Documentation License</a>
paul@38 349 and code is <a href="http://validator.w3.org/">valid xHTML 1.0</a>.
paul@38 350 </div>
paul@38 351
paul@38 352 </body></html>