website rev 38
Add Hacking LiveCD to Handbook (en)
author | Paul Issott <paul@slitaz.org> |
---|---|
date | Fri May 02 23:14:11 2008 +0000 (2008-05-02) |
parents | 455fdf8c7469 |
children | e172c1d2ec01 |
files | en/doc/handbook/hacking-livecd.html en/doc/handbook/index.html en/doc/handbook/liveusb.html |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/en/doc/handbook/hacking-livecd.html Fri May 02 23:14:11 2008 +0000 1.3 @@ -0,0 +1,351 @@ 1.4 +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 1.5 +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 1.6 + 1.7 +<head> 1.8 + <title>SliTaz Handbook (en) - Template</title> 1.9 + <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" /> 1.10 + <meta name="description" content="slitaz English handbook" /> 1.11 + <meta name="expires" content="never" /> 1.12 + <meta name="modified" content="2008-02-26 18:30:00" /> 1.13 + <meta name="publisher" content="www.slitaz.org" /> 1.14 + <meta name="author" content="Christophe Lincoln" /> 1.15 + <link rel="shortcut icon" href="favicon.ico" /> 1.16 + <link rel="stylesheet" type="text/css" href="book.css" /> 1.17 +</head> 1.18 +<body bgcolor="#ffffff" > 1.19 + 1.20 +<!-- Header and quick navigation --> 1.21 +<div id="header"> 1.22 +<div id="quicknav" align="right"> 1.23 + <a name="top"></a> 1.24 + <a href="index.html">Table of contents</a> 1.25 +</div> 1.26 +<h1><font color="#3e1220">SliTaz Handbook (en)</font></h1> 1.27 +</div> 1.28 + 1.29 +<!-- Content. --> 1.30 +<div id="content"> 1.31 +<div class="content-right"></div> 1.32 + 1.33 +<h2><font color="#df8f06">Hacking SliTaz LiveCD</font></h2> 1.34 + 1.35 +<ul> 1.36 + <li><a href="#intro">Introduction.</a></li> 1.37 + <li><a href="#pre">Organisation and preparation.</a></li> 1.38 + <li><a href="#add-files">Add files to the ISO.</a></li> 1.39 + <li><a href="#isolinux">Modify the isolinux configuration.</a></li> 1.40 + <li><a href="#memtest">Install and use Memtest86.</a></li> 1.41 + <li><a href="#rootfs">Manipulate the Live root system.</a></li> 1.42 + <li><a href="#gen-iso">Generate a bootable ISO image with isolinux.</a></li> 1.43 +</ul> 1.44 + 1.45 +<a name="intro"></a> 1.46 +<h3>Introduction</h3> 1.47 +<p> 1.48 +<em>Hacking SliTaz LiveCD</em> or how to have fun with the LiveCD ISO image. Note that you can also 1.49 +<a href="gen-livecd.html">create a custom flavor with Tazlito</a>. 1.50 +Creating your own bootable ISO image is easily acheivable and the steps are carefully described here. The manipulation of a personal ISO image can add new files or modify existing 1.51 +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, 1.52 +so there's plenty of scope for expansion. For example, you could store your images and even provide a <em>live</em> slideshow 1.53 +using GQview. The <em>hacking</em> of the ISO image allows you to modify boot loader configuration files 1.54 +(<em>boot loader</em>), <em>splash</em> images and GRUB itself. You could also add the 1.55 +Memtest86 utility (tool used to test system RAM). Using the same techniques it's even possible to 1.56 +modify the filesystem - this does however require some extra manipulation and a bit more time.</p> 1.57 + 1.58 +<a name="pre"></a> 1.59 +<h3>Organisation and preparation</h3> 1.60 +<p> 1.61 +To begin, first we must define where we are going to work by creating a directory and several sub directories 1.62 +to accomodate all the different files. The <em>hacking</em> of the ISO can be done from within a SliTaz system or any 1.63 +other GNU/Linux distribution such as Debian, Fedora, PCLinuxOS etc. If you use SliTaz LiveCD mode 1.64 +(where you can remove the CD once SliTaz has launched in RAM and burn your new ISO), It's advisible to use 1.65 +USB media to carry on working, otherwise your work will be lost on shutdown. To begin you need to create a 1.66 +<em>hacking</em> directory that you can use inside <code>/home/slitaz</code> within the 1.67 +root of your user space. The use of a <code>/home/slitaz</code> directory enables you to store an original 1.68 +ISO image and gives you the option to create a <code>src/</code> directory to download possible source packages. 1.69 +All the various stages of <em>hacking</em> can be done on the command line via a X terminal (Xterm) or in console mode 1.70 +on a Linux terminal. It's advisable to run all commands as <em>root</em> to avoid any permission problems. 1.71 +To become the (<em>root</em>) adminsistrator, create a <code>/home/slitaz/hacked</code> directory and proceed 1.72 +inside: 1.73 +</p> 1.74 +<pre> $ su 1.75 + # mkdir -p /home/slitaz/hacked 1.76 + (# mkdir -p /home/slitaz/src) 1.77 + # cd /home/slitaz/hacked 1.78 +</pre> 1.79 +<h4>Getting the contents of the ISO</h4> 1.80 +<p> 1.81 +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 1.82 +filesystem (<code>rootfs.gz</code>) and the isolinux bootloader files. To recover these files you have two 1.83 +options, either take them from a burnt CD or from an ISO image stored locally. To create the root of your CD 1.84 +(<code>rootcd</code>) and copy files from the cdrom device <code>/dev/cdrom</code> mounted on 1.85 +<code>/media/cdrom</code>: 1.86 +</p> 1.87 +<pre> # mount -t iso9660 /dev/cdrom /media/cdrom 1.88 + # mkdir rootcd 1.89 + # cp -a /media/cdrom/* rootcd 1.90 +</pre> 1.91 +<p> 1.92 +To mount an ISO image using <em>loop</em> in the temporary directory <code>/tmp/loop</code> 1.93 +(with the ISO image <code>slitaz-cooking.iso</code>), create the root of the CD 1.94 +(<code>rootcd</code>), copy all the files and dismount the ISO image: 1.95 +</p> 1.96 +<pre> # mkdir /tmp/loop 1.97 + # mount -o loop slitaz-cooking.iso /tmp/loop 1.98 + # mkdir rootcd 1.99 + # cp -a /tmp/loop/* rootcd 1.100 + # umount /tmp/loop 1.101 +</pre> 1.102 +<p> 1.103 +Voilą, all the necessary files should now be present in the <code>rootcd/</code> directory. 1.104 +To be sure, you can list all of the files recursively with the <code>ls</code> command: 1.105 +</p> 1.106 +<pre> # ls -R rootcd 1.107 +</pre> 1.108 + 1.109 +<a name="add-files"></a> 1.110 +<h3>Adding the files to the ISO</h3> 1.111 +<p> 1.112 +The addition of various files and directories to the ISO image simply consists of copying data to 1.113 +the root of the cdrom (<code>rootcd/</code>) and generating a new image. The data may be classified 1.114 +in one or two directories created in the root of the CD. Once the ISO image is burnt to a CD-R/CD-RW 1.115 +you can use SliTaz as before, mounted on <code>/media/cdrom</code> and navigate through your data using 1.116 +emelFM2, Clex or the command line. You data will also be legible from all GNU/Linux systems, BSD or even 1.117 +... Windows. 1.118 +</p> 1.119 +<h4>Create directories and copy data</h4> 1.120 +<p> 1.121 +To create and copy files, you can start by using the command line and then continue on graphically as a simple 1.122 +user. We will create a <code>images/</code> directory as <em>root</em> and change the permissions so that all 1.123 +users can have write access: 1.124 +</p> 1.125 +<pre> # mkdir rootcd/images 1.126 + # chmod 777 rootcd/images 1.127 +</pre> 1.128 +<p> 1.129 +Now that a directory exists that anybody can write to, you can start to fill it. Once you've finished 1.130 +you can then <a href="#gen-iso">generate a bootable ISO image</a>. 1.131 +</p> 1.132 + 1.133 +<a name="isolinux"></a> 1.134 +<h3>Modify the isolinux configuration</h3> 1.135 +<p> 1.136 +The modification of isolinux allows you to create custom entries with <em>pre-boot</em> parameters, 1.137 +for example you can add a <code>label</code> launching SliTaz with the <code>lang=en</code> 1.138 +and <code>kmap=en</code> options. At the design level you can easily change the <em>splash</em> 1.139 +image displayed at startup. The <code>isolinux</code> application manages the starting of the 1.140 +<em>boot loader</em> of the LiveCD and is provided by the Syslinux package. The source file of 1.141 +Syslinux provides various applications whose role it is to start a GNU/Linux system. The binary 1.142 +<code>isolinux.bin</code> controls the actual boot loading. The boot loader is simple, fast and easily 1.143 +configured either graphically or using a text editor. The syntax of the configuration file 1.144 +<code>isolinux.cfg</code> is easy to understand - to add new entries just copy and paste using the 1.145 +original file. To edit the file graphically using Leafpad: 1.146 +</p> 1.147 +<pre> # leafpad rootcd/boot/isolinux/isolinux.cfg & 1.148 +</pre> 1.149 +<h4>Configuration file isolinux.cfg</h4> 1.150 +<p> 1.151 +The <code>isolinux.cfg</code> file found on the standard LiveCD of 1.152 +SliTaz, begins with the value <code>display</code>, this will either display 1.153 +a text file or a (<code>isolinux.msg</code>) file using 24 ASCII characters and 1.154 +a splash image. The <code>default</code> value defines the name of the <code>label</code> 1.155 +started by default after the (<code>timeout</code>) waiting time. <em>Timeout</em> is the 1.156 +number of seconds to wait before booting the system, you can make it 0 to start booting 1.157 +immediately or choose a waiting time as long as 80s. Finally the <code>prompt</code> can be 1.158 +deactivated using the value <code>0</code>, F1, F2, F3 display help files and F4 displays a text file: 1.159 +</p> 1.160 +<pre class="script">display isolinux.msg 1.161 +default slitaz 1.162 +label slitaz 1.163 + kernel /boot/bzImage 1.164 + append initrd=/boot/rootfs.gz rw root=/dev/null vga=788 1.165 +implicit 0 1.166 +prompt 1 1.167 +timeout 80 1.168 +F1 help.txt 1.169 +F2 options.txt 1.170 +F3 isolinux.msg 1.171 +F4 display.txt 1.172 +</pre> 1.173 +<p> 1.174 +Example of a label <code>slitazen</code> which you can add to the original 1.175 +to directly configure the language of the system as English and use the UK keyboard:</p> 1.176 +<pre class="script">label slitazen 1.177 + kernel /boot/bzImage 1.178 + append initrd=/boot/rootfs.gz rw root=/dev/null lang=en kmap=en</pre> 1.179 +<p> 1.180 +Once you've finished modifying the configuration file, don't forget to save your changes and 1.181 +<a href="#gen-iso">generate a bootable ISO image</a> with isolinux. 1.182 +</p> 1.183 + 1.184 +<a name="memtest"></a> 1.185 +<h3>Install and use Memtest86</h3> 1.186 +<p> 1.187 +The application memtest86 (92 kB) is a tool for testing your system memory (RAM). 1.188 +Memtest86 performs in depth tests, that if failed, point heavily towards a hardware fault. 1.189 +The tool resides in the <code>boot/</code> directory and can be launched directly by typing 1.190 +<code>memtest</code> at the isolinux boot prompt. Navigate to <code>/home/slitaz/src</code> 1.191 +(if the directory dosen't exist: <code>mkdir -p /home/slitaz/src</code>), download the source 1.192 +and unpack:</p> 1.193 +<pre> # cd /home/slitaz/src 1.194 + # wget http://www.memtest86.com/memtest86-3.3.tar.gz 1.195 + # tar xzf memtest86-3.3.tar.gz 1.196 +</pre> 1.197 +<p> 1.198 +On unpacking the source of the memtest86 package you'll find a 1.199 +<code>README</code> providing information about the tool. Now you can install 1.200 +into the <em>root CD</em> of your ISO hacked. Based on the premise that you'll be 1.201 +working with a <code>/home/slitaz/hacked</code> directory, we will copy the binary 1.202 +you precompiled into the <code>boot/</code> directory of the root of the CD: 1.203 +</p> 1.204 +<pre> # cp memtest86-3.3/precomp.bin \ 1.205 + /home/slitaz/hacked/rootcd/boot/memtest 1.206 +</pre> 1.207 +<p> 1.208 +Now that the binary is installed in the <em>root CD</em>, we can just add an entry for memtest86 1.209 +to the isolinux configuration file and <a href="#gen-iso">generate a bootable ISO image</a>. 1.210 +Navigate to <code>/home/slitaz/hacked</code> and edit <code>isolinux.cfg</code> using Leafpad: 1.211 +</p> 1.212 +<pre> # cd /home/slitaz/hacked 1.213 + # leafpad rootcd/boot/isolinux/isolinux.cfg & 1.214 +</pre> 1.215 +<pre class="script">label memtest 1.216 + kernel /boot/memtest 1.217 +</pre> 1.218 +<p> 1.219 +Official website of <a href="http://www.memtest86.com/">Memtest86</a> 1.220 +</p> 1.221 + 1.222 +<a name="rootfs"></a> 1.223 +<h3>Manipulate the Live root system</h3> 1.224 +<p> 1.225 +Changes to the Live root system allow you for example, to add a new user and password, customize graphics or 1.226 +execute commands automatically at boot time. The necessary operations for changing the root file system are: 1.227 +extract the compressed file system <code>rootfs.gz</code>, modify, rebuild the image and generate the ISO. 1.228 +Based on the assumption that you've <a href="#pre">prepared a working directory</a>, we begin by creating 1.229 +a directory to contain the files on the changed system. Since the compressed root file system is named 1.230 +<code>rootfs.gz</code>, we suggest you use <code>rootfs/</code> to extract to. Navigate to the <code>hacked/</code> 1.231 +directory, create the root directory and copy the compressed file system from <code>rootcd/boot/</code> 1.232 +(the root of the cdrom): 1.233 +</p> 1.234 +<pre> # cd /home/slitaz/hacked 1.235 + # mkdir rootfs 1.236 + # cp rootcd/boot/rootfs.gz rootfs 1.237 +</pre> 1.238 +<p> 1.239 +Now that you have the compressed copy of the system, just unpack with <code>cpio</code>. 1.240 +Technically <code>rootfs.gz</code> is a cpio file compressed with lzma or gzip. It's recognized like an 1.241 +<code>initramfs</code> image by the Linux Kernel. At the start up of the machine, the Kernel is loaded into 1.242 +memory, which then decompresses the system image and carries out the initialization scripts. </p> 1.243 +<p>To extract the file system 1.244 + into <code>rootfs/</code> and delete the unarchived copy (remember you can copy & paste): 1.245 +</p> 1.246 +<pre> # cd rootfs 1.247 + # (zcat rootfs.gz 2>/dev/null || lzma d rootfs.gz -so) | cpio -id 1.248 + # rm rootfs rootfs.gz 1.249 +</pre> 1.250 +<p> 1.251 +The system is now ready to be hacked, you can list all files at the root of your system by using the 1.252 +<code>ls</code> command. 1.253 +</p> 1.254 +<h4>Modify a file</h4> 1.255 +<p> 1.256 +To keep things simple and to help you understand the principle, we are going to change a script file in 1.257 +order to execute some commands to be carried out automatically when the CD starts up. The target is 1.258 +<code>etc/init.d/local.sh</code>, just open with your favorite text editor such as Geany: 1.259 +</p> 1.260 +<pre> # geany etc/init.d/local.sh & 1.261 +</pre> 1.262 +<p> 1.263 +We'll add a command displaying a message and letting the system sleep for 4 seconds. Example using local script: 1.264 +</p> 1.265 +<pre class="script">echo "* Hacked SliTaz version booting..." 1.266 +sleep 4 1.267 +</pre> 1.268 +<h4>Rebuilding the image of the compressed system</h4> 1.269 +<p> 1.270 +Once the changes are completed, you can rebuild a compressed image of your system by using 1.271 +<code>find</code> to find the files, <code>cpio</code> for archiving, <code>lzma</code> and 1.272 +<code>gzip </code> for compression and the pipe <code>|</code> to connect 1.273 +everything together. This command must be launched from the root system (<code>rootfs/</code>) 1.274 +and creates a compressed file <code>rootfs.gz</code> in the preceding directory: 1.275 +</p> 1.276 +<pre> # find . -print | cpio -o -H newc | lzma e -si -so > ../rootfs.gz 1.277 + Ou avec gzip : 1.278 + # find . -print | cpio -o -H newc | gzip -9 > ../rootfs.gz 1.279 +</pre> 1.280 +<p> 1.281 +Finally copy the compressed file system into the <code>boot/</code> directory at the root of the CD and 1.282 +<a href="#gen-iso">generate a bootable ISO image</a> with isolinux. To copy the newly compressed 1.283 +<em>rootfs</em> into the working directory: 1.284 +</p> 1.285 +<pre> # cd ../ 1.286 + # cp -a rootfs.gz rootcd/boot 1.287 +</pre> 1.288 + 1.289 +<a name="gen-iso"></a> 1.290 +<h3>Generate a bootable ISO image</h3> 1.291 +<p> 1.292 +The following commands create an image with the 1.293 +<em>boot loader</em> <code>isolinux</code>, using the 1.294 +<code>genisoimage</code> application and a few options. The name of the ISO is 1.295 +specified at the beginning, after the <code>-o</code> option and the root directory 1.296 +(<code>rootcd/</code>) at the end, after the <code>-boot-info-table</code> option: 1.297 +</p> 1.298 +<pre> # genisoimage -R -o slitaz-hacked.iso -b boot/isolinux/isolinux.bin \ 1.299 + -c boot/isolinux/boot.cat -no-emul-boot -boot-load-size 4 \ 1.300 + -V "SliTaz-Hacked" -input-charset iso8859-1 -boot-info-table rootcd 1.301 +</pre> 1.302 +<p> 1.303 +If you want to check the contents of the ISO before burning, just mount the image in <code>loop</code> 1.304 +and list the files. On SliTaz and most GNU/Linux systems, you can burn images in ISO format with the 1.305 +<code>wodim</code> utility. 1.306 +</p> 1.307 +<h4>Generate a new ISO via a script</h4> 1.308 +<p> 1.309 +If you wish to test out a lot of new possibilities and generate a lot of ISO images, you may want to 1.310 +semi-automate the process via a simple SHell script. This tiny script can be created on the command line 1.311 +or edited graphically, but don't forget to make it executable. You can create the script with <code>cat</code>, 1.312 +note that <code>EOF</code> signifies <em>End Of File</em>. To create the script <code>gen_hacked_iso.sh</code> 1.313 +using two variables to change the name of the ISO image and the path to the root directory of the cdrom: 1.314 +</p> 1.315 +<pre> # cat > gen_hacked_iso.sh << "EOF" 1.316 +</pre> 1.317 +<pre class="script">#!/bin/sh 1.318 +# Gen a new hacked ISO image. 1.319 +# 1.320 +ISO_NAME="slitaz-hacked.iso" 1.321 +ROOTCD="rootcd" 1.322 + 1.323 +genisoimage -R -o $ISO_NAME -b boot/isolinux/isolinux.bin \ 1.324 + -c boot/isolinux/boot.cat -no-emul-boot -boot-load-size 4 \ 1.325 + -V "SliTaz-Hacked" -input-charset iso8859-1 -boot-info-table $ROOTCD 1.326 + 1.327 +EOF 1.328 +</pre> 1.329 +<p> 1.330 +To use the script, just make it executable and execute: 1.331 +</p> 1.332 +<pre> # chmod +x gen_hacked_iso.sh 1.333 + # ./gen_hacked_iso.sh 1.334 +</pre> 1.335 + 1.336 +<!-- End of content --> 1.337 +</div> 1.338 + 1.339 +<!-- Footer. --> 1.340 +<div id="footer"> 1.341 + <div class="footer-right"></div> 1.342 + <a href="#top">Top of the page</a> | 1.343 + <a href="http://www.slitaz.org/en/doc/handbook/index.html">Table of contents</a> 1.344 +</div> 1.345 + 1.346 +<div id="copy"> 1.347 + Copyright © 2008 <a href="http://www.slitaz.org/en/">SliTaz</a> - 1.348 + <a href="http://www.gnu.org/licenses/gpl.html">GNU General Public License</a>;<br /> 1.349 + Documentation is under 1.350 + <a href="http://www.gnu.org/copyleft/fdl.html">GNU Free Documentation License</a> 1.351 + and code is <a href="http://validator.w3.org/">valid xHTML 1.0</a>. 1.352 +</div> 1.353 + 1.354 +</body></html>
2.1 --- a/en/doc/handbook/index.html Fri May 02 10:32:03 2008 +0000 2.2 +++ b/en/doc/handbook/index.html Fri May 02 23:14:11 2008 +0000 2.3 @@ -47,6 +47,8 @@ 2.4 own LiveCD flavor using Tazlito.</li> 2.5 <li><a href="liveusb.html">LiveUSB media</a> - Create bootable USB media 2.6 using TazUSB.</li> 2.7 + <li><a href="hacking-livecd.html">Hacking LiveCD</a> - Manipulate and play with the ISO 2.8 + image of LiveCD.</li> 2.9 </ul> 2.10 2.11 <h3>About this Handbook</h3>
3.1 --- a/en/doc/handbook/liveusb.html Fri May 02 10:32:03 2008 +0000 3.2 +++ b/en/doc/handbook/liveusb.html Fri May 02 23:14:11 2008 +0000 3.3 @@ -18,6 +18,7 @@ 3.4 <div id="header"> 3.5 <div align="right" id="quicknav"> 3.6 <a name="top"></a> 3.7 + <a href="hacking-livecd.html">Hacking LiveCD</a> | 3.8 <a href="index.html">Table of contents</a> 3.9 </div> 3.10 <h1><font color="#3E1220">SliTaz Handbook (en)</font></h1>