# HG changeset patch # User Paul Issott # Date 1209770051 0 # Node ID b0f82bed43559e721e25afded6ca7d29990f596d # Parent 455fdf8c74690142050f301ef8de79507c3b1bd5 Add Hacking LiveCD to Handbook (en) diff -r 455fdf8c7469 -r b0f82bed4355 en/doc/handbook/hacking-livecd.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/en/doc/handbook/hacking-livecd.html Fri May 02 23:14:11 2008 +0000 @@ -0,0 +1,351 @@ + + + + + SliTaz Handbook (en) - Template + + + + + + + + + + + + + + + +
+
+ +

Hacking SliTaz LiveCD

+ + + + +

Introduction

+

+Hacking SliTaz LiveCD or how to have fun with the LiveCD ISO image. Note that you can also +create a custom flavor with Tazlito. +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 +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, +so there's plenty of scope for expansion. For example, you could store your images and even provide a live slideshow +using GQview. The hacking of the ISO image allows you to modify boot loader configuration files +(boot loader), splash images and GRUB itself. You could also add the +Memtest86 utility (tool used to test system RAM). Using the same techniques it's even possible to +modify the filesystem - this does however require some extra manipulation and a bit more time.

+ + +

Organisation and preparation

+

+To begin, first we must define where we are going to work by creating a directory and several sub directories +to accomodate all the different files. The hacking of the ISO can be done from within a SliTaz system or any +other GNU/Linux distribution such as Debian, Fedora, PCLinuxOS etc. If you use SliTaz LiveCD mode +(where you can remove the CD once SliTaz has launched in RAM and burn your new ISO), It's advisible to use +USB media to carry on working, otherwise your work will be lost on shutdown. To begin you need to create a +hacking directory that you can use inside /home/slitaz within the +root of your user space. The use of a /home/slitaz directory enables you to store an original +ISO image and gives you the option to create a src/ directory to download possible source packages. +All the various stages of hacking can be done on the command line via a X terminal (Xterm) or in console mode +on a Linux terminal. It's advisable to run all commands as root to avoid any permission problems. +To become the (root) adminsistrator, create a /home/slitaz/hacked directory and proceed +inside: +

+
 $ su
