SliTaz GNU/Linux official and community documentation wiki.
.png
This translation is older than the original page and might be outdated. See what has changed.
Translations of this page:

Basis System

Errichten einer SliTaz GNU/Linux Distro läuft im RAM und verwendet BusyBox.

Über dieses Dokument

Beschreibt den Aufbau des SliTaz Basis Systems und warum wir einen Linux Kernel eine BusyBox und Syslinux für den Systemboot verwenden. SliTaz nutzt ein initramfs Archiv das beim Booten vom Kernel im RAM ausgepackt wird. Wir werden eine Box erstellen um ein Rootsystem mit 3 bis 4MB zu bekommen, um Platz zu sparen werden Libraries (Bibliotheken) und Binaries (ausführbare Dateien) dem strip Befehl unterzogen.

Skripte und Konfigurationsdateien werden mit dem nano GNU Texteditor erstellt. Selbstverständlich können Sie nano durch Ihren eigenen Texteditor ersetzen.

Dieses Dokument gründet sich auf ein HOWTO gefunden im Archiv von BusyBox und basiert wiederum auf einem Papier von Erik Anderson welches auf der Embedded Systems Conference 2001 vorgestellt wurde.

Wget src

Ein src Verzeichnis für den Download und die Kompilierung erstellen.

 # mkdir -p src
 # cd src
 # wget ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.20.tar.bz2
 # wget http://www.busybox.net/downloads/busybox-1.2.2.tar.bz2
 # wget ftp://ftp.kernel.org/pub/linux/boot/syslinux/3.xx/syslinux-3.35.tar.gz
  • SliTaz tools 1.1. Download SliTaz tools, unpack, save the file in src/ and that's it:
   # wget http://download.tuxfamily.org/slitaz/sources/tools/slitaz-tools-1.1.tar.gz
   # tar xzf slitaz-tools-1.1.tar.gz

Entpacken und vorbereiten des Linux Kernel

Wir beginnen mit dem Kompilieren des Linux Kernel was durchaus zeitintensiv sein kann.

Linux Kernel

Ihr Kernel muss das intramfs Dateisystem unterstützen andernfalls startet die CD-ROM nicht. Sie können die Module auch in ein Verzeichnis installieren damit das Hostsystem unberührt bleibt. Die Konfiguration der Linuxkernelquellen ist durch “make menuconfig” unter Verwendung von ncurses (textbasiert) oder grafisch mit “gconfig“ oder “xconfig“ unter GTK oder beziehungsweise QT erfolgt. Sie können in den SliTaz tools, Makefiles für verschiedenste Kernel 2.6.xx finden.

Eine Eigenschaft der 2.6 Kernel ist das beim erstmaligen Ausführen von menuconfig, xconfig oder config im Setup Menu die Konfiguration unseres momentanen Kernel angezeigt wird.

Die Wahl der Optionen hängt von Ihren Anforderungen ab Sie können die module-init-tools installieren um komprimierte Module zu unterstützen oder sie wählen nur die lebenswichtigsten Optionen für eine minimale Installation.

