website annotate en/doc/scratchbook/base-system.html @ rev 1344

Resize balinor logo to 120px
author Christophe Lincoln <pankso@slitaz.org>
date Fri Jan 22 23:02:15 2021 +0100 (2021-01-22)
parents c2f9d5d0f314
children
rev   line source
al@1285 1 <!DOCTYPE html>
al@1285 2 <html lang="en">
paul@197 3 <head>
al@1285 4 <meta charset="UTF-8">
al@1285 5 <title>SliTaz Scratchbook - Base System</title>
al@1285 6 <meta name="description" content="">
al@1285 7 <meta name="expires" content="never">
al@1285 8 <meta name="modified" content="2008-11-22 17:00:00">
al@1285 9 <meta name="publisher" content="www.slitaz.org">
al@1285 10 <meta name="author" content="Christophe Lincoln">
al@1285 11 <link rel="shortcut icon" href="favicon.ico">
al@1285 12 <link rel="stylesheet" href="book.css">
paul@197 13 </head>
al@1285 14 <body>
paul@197 15
paul@197 16 <!-- Header and quick navigation -->
paul@197 17 <div id="header">
paul@197 18 <div align="right" id="quicknav">
al@1285 19 <span id="top"></span>
paul@226 20 <a href="index.html">Table of contents</a> |
paul@226 21 <a href="base-apps.html">Base apps</a>
paul@197 22 </div>
paul@197 23 <h1><font color="#3E1220">SliTaz Scratchbook</font></h1>
paul@197 24 </div>
paul@197 25
paul@197 26 <!-- Content. -->
paul@197 27 <div id="content">
paul@197 28 <div class="content-right"></div>
paul@197 29
paul@197 30
paul@197 31 <h2><font color="#df8f06">Base System</font></h2>
paul@197 32 <p>
paul@197 33 Build a SliTaz GNU/Linux distro running in RAM and using BusyBox.
paul@197 34 </p>
paul@197 35 <ul>
al@1006 36 <li><a href="#about">About.</a></li>
al@1006 37 <li><a href="#src">Wget src.</a></li>
al@1285 38 <li><a href="#prepa">Unpack and prepare the Linux Kernel.</a></li>
al@1006 39 <li><a href="#rootfs">Creation of the Root System</a>, the root
paul@197 40 file System (rootfs).</li>
al@1006 41 <li><a href="#config">Configure the box.</a></li>
al@1006 42 <li><a href="#initramfs">Generate the initramfs</a>, compressed cpio archive.</li>
al@1285 43 <li><a href="#rootcd">Construction of the root of the CD-ROM</a> (rootcd), and the
paul@197 44 configuration files of Syslinux.</li>
al@1006 45 <li><a href="#mkiso">Create an ISO image with genisoimage or mkisofs.</a></li>
al@1006 46 <li><a href="#testiso">Burn or test the ISO with Qemu.</a></li>
paul@197 47 </ul>
al@1285 48
al@1285 49 <h3 id="about">About</h3>
paul@197 50 <p>
paul@197 51 This document describes the construction of the SliTaz base system and why we use a
paul@197 52 Linux Kernel, BusyBox and Syslinux to boot the system. SliTaz uses an initramfs
al@1285 53 archive unpacked in RAM by the Kernel at boot. We will create a box to hold a
paul@197 54 root of 3 to 4MB and use strip on the libraries and binaries to save space.
paul@197 55 </p>
paul@197 56 <p>
paul@197 57 The scripts and configuration files are created with GNU nano, using the keystroke
paul@197 58 &lt;ctrl+x&gt; to save and exit. But of course you are free to replace with your own text editor.
paul@197 59 </p>
paul@197 60 <p>
paul@197 61 This document is based on a howto found in the archive of BusyBox, which is itself based on
paul@197 62 a paper presented by Erik Anderson in the Embedded Systems Conference in 2001.
paul@197 63 </p>
al@1285 64
al@1285 65 <h3 id="src">Wget src</h3>
paul@197 66 <p>
paul@197 67 Create a src directory for downloading and compiling:
paul@197 68 </p>
paul@197 69 <pre> # mkdir -p src
paul@197 70 # cd src
paul@197 71 </pre>
paul@197 72 <ul>
paul@197 73 <li>Linux Kernel 2.6.20
paul@197 74 (<a href="http://www.kernel.org/">http://www.kernel.org/</a>).
paul@197 75 <pre># wget ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.20.tar.bz2</pre>
paul@197 76 </li>
paul@197 77 <li>Busybox 1.2.2
paul@197 78 (<a href="http://www.busybox.net/">http://www.busybox.net/</a>).
paul@197 79 <pre># wget http://www.busybox.net/downloads/busybox-1.2.2.tar.bz2</pre>
paul@197 80 </li>
paul@197 81 <li>Syslinux 3.35
paul@197 82 (<a href="http://syslinux.zytor.com/">http://syslinux.zytor.com/</a>).
paul@197 83 <pre># wget ftp://ftp.kernel.org/pub/linux/boot/syslinux/syslinux-3.35.tar.gz</pre>
paul@197 84 </li>
paul@197 85 <li>SliTaz tools 1.1. Download SliTaz tools, unpack, save the file in src/ and that's it:
paul@197 86 <pre> # wget http://download.tuxfamily.org/slitaz/sources/tools/slitaz-tools-1.1.tar.gz
paul@197 87 # tar xzf slitaz-tools-1.1.tar.gz</pre>
paul@197 88 </li>
paul@197 89 </ul>
al@1285 90
al@1285 91 <h3 id="prepa">Unpack and prepare the Linux Kernel</h3>
paul@197 92 <p>
al@1285 93 We will begin by compiling a Linux Kernel, which may take a little time.
paul@197 94 </p>
paul@197 95 <h4>Linux Kernel</h4>
paul@197 96 <p>
al@1285 97 Your Kernel must support the intramfs filesystem, otherwise the CD-ROM will not start. You can
paul@197 98 also install the modules in a directory so as not to touch the host system. The configuration
paul@197 99 of the Linux kernel sources is done by <code>make menuconfig</code> using ncurses or graphically
paul@197 100 with <code>make gconfig</code> or <code>make xconfig</code> using GTK development packages and/or
al@1285 101 Qt respectively. You can find in <a href="http://doc.slitaz.org/en:cookbook:slitaztools">SliTaz tools</a>,
paul@197 102 Makefiles for the various 2.6.xx kernels.
paul@197 103 </p>
paul@197 104 <p>
al@1285 105 A feature of the 2.6 Kernels is that if we make menuconfig, xconfig or config for the first time,
paul@197 106 the setup menu is displayed based on the configuration of our current kernel.
paul@197 107 </p>
paul@197 108 <p>
paul@197 109 The options depend on your needs, you can install module-init-tools to support compressed modules
paul@197 110 or for a minimal install, you can select only the vital options.
paul@197 111 </p>
paul@197 112 <p>
paul@197 113 We start by changing into the sources, <code>make mrproper</code> to put things in order, then we start a
paul@197 114 configuration interface: gconfig, xconfig, menuconfig or oldconfig:
paul@197 115 </p>
paul@197 116 <pre> # tar xjf linux-2.6.20.tar.bz2
paul@197 117 # cd linux-2.6.20
paul@197 118 # make mrproper
paul@197 119 # cp ../slitaz-tools-1.1/Makefiles/linux-2.6.20-slitaz.config .config
paul@197 120 # make oldconfig
paul@197 121 (# make menuconfig)
paul@197 122 # make bzImage
paul@197 123 # make modules
paul@197 124 # make INSTALL_MOD_PATH=$PWD/_pkg modules_install
paul@197 125 # cd ..
paul@197 126 </pre>
paul@197 127 <p>
al@1285 128 If you want more info on compiling Kernels, there are many textbooks. Note that you can install the
al@1285 129 Kernel and after rebooting, you can compile your own Kernel following the same instructions.
paul@197 130 </p>
al@1285 131
al@1285 132 <h3 id="rootfs">Creation of the root system (rootfs)</h3>
paul@197 133 <p>
al@1285 134 The next step will create a file named ‘rootfs’ - Root File System, in the working directory SliTaz/:
paul@197 135 </p>
paul@197 136 <pre> # mkdir ../rootfs
paul@197 137 </pre>
paul@197 138 <h4>Install BusyBox</h4>
paul@197 139 <p>
paul@197 140 BusyBox (<a href="http://www.busybox.net/">www.busybox.net</a>) is a single executable offering
al@1285 141 versions of the main tools necessary to use a Linux Kernel. It is (mainly) intended to be used
paul@197 142 embedded and can do almost anything. As well as proposing (coreutils) shell commands and a daemons
paul@197 143 system, it also provides a websever and client/server (DHCP, udhcpc).
paul@197 144 </p>
paul@197 145 <pre> # tar xjf busybox-1.2.2.tar.bz2
paul@197 146 </pre>
paul@197 147 <p>
paul@197 148 Configure and compile, remembering the dumpkmap options, init, etc - you can find help in the Makefile in
paul@197 149 SliTaz Busybox tools. Make install creates a _install directory in the current directory:
paul@197 150 </p>
paul@197 151 <pre> # cd busybox-1.2.2
paul@197 152 # cp ../slitaz-tools-1.1/Makefiles/busybox-1.2.2.config .config
paul@197 153 # make oldconfig
paul@197 154 (# make menuconfig)
paul@197 155 # make
paul@197 156 # make install
paul@197 157 # chmod 4755 _install/bin/busybox
paul@197 158 </pre>
paul@197 159 <p>
paul@197 160 Copy files compiled by BusyBox in the directory _install to the root file system (rootfs):
paul@197 161 </p>
paul@197 162 <pre> # cp -a _install/* ../../rootfs
paul@197 163 </pre>
paul@197 164 <p>
paul@197 165 The linuxrc link pointing to /bin/busybox, folders /bin, /lib and /sbin were added to the directory
paul@197 166 /rootfs - you can check this. It may be that the link isn't there if you didn't select the option
paul@197 167 initrd support in Busybox. We'll delete the linuxrc link and create a link for init that points to
paul@197 168 /bin/busybox:
paul@197 169 </p>
paul@197 170 <pre> # cd ../../rootfs
paul@197 171 # ls -CF
paul@197 172 bin/ linuxrc@ sbin/ usr/
paul@197 173
paul@197 174 # rm linuxrc
paul@197 175 # ln -s bin/busybox init
paul@197 176 </pre>
paul@197 177 <h4>ldd on BusyBox</h4>
paul@197 178 <p>
paul@197 179 The ldd command can show any libraries used by a program. Libraries used by Busybox may differ
paul@197 180 depending on the host system. On Debian for example, copying the libraries in /lib/tls. The following
al@1285 181 commands are given using ‘v’ for verbose mode. To eliminate the symbols of executable binaries
paul@197 182 and shared libraries we can utilize strip. Note you may also use the mklibs or uClibc libraries.
paul@197 183 </p>
paul@197 184 <pre> # mkdir lib
paul@197 185 </pre>
paul@197 186 <p>
paul@197 187 SliTaz or another:
paul@197 188 </p>
paul@197 189 <pre> # cp /lib/{libcrypt.so.1,libm.so.6,libc.so.6} lib
paul@197 190 # cp /lib/ld-linux.so.2 lib
paul@197 191 </pre>
paul@197 192 <p>
paul@197 193 Example on Debian Etch:
paul@197 194 </p>
paul@197 195 <pre> # cp /lib/tls/{libcrypt.so.1,libm.so.6,libc.so.6} lib
paul@197 196 # cp /lib/ld-linux.so.2 lib
paul@197 197 </pre>
paul@197 198 <p>
paul@197 199 Cleanup libraries with strip:
paul@197 200 </p>
paul@197 201 <pre> # strip -v lib/*
paul@197 202 </pre>
paul@197 203 <h4>Linux tree and configuration</h4>
paul@197 204 <p>
paul@197 205 Make some directories for a classic Linux branch SliTaz installation. /dev for devices, /etc, /home,
paul@197 206 /usr, /proc, /root and co. To learn more about the hierarchy of a file system and its contents,
paul@197 207 there is a File System Hierarchy Standard available in various formats at
paul@197 208 <a href="http://www.pathname.com/fhs/">www.pathname.com/fhs/</a>.
paul@197 209 </p>
paul@197 210 <p>
paul@197 211 You are free to create your own directory tree. In traditional Unix systems, /usr usually contains
paul@222 212 files from the distribution, /dev contains devices (devices), /etc contains configuration files,
paul@197 213 /lib libraries, /home for home users and /var for variable data. Note that we do not create
paul@197 214 /lib, /bin or /sbin - these are created when BusyBox is installed.
paul@197 215 </p>
paul@197 216 <pre> # mkdir -p dev etc root home proc media mnt sys tmp var
paul@197 217 # mkdir -p usr/{lib,local,games,share} \
paul@197 218 var/{cache,lib,lock,log,games,run,spool} \
paul@197 219 media/{cdrom,flash,usbdisk}
paul@197 220 </pre>
paul@197 221 <p>
paul@197 222 Change permissions on the /tmp directory:
paul@197 223 </p>
paul@197 224 <pre> # chmod 1777 tmp
paul@197 225 </pre>
paul@197 226 <p>
paul@197 227 Setting up glibc - note /etc/ld.so.conf and /etc/rpc are not essential for a micro system:
paul@197 228 </p>
paul@197 229 <pre> # touch etc/ld.so.conf
paul@197 230 # cp /etc/rpc etc
paul@197 231 </pre>
paul@197 232 <h4>Create the devices in /dev</h4>
paul@197 233 <p>
al@1285 234 This can be done with the script ‘mkdevs.sh’ found in BusyBox, or with our script ‘mktazdevs.sh’ in
paul@310 235 SliTaz tools. If you want more details, read the scripts. If you used the BusyBox version, we must
paul@197 236 still create the pts directory:
paul@197 237 </p>
paul@197 238 <pre> # cp ../src/slitaz-tools-1.1/utils/mktazdevs.sh bin
paul@197 239 # ./bin/mktazdevs.sh dev
paul@197 240 or:
paul@197 241 # cp ../src/busybox-1.2.2/examples/bootfloppy/mkdevs.sh bin
paul@197 242 # ./bin/mkdevs.sh dev
paul@197 243 # mkdir -p dev/{pts,input,shm,net,usb}
paul@197 244 </pre>
paul@197 245 <p>
paul@197 246 Note that we start mdev-s with the rcS script to create devices dynamically at boot.
paul@197 247 </p>
paul@197 248 <h4>Support for the resolution of hostnames (DNS)</h4>
paul@197 249 <p>
paul@197 250 Copy the libraries libnss_* of the host system into our SliTaz system. These libraries are used for
paul@197 251 name resolution and are cleaned with strip:
paul@197 252 </p>
paul@197 253 <pre> # cp /lib/{libnss_dns.so.2,libnss_files.so.2} lib
paul@197 254 # cp /lib/libresolv.so.2 lib
paul@197 255 # strip -v lib/*.so*
paul@197 256 </pre>
al@1285 257
al@1285 258 <h3 id="config">Configuration of your box</h3>
paul@197 259 <p>
paul@197 260 Create the necessary files in /etc. For more info, just look at the contents of the files.
paul@197 261 We start by creating some files relevant to the core operating system.
paul@197 262 </p>
paul@197 263 <h4>Network</h4>
paul@197 264 <p>
paul@197 265 Create basic files used to configure the network:
paul@197 266 </p>
paul@197 267 <pre> # echo "127.0.0.1 localhost" &gt; etc/hosts
paul@197 268 # echo "localnet 127.0.0.1" &gt; etc/networks
paul@197 269 # echo "slitaz" &gt; etc/hostname
paul@197 270 # echo "order hosts,bind" &gt; etc/host.conf
paul@197 271 # echo "multi on" &gt;&gt; etc/host.conf
paul@197 272 </pre>
paul@197 273 <h4>/etc/nsswitch.conf</h4>
paul@197 274 <p>
paul@197 275 Configuration files used to resolve names:
paul@197 276 </p>
paul@197 277 <pre> # nano etc/nsswitch.conf
paul@197 278 </pre>
paul@197 279 <pre class="script"># /etc/nsswitch.conf: GNU Name Service Switch config.
paul@197 280 #
paul@197 281
paul@197 282 passwd: files
paul@197 283 group: files
paul@197 284 shadow: files
paul@197 285
paul@197 286 hosts: files dns
paul@197 287 networks: files
paul@197 288
paul@197 289 </pre>
paul@197 290 <h4>/etc/securetty</h4>
paul@197 291 <p>
paul@197 292 /etc/securetty lists terminals that can connect to root:
paul@197 293 </p>
paul@197 294 <pre> # nano etc/securetty
paul@197 295 </pre>
paul@197 296 <pre class="script"># /etc/securetty: List of terminals on which root is allowed to login.
paul@197 297 #
paul@197 298 console
paul@197 299
paul@197 300 # For people with serial port consoles
paul@197 301 ttyS0
paul@197 302
paul@197 303 # Standard consoles
paul@197 304 tty1
paul@197 305 tty2
paul@197 306 tty3
paul@197 307 tty4
paul@197 308 tty5
paul@197 309 tty6
paul@197 310 tty7
paul@197 311
paul@197 312 </pre>
paul@197 313 <h4>/etc/shells</h4>
paul@197 314 <p>
paul@197 315 /etc/shells, a shells list of valid connections. This file is used by the SSH server (Dropbear):
paul@197 316 </p>
paul@197 317 <pre> # nano etc/shells
paul@197 318 </pre>
paul@197 319 <pre class="script"># /etc/shells: valid login shells.
paul@197 320 /bin/sh
paul@197 321 /bin/ash
paul@197 322 /bin/hush
paul@197 323
paul@197 324 </pre>
paul@197 325 <h4>/etc/issue and /etc/motd</h4>
paul@197 326 <p>
paul@197 327 /etc/issue is displayed at the end of boot and the message of the day is displayed after logging in:
paul@197 328 </p>
paul@197 329 <pre> # echo "SliTaz GNU/Linux 1.0 Kernel \r \l" &gt; etc/issue
paul@197 330 # echo "" &gt;&gt; etc/issue
paul@197 331 # nano etc/motd
paul@197 332 </pre>
paul@197 333 <pre class="script">
al@1006 334 (°- { Get documentation in: /usr/share/doc.
paul@197 335 //\ Use: 'less' or 'more' to read files, 'su' to be root. }
paul@197 336 v_/_
paul@197 337
paul@197 338 SliTaz is distributed in the hope that it will be useful, but
paul@197 339 with ABSOLUTELY NO WARRANTY.
paul@197 340
paul@197 341 </pre>
paul@197 342 <h4>/etc/busybox.conf</h4>
paul@197 343 <p>
paul@197 344 The configuration file for BusyBox, it can set duties on BusyBox applications. For more information, you can read the
pascal@845 345 <a href="http://doc.slitaz.org/en:handbook:security">security</a> page in the Handbook. BusyBox.conf file:
paul@197 346
paul@197 347 </p>
paul@197 348 <pre> # nano etc/busybox.conf
paul@197 349 </pre>
paul@197 350 <pre class="script"># /etc/busybox.conf: SliTaz GNU/linux Busybox configuration.
paul@197 351 #
paul@197 352
paul@197 353 [SUID]
paul@197 354 # Allow command to be run by anyone.
paul@197 355 su = ssx root.root
paul@197 356 passwd = ssx root.root
paul@197 357 loadkmap = ssx root.root
paul@197 358 mount = ssx root.root
paul@197 359 reboot = ssx root.root
paul@197 360 halt = ssx root.root
paul@197 361
paul@197 362 </pre>
paul@197 363 <p>
paul@197 364 For added security, change the permissions on the file:
paul@197 365 </p>
paul@197 366 <pre> # chmod 600 etc/busybox.conf
paul@197 367 </pre>
paul@197 368 <h4>/etc/inittab</h4>
paul@197 369 <p>
paul@197 370 Minimal configuration file for init. It helps to have a root console without having to
paul@197 371 go through the login and a console on tty2.
paul@197 372 </p>
paul@197 373 <pre> # nano etc/inittab
paul@197 374 </pre>
paul@197 375 <pre class="script"># /etc/inittab: init configuration for SliTaz GNU/Linux.
paul@197 376
paul@197 377 ::sysinit:/etc/init.d/rcS
paul@197 378 ::respawn:-/bin/sh
paul@197 379 tty2::askfirst:-/bin/sh
paul@197 380 ::ctrlaltdel:/bin/umount -a -r
paul@197 381 ::ctrlaltdel:/sbin/reboot
paul@197 382
paul@197 383 </pre>
paul@197 384 <p>
paul@197 385 You will also find a wider example of an inittab file in the archive of BusyBox.
paul@197 386 </p>
paul@197 387 <h4>/etc/profile</h4>
paul@197 388 <p>
paul@197 389 This file is read at each login and affects all users. We must use the ./profile
paul@197 390 config file for each individual user:
paul@197 391 </p>
paul@197 392 <pre> # nano etc/profile
paul@197 393 </pre>
paul@197 394 <pre class="script"># /etc/profile: system-wide .profile file for the Bourne shells
paul@197 395
paul@197 396 PATH="/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
paul@197 397 LD_LIBRARY_PATH="/usr/lib:/lib"
paul@197 398
paul@197 399 if [ "`id -u`" -eq 0 ]; then
paul@197 400 PS1='\e[1m\u@\h:\w\#\e[m '
paul@197 401 else
paul@197 402 PS1='\e[1m\u@\h:\w\$\e[m '
paul@197 403 fi
paul@197 404
paul@197 405 DISPLAY=:0.0
paul@197 406
paul@197 407 export PATH LD_LIBRARY_PATH PS1 DISPLAY ignoreeof
paul@197 408 umask 022
paul@197 409
paul@197 410 </pre>
paul@197 411 <h4>Users, groups and passwords</h4>
paul@197 412 <p>
paul@197 413 Create configuration files of users, groups and passwords in /etc/ {passwd, shadow, group, gshadow}, and adjust permissions:
paul@197 414 </p>
paul@197 415 <pre> # echo "root:x:0:0:root:/root:/bin/sh" &gt; etc/passwd
paul@197 416 # echo "root::13525:0:99999:7:::" &gt; etc/shadow
paul@197 417 # echo "root:x:0:" &gt; etc/group
paul@197 418 # echo "root:*::" &gt; etc/gshadow
paul@197 419 # chmod 640 etc/shadow
paul@197 420 # chmod 640 etc/gshadow
paul@197 421 </pre>
paul@197 422 <p>
paul@197 423 You can add other users, like hacker is used by the LiveCD mode. You can also configure a password for the root user
paul@197 424 with the <code>passwd</code> command. To add an existing user to an existing group, you must edit /etc/group and /etc/gshadow because
paul@197 425 the applet <code>adduser</code> provided by BusyBox doesn't offer all of the options provided by the original program.
paul@197 426 </p>
paul@197 427 <h4>/etc/fstab or /etc/mtab</h4>
paul@197 428 <p>
paul@197 429 List filesystems to be mounted:
paul@197 430 </p>
paul@197 431 <pre> # nano etc/fstab
paul@197 432 </pre>
paul@197 433 <pre class="script"># /etc/fstab: information about static file system.
paul@197 434 #
paul@197 435 proc /proc proc defaults 0 0
paul@197 436 sysfs /sys sysfs defaults 0 0
paul@197 437 devpts /dev/pts devpts defaults 0 0
paul@197 438 tmpfs /dev/shm tmpfs defaults 0 0
paul@197 439
paul@197 440 </pre>
paul@197 441 <p>
paul@197 442 /etc/mtab is used by other mkfs*, for listing the mounted partitions. It needs /proc because there is a link on /proc/mounts:
paul@197 443 </p>
paul@197 444 <pre> # chroot . /bin/ash
paul@197 445 /# ln -s /proc/mounts /etc/mtab
paul@197 446 </pre>
paul@197 447 <h4>Keyboard</h4>
paul@197 448 <p>
paul@197 449 You can create a kmap file specific to your keyboard with the dumpkmap command provided by BusyBox.
paul@197 450 You can find some kmap files in SliTaz tools. To create a fr_CH kmap file:
paul@197 451 </p>
paul@197 452 <pre> /# mkdir /usr/share/kmap
paul@197 453 /# /bin/busybox dumpkmap &gt; /usr/share/kmap/fr_CH.kmap
paul@197 454 /# exit
paul@197 455 </pre>
paul@197 456 <p>
paul@197 457 Once this is done, you can automatically load your keyboard with loadkmap in a /etc/init.d/rcS script:
paul@197 458 </p>
paul@197 459 <h4>/usr/share/doc</h4>
paul@197 460 <p>
paul@197 461 You can also add various documents, such as a SliTaz user manual, which you can download as a tar.gz from the website:
paul@197 462 </p>
paul@197 463 <pre> # mkdir -p usr/share/doc
paul@197 464 </pre>
paul@197 465 <h4>Installing the udhcpc script</h4>
paul@197 466 <p>
paul@197 467 Udhcpc DHCP client supplied by Busybox is fast and stable, but is developed independently.
paul@197 468 Web site: <a href="http://udhcp.busybox.net/">http://udhcp.busybox.net/</a>. You can use the default
paul@197 469 script found in the archive of BusyBox. This script goes into /usr/share/udhcpc/default.script,
paul@197 470 but this can be changed via the command line. On SliTaz, the client is started at boot by the script
paul@197 471 /etc/init.d/network.sh via the configuration file /etc/network.conf:
paul@197 472 </p>
paul@197 473 <pre> # mkdir usr/share/udhcpc
paul@197 474 # cp ../src/busybox-1.2.2/examples/udhcp/simple.script \
paul@197 475 usr/share/udhcpc/default.script
paul@197 476 # chmod +x usr/share/udhcpc/default.script
paul@197 477 </pre>
paul@197 478 <h4>/etc/init.d/rcS</h4>
paul@197 479 <p>
paul@197 480 To finish off this draft, you must create the init script /etc/init.d/rcS to mount the filesystems
paul@197 481 and run some commands. For more information, you can look at the
pascal@844 482 <a href="http://doc.slitaz.org/en:cookbook:bootscripts">boot scripts</a> page.
paul@197 483 You can change the value of the variable KMAP= for the keyboard:
paul@197 484 </p>
paul@197 485 <pre> # mkdir etc/init.d
paul@197 486 # nano etc/init.d/rcS
paul@197 487 </pre>
paul@197 488 <pre class="script">#! /bin/sh
paul@197 489 # /etc/init.d/rcS: rcS initial script.
paul@197 490 #
paul@197 491
paul@197 492 KMAP=fr_CH
paul@197 493
paul@197 494 echo "Processing /etc/init.d/rcS... "
paul@197 495
paul@197 496 /bin/mount proc
paul@197 497 /bin/mount -a
paul@197 498 /bin/hostname -F /etc/hostname
paul@197 499 /sbin/ifconfig lo 127.0.0.1 up
paul@197 500 /sbin/loadkmap &lt; /usr/share/kmap/$KMAP.kmap
paul@197 501
paul@197 502
paul@197 503 </pre>
paul@197 504 <pre> # chmod +x etc/init.d/rcS
paul@197 505 </pre>
paul@197 506 <h4>Note</h4>
paul@197 507 <p>
paul@285 508 Note that you can still install the Tazpkg package manager (10 kb) that we created,
paul@197 509 you will find information to install in the source tarball. You can also install various
paul@197 510 files from SliTaz tools, such as the licence.
paul@197 511 </p>
paul@197 512
al@1285 513 <h3 id="initramfs">Build an initramfs cpio archive</h3>
paul@197 514 <p>
paul@197 515 The initramfs is a <code>cpio</code> archive generated from the root of the system,
al@1285 516 it is decompressed in RAM by the Linux Kernel at boot to create the filesystem (also in RAM).
paul@197 517 To generate an initramfs archive, using the root directory of system files (rootfs), we
paul@197 518 facilitate a search with <code>find</code> and add some pipes <code>|</code>.
paul@197 519 Then we create a cpio archive using <code>gzip</code> which we put in the working directory.
paul@197 520 </p>
paul@197 521 <p>
paul@197 522 The SliTaz initramfs <strong>rootfs.gz</strong> is the root system, but with a <code>.gz</code>
paul@197 523 extension. If you want to change the name, you need to edit the configuration file for
paul@197 524 isolinux: isolinux.cfg or the menu.lst for GRUB.
paul@197 525 </p>
paul@197 526 <p>
paul@197 527 Generation of the initramfs:
paul@197 528 </p>
paul@197 529 <pre> # find . -print | cpio -o -H newc | gzip -9 &gt; ../rootfs.gz
paul@197 530 </pre>
paul@197 531 <p>
paul@285 532 You should now have a file rootfs.gz about 1 to 2MB in the working directory SliTaz/.
paul@197 533 </p>
paul@197 534 <p>
paul@197 535 For a new image, when making changes in rootfs, simply copy the new rootfs.gz archive to rootcd/boot
paul@197 536 and create a new image with <code>genisoimage</code> or <code>mkisofs</code>. For this you can also
paul@197 537 use <strong>mktaziso</strong> within SliTaz tools. This script will check if the directories are present,
paul@222 538 create a new compressed cpio archive and generate a new bootable ISO image.
paul@197 539 </p>
al@1285 540
al@1285 541 <h3 id="rootcd">Make rootcd files</h3>
paul@197 542 <p>
paul@197 543 The following steps will help you create the root of the bootable CD-ROM. We begin by creating the rootcd,
al@1285 544 boot and isolinux directories for the CD-ROM files:
paul@197 545 </p>
paul@197 546 <pre> # cd ..
paul@197 547 # mkdir -p rootcd/boot/isolinux
paul@197 548 </pre>
paul@197 549 <p>
paul@197 550 Optionally, you can create some other directories in which to place various data, such as HTML documents or packages.
paul@197 551 </p>
al@1285 552
al@1285 553 <h4 id="linux">Copy the Kernel</h4>
paul@197 554 <p>
al@1285 555 Just copy the Kernel previously compiled to rootcd/boot:
paul@197 556 </p>
paul@197 557 <pre> # cp src/linux-2.6.20/arch/i386/boot/bzImage rootcd/boot
paul@197 558 </pre>
paul@197 559 <h4>Copy the initramfs into rootcd/boot</h4>
paul@197 560 <p>
paul@197 561 Copy the rootfs.gz to rootcd/boot. We must not forget to generate a new initramfs archive for any changes
paul@197 562 made to the rootfs (root file system):
paul@197 563 </p>
paul@197 564 <pre> # cp rootfs.gz rootcd/boot
paul@197 565 </pre>
paul@197 566 <h4>Install the isolinux bootloader</h4>
paul@197 567 <p>
paul@197 568 The bootloader isolinux - simply copy the isolinux.bin from the source archive of Syslinux:
paul@197 569 </p>
paul@197 570 <pre> # cd src
paul@197 571 # tar xzf syslinux-3.35.tar.gz
paul@197 572 # cp syslinux-3.35/isolinux.bin ../rootcd/boot/isolinux
paul@197 573 # cd ..
paul@197 574 </pre>
paul@197 575 <h4>isolinux.cfg - Configure isolinux</h4>
paul@197 576 <p>
paul@197 577 Here is an example of an isolinux.cfg file that should work well. You can change it if you wish:
paul@197 578 </p>
paul@197 579 <pre> # nano rootcd/boot/isolinux/isolinux.cfg
paul@197 580 </pre>
paul@197 581 <pre class="script">display display.txt
paul@197 582 default slitaz
paul@197 583 label slitaz
paul@197 584 kernel /boot/bzImage
paul@197 585 append initrd=/boot/rootfs.gz rw root=/dev/null vga=788
paul@197 586 implicit 0
paul@197 587 prompt 1
paul@197 588 timeout 80
paul@197 589
paul@197 590 </pre>
paul@197 591 <p>
paul@197 592 Here are some changes that you might like to make in isolinux.cfg:
paul@197 593 </p>
paul@197 594 <ul>
paul@197 595 <li>The timeout value is the number of seconds to wait before booting
paul@197 596 You can make it 0 or delete the line to start instantly, or choose to wait as long as 10s.</li>
al@1285 597 <li>prompt can be set to 0 to disable the ‘boot:’ prompt.</li>
paul@197 598 <li>You can add more lines to view the contents of several text files when the user presses F1, F2, F3, etc.</li>
paul@197 599 </ul>
paul@197 600 <h4>display.txt</h4>
paul@197 601 <p>
paul@197 602 A small welcome note, powered by isolinux, you can modify this file if you wish:
paul@197 603 </p>
paul@197 604 <pre> # nano rootcd/boot/isolinux/display.txt
paul@197 605 </pre>
al@1285 606 <pre class="script">
al@1285 607 /* _\|/_
paul@197 608 (o o)
paul@197 609 +----oOO-{_}-OOo---------------------------------------------------+
paul@197 610 ____ _ _ _____
paul@197 611 / ___|| (_)_ _|_ _ ____
paul@197 612 \___ \| | | | |/ _` |_ /
paul@197 613 ___) | | | | | (_| |/ /
paul@197 614 |____/|_|_| |_|\__,_/___|
paul@197 615
paul@197 616 SliTaz GNU/Linux - Temporary Autonomous Zone
paul@197 617
paul@197 618 &lt;ENTER&gt; to boot.
paul@197 619
paul@197 620 */
paul@197 621 </pre>
al@1285 622
al@1285 623 <h3 id="mkiso">Create an ISO image with genisoimage or mkisofs</h3>
paul@197 624 <pre> # genisoimage -R -o slitaz-cooking.iso -b boot/isolinux/isolinux.bin \
paul@197 625 -c boot/isolinux/boot.cat -no-emul-boot -boot-load-size 4 \
paul@197 626 -V "SliTaz" -input-charset iso8859-1 -boot-info-table rootcd
paul@197 627 </pre>
paul@197 628 <p>
paul@197 629 For each change in the root of the box, you must create a new ISO image.
paul@197 630 </p>
paul@197 631 <p>
paul@197 632 You can create a small script that will generate a new compressed cpio archive and a new image,
paul@197 633 or use mktaziso within SliTaz tools. Note that you can also use GRUB to boot the box.
paul@197 634 </p>
al@1285 635
al@1285 636 <h3 id="testiso">Burn or test ISO image with Qemu</h3>
paul@197 637 <p>
al@1285 638 You can burn the ISO image with Graveman, k3b or wodim and boot it. Simple burning command using wodim (also valid for cdrecord), with a 2.6.XX. Kernel:
paul@197 639 </p>
paul@197 640 <pre># wodim -v -speed=24 -data slitaz-cooking.iso
paul@197 641 </pre>
paul@197 642 <h4>Qemu</h4>
paul@197 643 <p>
paul@197 644 Note that you can test the ISO image with the software emulator Qemu (On Debian # aptitude install qemu).
paul@197 645 To emulate the newly created ISO image, simply type:
paul@197 646 </p>
paul@197 647 <pre># qemu -cdrom slitaz-cooking.iso
paul@197 648 </pre>
paul@226 649 <h4>Following chapter</h4>
paul@226 650 <p>
paul@226 651 The next chapter <a href="base-apps.html">Base applications</a> provides all the instructions to install
paul@226 652 and configure the basic applications and libraries.
paul@226 653 </p>
paul@197 654
paul@197 655 <!-- End of content -->
paul@197 656 </div>
paul@197 657
paul@197 658 <!-- Footer. -->
paul@197 659 <div id="footer">
paul@197 660 <div class="footer-right"></div>
al@1006 661 <a href="#top">Top of the page</a> |
paul@197 662 <a href="index.html">Table of contents</a>
paul@197 663 </div>
paul@197 664
paul@197 665 <div id="copy">
pascal@669 666 Copyright &copy; <span class="year"></span> <a href="http://www.slitaz.org/en/">SliTaz</a> -
paul@197 667 <a href="http://www.gnu.org/licenses/gpl.html">GNU General Public License</a>;<br />
paul@197 668 Documentation is under
paul@197 669 <a href="http://www.gnu.org/copyleft/fdl.html">GNU Free Documentation License</a>
paul@197 670 and code is <a href="http://validator.w3.org/">valid xHTML 1.0</a>.
paul@197 671 </div>
paul@197 672
paul@197 673 </body>
paul@197 674 </html>