+ # mkdir -p /home/slitaz/hacked
+ (# mkdir -p /home/slitaz/src)
+ # cd /home/slitaz/hacked
+
+

Getting the contents of the ISO

+

+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 (bzImage), the compressed +filesystem (rootfs.gz) and the isolinux bootloader files. To recover these files you have two +options, either take them from a burnt CD or from an ISO image stored locally. To create the root of your CD +(rootcd) and copy files from the cdrom device /dev/cdrom mounted on +/media/cdrom: +

+
 # mount -t iso9660 /dev/cdrom /media/cdrom
+ # mkdir rootcd
+ # cp -a /media/cdrom/* rootcd
+
+

+To mount an ISO image using loop in the temporary directory /tmp/loop +(with the ISO image slitaz-cooking.iso), create the root of the CD +(rootcd), copy all the files and dismount the ISO image: +

+
 # mkdir /tmp/loop
+ # mount -o loop slitaz-cooking.iso /tmp/loop
+ # mkdir rootcd
+ # cp -a /tmp/loop/* rootcd
+ # umount /tmp/loop
+
+

+Voilą, all the necessary files should now be present in the rootcd/ directory. +To be sure, you can list all of the files recursively with the ls command: +

+
 # ls -R rootcd
+
+ + +

Adding the files to the ISO

+

+The addition of various files and directories to the ISO image simply consists of copying data to +the root of the cdrom (rootcd/) and generating a new image. The data may be classified +in one or two directories created in the root of the CD. Once the ISO image is burnt to a CD-R/CD-RW +you can use SliTaz as before, mounted on /media/cdrom and navigate through your data using +emelFM2, Clex or the command line. You data will also be legible from all GNU/Linux systems, BSD or even +... Windows. +

+

Create directories and copy data

+

+To create and copy files, you can start by using the command line and then continue on graphically as a simple +user. We will create a images/ directory as root and change the permissions so that all +users can have write access: +

+
 # mkdir rootcd/images
+ # chmod 777 rootcd/images
+
+

+Now that a directory exists that anybody can write to, you can start to fill it. Once you've finished +you can then generate a bootable ISO image. +

+ + +

Modify the isolinux configuration

+

+The modification of isolinux allows you to create custom entries with pre-boot parameters, +for example you can add a label launching SliTaz with the lang=en +and kmap=en options. At the design level you can easily change the splash +image displayed at startup. The isolinux application manages the starting of the +boot loader of the LiveCD and is provided by the Syslinux package. The source file of +Syslinux provides various applications whose role it is to start a GNU/Linux system. The binary +isolinux.bin controls the actual boot loading. The boot loader is simple, fast and easily +configured either graphically or using a text editor. The syntax of the configuration file +isolinux.cfg is easy to understand - to add new entries just copy and paste using the +original file. To edit the file graphically using Leafpad: +

+
 # leafpad rootcd/boot/isolinux/isolinux.cfg &
+
+

Configuration file isolinux.cfg

+

+The isolinux.cfg file found on the standard LiveCD of +SliTaz, begins with the value display, this will either display +a text file or a (isolinux.msg) file using 24 ASCII characters and +a splash image. The default value defines the name of the label +started by default after the (timeout) waiting time. Timeout is the +number of seconds to wait before booting the system, you can make it 0 to start booting +immediately or choose a waiting time as long as 80s. Finally the prompt can be +deactivated using the value 0, F1, F2, F3 display help files and F4 displays a text file: +

+
display isolinux.msg
+default slitaz
+label slitaz
+      kernel /boot/bzImage
+      append initrd=/boot/rootfs.gz rw root=/dev/null vga=788
+implicit 0	
+prompt 1	
+timeout 80
+F1 help.txt
+F2 options.txt
+F3 isolinux.msg
+F4 display.txt
+
+

+Example of a label slitazen which you can add to the original +to directly configure the language of the system as English and use the UK keyboard:

+
label slitazen
+      kernel /boot/bzImage
+      append initrd=/boot/rootfs.gz rw root=/dev/null lang=en kmap=en
+

+Once you've finished modifying the configuration file, don't forget to save your changes and +generate a bootable ISO image with isolinux. +

+ + +

Install and use Memtest86

+

+The application memtest86 (92 kB) is a tool for testing your system memory (RAM). +Memtest86 performs in depth tests, that if failed, point heavily towards a hardware fault. +The tool resides in the boot/ directory and can be launched directly by typing +memtest at the isolinux boot prompt. Navigate to /home/slitaz/src +(if the directory dosen't exist: mkdir -p /home/slitaz/src), download the source +and unpack:

+
 # cd /home/slitaz/src
+ # wget http://www.memtest86.com/memtest86-3.3.tar.gz
+ # tar xzf memtest86-3.3.tar.gz
+
+

+On unpacking the source of the memtest86 package you'll find a +README providing information about the tool. Now you can install +into the root CD of your ISO hacked. Based on the premise that you'll be +working with a /home/slitaz/hacked directory, we will copy the binary +you precompiled into the boot/ directory of the root of the CD: +

+
 # cp memtest86-3.3/precomp.bin \
+   /home/slitaz/hacked/rootcd/boot/memtest
+
+

+Now that the binary is installed in the root CD, we can just add an entry for memtest86 +to the isolinux configuration file and generate a bootable ISO image. +Navigate to /home/slitaz/hacked and edit isolinux.cfg using Leafpad: +

+
 # cd /home/slitaz/hacked
+ # leafpad rootcd/boot/isolinux/isolinux.cfg &
+
+
label memtest
+      kernel /boot/memtest
+
+

+Official website of Memtest86 +

+ + +

Manipulate the Live root system

+

+Changes to the Live root system allow you for example, to add a new user and password, customize graphics or +execute commands automatically at boot time. The necessary operations for changing the root file system are: +extract the compressed file system rootfs.gz, modify, rebuild the image and generate the ISO. +Based on the assumption that you've prepared a working directory, we begin by creating +a directory to contain the files on the changed system. Since the compressed root file system is named +rootfs.gz, we suggest you use rootfs/ to extract to. Navigate to the hacked/ +directory, create the root directory and copy the compressed file system from rootcd/boot/ +(the root of the cdrom): +

+
 # cd /home/slitaz/hacked
+ # mkdir rootfs
+ # cp rootcd/boot/rootfs.gz rootfs
+
+

+Now that you have the compressed copy of the system, just unpack with cpio. +Technically rootfs.gz is a cpio file compressed with lzma or gzip. It's recognized like an +initramfs image by the Linux Kernel. At the start up of the machine, the Kernel is loaded into +memory, which then decompresses the system image and carries out the initialization scripts.

+

To extract the file system + into rootfs/ and delete the unarchived copy (remember you can copy & paste): +

+
 # cd rootfs
+ # (zcat rootfs.gz 2>/dev/null || lzma d rootfs.gz -so) | cpio -id
+ # rm rootfs rootfs.gz
+
+

+The system is now ready to be hacked, you can list all files at the root of your system by using the +ls command. +

+

Modify a file

+

+To keep things simple and to help you understand the principle, we are going to change a script file in +order to execute some commands to be carried out automatically when the CD starts up. The target is +etc/init.d/local.sh, just open with your favorite text editor such as Geany: +

+
 # geany etc/init.d/local.sh &
+
+

+We'll add a command displaying a message and letting the system sleep for 4 seconds. Example using local script: +

+
echo "* Hacked SliTaz version booting..."
+sleep 4
+
+

Rebuilding the image of the compressed system

+

+Once the changes are completed, you can rebuild a compressed image of your system by using +find to find the files, cpio for archiving, lzma and +gzip for compression and the pipe | to connect +everything together. This command must be launched from the root system (rootfs/) +and creates a compressed file rootfs.gz in the preceding directory: +

+
 # find . -print | cpio -o -H newc | lzma e -si -so > ../rootfs.gz
+ Ou avec gzip :
+ # find . -print | cpio -o -H newc | gzip -9 > ../rootfs.gz
+
+

+Finally copy the compressed file system into the boot/ directory at the root of the CD and +generate a bootable ISO image with isolinux. To copy the newly compressed +rootfs into the working directory: +

+
 # cd ../
+ # cp -a rootfs.gz rootcd/boot
+
+ + +

Generate a bootable ISO image

+

+The following commands create an image with the +boot loader isolinux, using the +genisoimage application and a few options. The name of the ISO is +specified at the beginning, after the -o option and the root directory +(rootcd/) at the end, after the -boot-info-table option: +

+
 # genisoimage -R -o slitaz-hacked.iso -b boot/isolinux/isolinux.bin \
+   -c boot/isolinux/boot.cat -no-emul-boot -boot-load-size 4 \
+   -V "SliTaz-Hacked" -input-charset iso8859-1 -boot-info-table rootcd
+
+

+If you want to check the contents of the ISO before burning, just mount the image in loop +and list the files. On SliTaz and most GNU/Linux systems, you can burn images in ISO format with the +wodim utility. +

+

Generate a new ISO via a script

+

+If you wish to test out a lot of new possibilities and generate a lot of ISO images, you may want to +semi-automate the process via a simple SHell script. This tiny script can be created on the command line +or edited graphically, but don't forget to make it executable. You can create the script with cat, +note that EOF signifies End Of File. To create the script gen_hacked_iso.sh +using two variables to change the name of the ISO image and the path to the root directory of the cdrom: +

+
 # cat > gen_hacked_iso.sh << "EOF"
+
+
#!/bin/sh
+# Gen a new hacked ISO image.
+#
+ISO_NAME="slitaz-hacked.iso"
+ROOTCD="rootcd"
+
+genisoimage -R -o $ISO_NAME -b boot/isolinux/isolinux.bin \
+   -c boot/isolinux/boot.cat -no-emul-boot -boot-load-size 4 \
+   -V "SliTaz-Hacked" -input-charset iso8859-1 -boot-info-table $ROOTCD
+
+EOF
+
+

+To use the script, just make it executable and execute: +

+
 # chmod +x gen_hacked_iso.sh
+ # ./gen_hacked_iso.sh
+
+ + +
+ + + + +
+ Copyright © 2008 SliTaz - + GNU General Public License;
+ Documentation is under + GNU Free Documentation License + and code is valid xHTML 1.0. +
+ + diff -r 455fdf8c7469 -r b0f82bed4355 en/doc/handbook/index.html --- a/en/doc/handbook/index.html Fri May 02 10:32:03 2008 +0000 +++ b/en/doc/handbook/index.html Fri May 02 23:14:11 2008 +0000 @@ -47,6 +47,8 @@ own LiveCD flavor using Tazlito.
  • LiveUSB media - Create bootable USB media using TazUSB.
  • +
  • Hacking LiveCD - Manipulate and play with the ISO + image of LiveCD.
  • About this Handbook

    diff -r 455fdf8c7469 -r b0f82bed4355 en/doc/handbook/liveusb.html --- a/en/doc/handbook/liveusb.html Fri May 02 10:32:03 2008 +0000 +++ b/en/doc/handbook/liveusb.html Fri May 02 23:14:11 2008 +0000 @@ -18,6 +18,7 @@