Wir wechseln in das Verzeichnis der Quellen, der Befehl mrproper bereinigt alles dann starten wir eine Konfigurationsschnittstelle. (mit gconfig, xconfig, menuconfig oder oldconfig).

 # tar xjf linux-2.6.20.tar.bz2
 # cd linux-2.6.20
 # make mrproper
 # cp ../slitaz-tools-1.1/Makefiles/linux-2.6.20-slitaz.config .config
 # make oldconfig
 (# make menuconfig)
 # make bzImage
 # make modules
 # make INSTALL_MOD_PATH=$PWD/_pkg modules_install
 # cd ..

Für weitere Informationen zum Thema Kernel kompilieren verweisen wir auf Lehrbücher. Sie können den Kernel installieren und nach dem Neustart Ihren eigenen Kernel nach den gleichen Anweisungen kompilieren.

Creation of the root system (rootfs)

The next step will create a file named 'rootfs' - Root File System, in the working directory SliTaz/:

 # mkdir ../rootfs

Install BusyBox

BusyBox (www.busybox.net) is a single executable offering versions of the main tools necessary to use a Linux kernel. It is (mainly) intended to be used embedded and can do almost anything. As well as proposing (coreutils) shell commands and a daemons system, it also provides a websever and client/server (DHCP, udhcpc).

 # tar xjf busybox-1.2.2.tar.bz2

Configure and compile, remembering the dumpkmap options, init, etc - you can find help in the Makefile in SliTaz Busybox tools. Make install creates a _install directory in the current directory:

 # cd busybox-1.2.2
 # cp ../slitaz-tools-1.1/Makefiles/busybox-1.2.2.config .config
 # make oldconfig
 (# make menuconfig)
 # make
 # make install
 # chmod 4755 _install/bin/busybox

Copy files compiled by BusyBox in the directory _install to the root file system (rootfs):

 # cp -a _install/* ../../rootfs

The linuxrc link pointing to /bin/busybox, folders /bin, /lib and /sbin were added to the directory /rootfs - you can check this. It may be that the link isn't there if you didn't select the option initrd support in Busybox. We'll delete the linuxrc link and create a link for init that points to /bin/busybox:

 # cd ../../rootfs
 # ls -CF
 bin/  linuxrc@  sbin/  usr/
 # rm linuxrc
 # ln -s bin/busybox init

ldd on BusyBox

The ldd command can show any libraries used by a program. Libraries used by Busybox may differ depending on the host system. On Debian for example, copying the libraries in /lib/tls. The following commands are given using 'v' for verbose mode. To eliminate the symbols of executable binaries and shared libraries we can utilize strip. Note you may also use the mklibs or uClibc libraries.

 # mkdir lib

SliTaz or another:

 # cp /lib/{libcrypt.so.1,libm.so.6,libc.so.6} lib
 # cp /lib/ld-linux.so.2 lib

Example on Debian Etch:

 # cp /lib/tls/{libcrypt.so.1,libm.so.6,libc.so.6} lib
 # cp /lib/ld-linux.so.2 lib

Cleanup libraries with strip:

 # strip -v lib/*

Linux tree and configuration

Make some directories for a classic Linux branch SliTaz installation. /dev for devices, /etc, /home, /usr, /proc, /root and co. To learn more about the hierarchy of a file system and its contents, there is a File System Hierarchy Standard available in various formats at www.pathname.com/fhs/.

You are free to create your own directory tree. In traditional Unix systems, /usr usually contains files from the distribution, /dev contains devices (devices), /etc contains configuration files, /lib libraries, /home for home users and /var for variable data. Note that we do not create /lib, /bin or /sbin - these are created when BusyBox is installed.

 # mkdir -p dev etc root home proc media mnt sys tmp var
 # mkdir -p usr/{lib,local,games,share} \
   var/{cache,lib,lock,log,games,run,spool} \
   media/{cdrom,flash,usbdisk}

Change permissions on the /tmp directory:

 # chmod 1777 tmp

Setting up glibc - note /etc/ld.so.conf and /etc/rpc are not essential for a micro system:

 # touch etc/ld.so.conf
 # cp /etc/rpc etc

Create the devices in /dev

This can be done with the script 'mkdevs.sh' found in BusyBox, or with our script 'mktazdevs.sh' in SliTaz tools. If you want more details, read the scripts. If you used the BusyBox version, we must still create the pts directory:

 # cp ../src/slitaz-tools-1.1/utils/mktazdevs.sh bin
 # ./bin/mktazdevs.sh dev

or:

 # cp ../src/busybox-1.2.2/examples/bootfloppy/mkdevs.sh bin
 # ./bin/mkdevs.sh dev
 # mkdir -p dev/{pts,input,shm,net,usb}

Note that we start mdev-s with the rcS script to create devices dynamically at boot.

Support for the resolution of hostnames (DNS)

Copy the libraries libnss_* of the host system into our SliTaz system. These libraries are used for name resolution and are cleaned with strip:

 # cp /lib/{libnss_dns.so.2,libnss_files.so.2} lib
 # cp /lib/libresolv.so.2 lib
 # strip -v lib/*.so*

Configuration of your box

Create the necessary files in /etc. For more info, just look at the contents of the files. We start by creating some files relevant to the core operating system.

Configure network

Create basic files used to configure the network:

 # echo "127.0.0.1      localhost" > etc/hosts
 # echo "localnet    127.0.0.1" > etc/networks
 # echo "slitaz" > etc/hostname
 # echo "order hosts,bind" > etc/host.conf
 # echo "multi on" >> etc/host.conf

/etc/nsswitch.conf

Configuration files used to resolve names:

 # nano etc/nsswitch.conf
  # /etc/nsswitch.conf: GNU Name Service Switch config.
  #

  passwd:     files
  group:      files
  shadow:     files

  hosts:      files dns
  networks:   files

/etc/securetty

/etc/securetty lists terminals that can connect to root:

 # nano etc/securetty
  # /etc/securetty: List of terminals on which root is allowed to login.
  #
  console

  # For people with serial port consoles
  ttyS0

  # Standard consoles
  tty1
  tty2
  tty3
  tty4
  tty5
  tty6
  tty7

/etc/shells

/etc/shells, a shells list of valid connections. This file is used by the SSH server (Dropbear):

 # nano etc/shells
  # /etc/shells: valid login shells.
  /bin/sh
  /bin/ash
  /bin/hush

/etc/issue and /etc/motd

/etc/issue is displayed at the end of boot and the message of the day is displayed after logging in:

 # echo "SliTaz GNU/Linux 1.0 Kernel \r \l" > etc/issue
 # echo "" >> etc/issue
 # nano etc/motd
   (°-  { Get documentation in: /usr/share/doc.
   //\    Use: 'less' or 'more' to read files, 'su' to be root. }
   v_/_

  SliTaz is distributed in the hope that it will be useful, but
  with ABSOLUTELY NO WARRANTY.

/etc/busybox.conf

The configuration file for BusyBox, it can set duties on BusyBox applications. For more information, you can read the security page in the Handbook. BusyBox.conf file:

 # nano etc/busybox.conf
  # /etc/busybox.conf: SliTaz GNU/linux Busybox configuration.
  #

  [SUID]
  # Allow command to be run by anyone.
  su = ssx root.root
  passwd = ssx root.root
  loadkmap = ssx root.root
  mount = ssx root.root
  reboot = ssx root.root
  halt = ssx root.root

For added security, change the permissions on the file:

 # chmod 600 etc/busybox.conf

/etc/inittab

Minimal configuration file for init. It helps to have a root console without having to go through the login and a console on tty2.

 # nano etc/inittab
  # /etc/inittab: init configuration for SliTaz GNU/Linux.

  ::sysinit:/etc/init.d/rcS
  ::respawn:-/bin/sh
  tty2::askfirst:-/bin/sh
  ::ctrlaltdel:/bin/umount -a -r
  ::ctrlaltdel:/sbin/reboot

You will also find a wider example of an inittab file in the archive of BusyBox.

/etc/profile

This file is read at each login and affects all users. We must use the ./profile config file for each individual user:

 # nano etc/profile
  # /etc/profile: system-wide .profile file for the Bourne shells

  PATH="/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
  LD_LIBRARY_PATH="/usr/lib:/lib"

  if [ "`id -u`" -eq 0 ]; then
    PS1='\e[1m\u@\h:\w\#\e[m '
  else
    PS1='\e[1m\u@\h:\w\$\e[m '
  fi

  DISPLAY=:0.0

  export PATH LD_LIBRARY_PATH PS1 DISPLAY ignoreeof
  umask 022

Users, groups and passwords

Create configuration files of users, groups and passwords in /etc/ {passwd, shadow, group, gshadow}, and adjust permissions:

 # echo "root:x:0:0:root:/root:/bin/sh" > etc/passwd
 # echo "root::13525:0:99999:7:::" > etc/shadow
 # echo "root:x:0:" > etc/group
 # echo "root:*::" > etc/gshadow
 # chmod 640 etc/shadow
 # chmod 640 etc/gshadow

You can add other users, like hacker is used by the LiveCD mode. You can also configure a password for the root user with the “passwd” command. To add an existing user to an existing group, you must edit /etc/group and /etc/gshadow because the applet “adduser” provided by BusyBox doesn't offer all of the options provided by the original program.

/etc/fstab or /etc/mtab

List filesystems to be mounted:

 # nano etc/fstab
  # /etc/fstab: information about static file system.
  #
  proc            /proc        proc    defaults          0       0
  sysfs           /sys         sysfs   defaults          0       0
  devpts          /dev/pts     devpts  defaults          0       0
  tmpfs           /dev/shm     tmpfs   defaults          0       0

/etc/mtab is used by other mkfs*, for listing the mounted partitions. It needs /proc because there is a link on /proc/mounts:

 # chroot . /bin/ash
 /# ln -s /proc/mounts /etc/mtab

Keyboard

You can create a kmap file specific to your keyboard with the dumpkmap command provided by BusyBox. You can find some kmap files in SliTaz tools. To create a fr_CH kmap file:

 /# mkdir /usr/share/kmap
 /# /bin/busybox dumpkmap > /usr/share/kmap/fr_CH.kmap
 /# exit

Once this is done, you can automatically load your keyboard with loadkmap in a /etc/init.d/rcS script:

/usr/share/doc

You can also add various documents, such as a SliTaz user manual, which you can download as a tar.gz from the website:

 # mkdir -p usr/share/doc

Installing the udhcpc script

Udhcpc DHCP client supplied by Busybox is fast and stable, but is developed independently. Web site: http://udhcp.busybox.net/. You can use the default script found in the archive of BusyBox. This script goes into /usr/share/udhcpc/default.script, but this can be changed via the command line. On SliTaz, the client is started at boot by the script /etc/init.d/network.sh via the configuration file /etc/network.conf:

 # mkdir usr/share/udhcpc
 # cp ../src/busybox-1.2.2/examples/udhcp/simple.script \
   usr/share/udhcpc/default.script
 # chmod +x usr/share/udhcpc/default.script

/etc/init.d/rcS

To finish off this draft, you must create the init script /etc/init.d/rcS to mount the filesystems and run some commands. For more information, you can look at the boot scripts page. You can change the value of the variable KMAP= for the keyboard:

 # mkdir etc/init.d
 # nano etc/init.d/rcS
  #! /bin/sh
  # /etc/init.d/rcS: rcS initial script.
  #

  KMAP=fr_CH

  echo "Processing /etc/init.d/rcS... "

  /bin/mount proc
  /bin/mount -a
  /bin/hostname -F /etc/hostname
  /sbin/ifconfig lo 127.0.0.1 up
  /sbin/loadkmap < /usr/share/kmap/$KMAP.kmap

   # chmod +x etc/init.d/rcS

Note

Note that you can still install the Tazpkg package manager (10 kb) that we created, you will find information to install in the source tarball. You can also install various files from SliTaz tools, such as the licence.

Build an initramfs cpio archive

The initramfs is a “cpio” archive generated from the root of the system, it is decompressed in RAM by the Linux kernel at boot to create the filesystem (also in RAM). To generate an initramfs archive, using the root directory of system files (rootfs), we facilitate a search with “find” and add some pipes “|”. Then we create a cpio archive using “gzip” which we put in the working directory.

The SliTaz initramfs rootfs.gz is the root system, but with a ”.gz” extension. If you want to change the name, you need to edit the configuration file for isolinux: isolinux.cfg or the menu.lst for GRUB.

Generation of the initramfs:

 # find . -print | cpio -o -H newc | gzip -9 > ../rootfs.gz

You should now have a file rootfs.gz about 1 to 2MB in the working directory SliTaz/.

For a new image, when making changes in rootfs, simply copy the new rootfs.gz archive to rootcd/boot and create a new image with “genisoimage” or “mkisofs”. For this you can also use mktaziso within SliTaz tools. This script will check if the directories are present, create a new compressed cpio archive and generate a new bootable ISO image.

Make rootcd files

The following steps will help you create the root of the bootable CD-ROM. We begin by creating the rootcd, boot and isolinux directories for the cd-rom files:

 # cd ..
 # mkdir -p rootcd/boot/isolinux

Optionally, you can create some other directories in which to place various data, such as HTML documents or packages.

Copy the kernel

Just copy the kernel previously compiled to rootcd/boot:

 # cp src/linux-2.6.20/arch/i386/boot/bzImage rootcd/boot

Copy the initramfs into rootcd/boot

Copy the rootfs.gz to rootcd/boot. We must not forget to generate a new initramfs archive for any changes made to the rootfs (root file system):

 # cp rootfs.gz rootcd/boot

Install the isolinux bootloader

The bootloader isolinux - simply copy the isolinux.bin from the source archive of Syslinux:

 # cd src
 # tar xzf syslinux-3.35.tar.gz
 # cp syslinux-3.35/isolinux.bin ../rootcd/boot/isolinux
 # cd ..

isolinux.cfg - Configure isolinux

Here is an example of an isolinux.cfg file that should work well. You can change it if you wish:

 # nano rootcd/boot/isolinux/isolinux.cfg
  display display.txt
  default slitaz
  label slitaz
      kernel /boot/bzImage
      append initrd=/boot/rootfs.gz rw root=/dev/null vga=788
  implicit 0
  prompt 1
  timeout 80

Here are some changes that you might like to make in isolinux.cfg:

  • The timeout value is the number of seconds to wait before booting You can make it 0 or delete the line to start instantly, or choose to wait as long as 10s.
  • prompt can be set to 0 to disable the 'boot:' prompt.
  • You can add more lines to view the contents of several text files when the user presses F1, F2, F3, etc.

display.txt

A small welcome note, powered by isolinux, you can modify this file if you wish:

 # nano rootcd/boot/isolinux/display.txt
  /*       _\|/_
           (o o)
   +----oOO-{_}-OOo---------------------------------------------------+
       ____  _ _ _____
      / ___|| (_)_   _|_ _ ____
      \___ \| | | | |/ _` |_  /
       ___) | | | | | (_| |/ /
      |____/|_|_| |_|\__,_/___|

   SliTaz GNU/Linux - Temporary Autonomous Zone

       <ENTER> to boot.

                                                                     */

Create an ISO image with genisoimage or mkisofs

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

For each change in the root of the box, you must create a new ISO image.

You can create a small script that will generate a new compressed cpio archive and a new image, or use mktaziso within SliTaz tools. Note that you can also use GRUB to boot the box.

Burn or test ISO image with Qemu

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:

# wodim -v -speed=24 -data slitaz-cooking.iso

Qemu

Note that you can test the ISO image with the software emulator Qemu (On Debian # aptitude install qemu). To emulate the newly created ISO image, simply type:

# qemu -cdrom slitaz-cooking.iso

Following chapter

The next chapter Base applications provides all the instructions to install and configure the basic applications and libraries.

 
de/scratchbook/base-system.txt · Last modified: 2012/04/19 07:06 by mtas