Chinese (People's Republic of China)  English  Français


Supinfo-Projects.com
Tous les projets des élèves ingénieurs de Supinfo



Projets
  Dernier Projet
  Les plus populaires
  Tous les Projets

133 Visiteurs
3168 Projets


My Supinfo-Projects

   Connectez-vous
   Créez un Compte


Synopsis

   221 Visites
   Note INTERNET : 12
    (5 Votants)
   0 Commentaires

   Lire l'article

Evaluez cet article

20
18
16
14
12
10
8
6
4
2
0


Commentez cet article

Auteur :

Email :

Votre commentaire :



 
2005 - Pérennisation
Créer sa propre distribution Linux
[60 mn de lecture - paru le 11/24/2004 5:17:30 PM - Public : Confirmé]

Auteur

marcha_gFrançois MARCHAND
Elève-Ingénieur Supinfo Paris
Promotion SUPINFO 2004

   Lui écrire
   Tous les projets de cet auteur
   Le mini-CV de cet auteur

Part I - The Linux From Scratch Method

 

 

Linux From Scratch is the only complete documentation I have found about how to build your own Linux. It does not describe how to load the distribution in a ramdisk nor how to boot it from a CD-ROM, but explains the whole distribution building process:

-          creation of a partition and file system

-          installation of the packages for the basic development

-          building of the concrete base of the distribution

-          making the distribution bootable

 

We will strain on synthesising the method as clearly as possible without modifying it since each step depends on the previous one

 

We will use the same naming conventions that are used in the Linux From Scratch documentation project (http://linuxfromscratch.org ) so that you can refer to it to get more details.

 

I- LFS: Preparation of the system

 

A- Creating a partition

 

We need a free partition on which we can construct our system. A tool like fdisk can be used. This tool is to use with caution, indeed all your data will be lost. If you want to create a new partition when you have a Microsoft operating system, you can use Powerquest Partition Magic, it resizes the partition you already have and uses the free space to create a new partition without erasing your data. Some partitioning tools that don’t erase the content of the disk also exist for Linux.

 

We need now a filesystem for this partition. The second extended file system (ext2fs) is very common, therefore we will use it. We can use this command to create it:

 

Mk2fs /dev/disk_partition

 

Where disk_partition is the name of the disk and of the partition such as hda1.

 

We can now mount the partition under /mnt/LFS. We will first assign the mounting point to a variable so that we access is more easily.

 

Export LFS=/mnt/lfs

Mkdir –p $LFS

Mnt /dev/hda4 $LFS

 


B- The packages we need

 

Here is a list of the packages that Linux From Scratch recommends for building the basic Linux system. We will create a $LFS/sources directory accessible by a regular user to download them and work with them.

 

 


Autoconf (2.57) - 792 KB

Automake (1.7.6) - 545 KB

Bash (2.05b) - 1,910 KB

Binutils (2.14) - 10,666 KB

Bison (1.875) - 796 KB

Bzip2 (1.0.2) - 650 KB

Coreutils (5.0) - 3,860 KB

DejaGnu (1.4.3) - 1,775 KB

Diffutils (2.8.1) - 762 KB

E2fsprogs (1.34) - 3,003 KB

Ed (0.2) - 182 KB

Expect (5.39.0) - 508 KB

File (4.04) - 338 KB

Findutils (4.1.20) - 760 KB

Flex (2.5.4a) - 372 KB

Gawk (3.1.3) - 1,596 KB

GCC (2.95.3) - 9,618 KB

GCC-core (3.3.1) - 10,969 KB

GCC-g++ (3.3.1) - 2,017 KB

GCC-testsuite (3.3.1) - 1,033 KB

Gettext (0.12.1) - 5,593 KB

Glibc (2.3.2) - 13,064 KB

Glibc-linuxthreads (2.3.2) - 211 KB

Grep (2.5.1) - 545 KB

Groff (1.19) - 2,360 KB

Grub (0.93) - 870 KB

Gzip (1.3.5) - 324 KB

Inetutils (1.4.2) - 1,019 KB

Kbd (1.08) - 801 KB

Less (381) - 259 KB

LFS-Bootscripts (1.12) - 25 KB

Lfs-Utils (0.3) - 221 KB

Libtool (1.5) - 2,751 KB

Linux (2.4.22) - 28,837 KB

M4 (1.4) - 310 KB

Make (3.80) - 899 KB

MAKEDEV (1.7) - 8 KB

Man (1.5m2) - 196 KB

Man-pages (1.60) - 627 KB

Modutils (2.4.25) - 215 KB

Ncurses (5.3) - 2,019 KB

Net-tools (1.60) - 194 KB

Patch (2.5.4) - 182 KB

Perl (5.8.0) - 10,765 KB

Procinfo (18) - 24 KB

Procps (3.1.11) - 242 KB

Psmisc (21.3) - 259 KB

Sed (4.0.7) - 678 KB

Shadow (4.0.3) - 760 KB

Sysklogd (1.4.1) - 80 KB

Sysvinit (2.85) - 91 KB

Tar (1.13.25) - 1,281 KB

Tcl (8.4.4) - 3,292 KB

Texinfo (4.6) - 1,317 KB

Util-linux (2.12) - 1,814 KB

Vim (6.2) - 3,193 KB

Zlib (1.1.4) - 144 KB


 

Total size of these packages: 134 MB

 


Here is the list of the patches that correct some bugs and add functions to the previous packages.

 

 


Bash Patch - 7 KB

Bison Attribute Patch - 2 KB

Coreutils Hostname Patch - 1 KB

Coreutils Uname Patch - 1 KB

Ed Mkstemp Patch - 1 KB

Expect Spawn Patch - 6 KB

Gawk Libexecdir Patch - 1 KB

GCC No-Fixincludes Patch - 1 KB

GCC Specs Patch - 10 KB

GCC Suppress-Libiberty Patch - 1 KB

GCC-2 Patch - 16 KB

GCC-2 No-Fixincludes Patch - 1 KB

GCC-2 Return-Type Patch - 1 KB

Glibc Sscanf Patch - 2 KB

Grub Gcc33 Patch - 1 KB

Kbd More-Programs Patch - 1 KB

Man 80-Columns Patch - 1 KB

Man Manpath Patch - 1 KB

Man Pager Patch - 1 KB

Ncurses Etip Patch - 1 KB

Ncurses Vsscanf Patch - 1 KB

Net-tools Mii-Tool-Gcc33 Patch - 2 KB

Perl Libc Patch - 1 KB

Procps Locale Patch - 1 KB

Shadow Newgrp Patch - 1 KB

Zlib Vsnprintf Patch - 10 KB


 

 

The download locations are available at http://linuxfromscratch.org . If the download location has change you can find them at http://www.freshmeat.org or http://linuxfromscratch.org/lfs/packages.html .


C- Creating a subsystem

 

1-     Environment Settings

 

Once all the packages have been downloaded, we can create a new $LFS/tools directory where we will compile them.

To avoid damaging the system while running compiling as root, we create a lfs user which will have access to the $LFS/tools directory:

 

Useradd –s /bin/bash –m lfs

Passwd lfs

Chown lfs $LFS/tools

Chown lfs $LFS/sources

Su –lfs

 

After logging as lfs we can set up the environment to facilitate and secure the building process:

 

Cat > ~/.bash_profile << EOF

Set +h

Umask 022

LFS=/mnt/lfs

LC_ALL=POSIX

PATH=/tools/bin:$PATH

export LFS LC_ALL PATH

unset CC CXX CPP LD_LIBRARY_PATH LD_PRELOAD

EOF

 


source ~/.bash_profile

 

This settings turn off bash’s hash functions to avoid reusing a non upgrade version of a program, set write permission for created files to the owner only or sets /tools/bin to the standard path etc.

 

2-     Installing the packages

 

We can now start to compile our tools, for each package the general method is the following:

 

-          unpack the package

-          prepare it for compilation (./ configure)

-          compile it (make)

-          test the result (make check)

-          install the package (make install)

 

Some packages have specific building options or processes; to have more details about it, you can check the Linux From Scratch documentation.

 

The packages should be compiled in the order provided by Linux From Scratch since some packages depend from others.



Here is the list of the packages we need to install:

 


Binutils-2.14

GCC-3.3.1

Linux-2.4.22

Glibc-2.3.2

« Lock  in » Glibc

Tcl-8.4.4

Expect-5.39.0

DejaGnu-1.4.3

GCC-3.3.1

Binutils-2.14

Gawk-3.1.3

Coreutils-5.0

Bzip2-1.0.2

Gzip-1.3.5

Diffutils-2.8.1

Findutils-4.1.20

Make-3.80

Grep-2.5.1

Sed-4.0.7

Gettext-0.12.1

Ncurses-5.3

Patch-2.5.4

Tar-1.13.25

Texinfo-4.6

Bash-2.05b

Util-linux-2.12

Perl-5.8.0


 

 

 

To clean the system, we can delete the sources, the documentation and remove around 130 MB of debugging symbols from some executables and libraries.

 

Strip --strip(unneeded /tools/{ ,s}bin/*

Strip --strip-debug /tools/lib/*

 

Rm –rf /tools/{ ,share}{doc, info, man}

 

II- LFS: Building our distribution

 

A- Preparing the system

 

To install our softwares on the LFS, we need to restrain the system environment to the LFS using chroot. It changes the root from / to /LFS. This is done by running the following command:

 

chroot $LFS /tools/bin/env -i \

HOME=/root TERM=$TERM PS1='\u:\w\$ ' \

PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \

/tools/bin/bash --login

 

1-     Creating a directory structure

 

We now create a directory structure for our lfs file system:

 

mkdir -p /{bin,boot,dev/{pts,shm},etc/opt,home,lib,mnt,proc}

mkdir -p /{root,sbin,tmp,usr/local,var,opt}

for dirname in /usr /usr/local

    do

    mkdir $dirname/{bin,etc,include,lib,sbin,share,src}

    ln -s share/{man,doc,info} $dirname

    mkdir $dirname/share/{dict,doc,info,locale,man}

    mkdir $dirname/share/{nls,misc,terminfo,zoneinfo}

    mkdir $dirname/share/man/man{1,2,3,4,5,6,7,8}

done

mkdir /var/{lock,log,mail,run,spool}

mkdir -p /var/{tmp,opt,cache,lib/misc,local}

mkdir /opt/{bin,doc,include,info}

mkdir -p /opt/{lib,man/man{1,2,3,4,5,6,7,8}}

 

The permissions have been set to 755:

-          read write execute for the user

-          read execute for the group

-          read execute for the others

 

Since we want some specific permission for the /root, the /var and the /var/temp directories we run these commands:

chmod 0750 /root

chmod 1777 /tmp /var/tmp

 

Now nobody can enter /root except from the user and his group, and everybody can access /tmp and /var/tmp but files created by other users can’t be deleted.

 

2-     Mounting proc and devpts

 

Some programs require the proc and devpts file systems to be mounted to run properly.

 

Mounting proc should generate some errors since the system is not complete and some files are missing but it will be mounted.

The kernel uses proc to provide status information about the system status; we mount it on /proc by running this command:

 

mount proc /proc -t proc

 

devpts is a file system that allow implementing PTYs pseudo terminal. We need to have compiled our host system’s kernel with the devpts file system support otherwise it will generate an error. It should be mounted on /dev/pts by running:

 

mount devpts /dev/pts -t devpts

3-     Creating symlinks

 

We need to create some symlinks (symbolic links, shortcuts) to programs that don’t exist yet to be able to run some programs that require them. The symlinks will of course be replaced by the real files after all the installation steps are completed.

 

ln -s /tools/bin/{bash,cat,pwd,stty} /bin

ln -s /tools/bin/perl /usr/bin

ln -s /tools/lib/libgcc_s.so.1 /usr/lib

ln -s bash /bin/sh

 

 

4-     Creating the passwd and group files

 

We have to create a password and a group file containing data about the root user so as we can login as root.

 

We create a password file in /etc/passwd:

 

cat > /etc/passwd << "EOF"

root:x:0:0:root:/root:/bin/bash

EOF

 

We create a group file in /etc/group:

 

cat > /etc/group << "EOF"

root:x:0:

bin:x:1:

sys:x:2:

kmem:x:3:

tty:x:4:

tape:x:5:

daemon:x:6:

floppy:x:7:

disk:x:8:

lp:x:9:

dialout:x:10:

audio:x:11:

EOF

 

 

We can now re-login to the chroot environment using the +h parameter in order to use our newly compiled binaries for the rest of the installation. We will get rid of the "I have no name!" prompt:

 

5-     Creating devices (Makedev-1.7)

 

MAKEDEV is a program that will create the devices in /dev used to interface with drivers in the kernel:

 

bzcat MAKEDEV-1.7.bz2 > /dev/MAKEDEV

chmod 754 /dev/MAKEDEV

 

Run the script to create the device files:

cd /dev

./MAKEDEV -v generic-nopty

 

We used –v to run the script in verbose mode and generic-nopty to create a generic selection of commonly used device special files.

Some zzz devices have not been created, we run again MAKEDEV instructing it to create these devices:

 

./MAKEDEV -v zzz

6-     Installing kernel headers

 

Kernel refers to the core OS. It is an abstraction layer (HAL) between hardware and software, which provides an environment for running software programs; it is the first piece of software loaded by to boot loader. It initializes the hardware using simplified functions and makes it available to the software. It takes care of the memory, process and Imput/Output (I/O) management.

 

The header files define structures and constants that are needed for building most standard programs. The header files are also needed for rebuilding the kernel.

 

As some packages need the kernel header files, we're going install the headers that are packed in the kernel archive.

 

The  kernel source tree is not always clean, therefore we use the following command to prepare the header:

 

make mrproper

 

We create the include/linux/version.h file:

 

make include/linux/version.h

 

We create the platform-specific include/asm symlink:

make symlinks

 

We copy the platform specific-header files:

 

cp -HR include/asm /usr/include

cp -R include/asm-generic /usr/include

 

We copy the cross-platform kernel header files:

 

cp -R include/linux /usr/include

 

The autoconf.h header file is normally created when we configure the kernel. Since we have not configured it yet and since some kernel header files use it, we need to create this autoconf.h header file:

 

touch /usr/include/linux/autoconf.h


B- Installing the packages

 

1-     Packages

 

We can now install the rest of the packages; we will install the list of packages below following its order since some tools have dependencies with previously installed tools.

 

Most packages have specific installation options, processes and configuration files; to have more details about it, you can check the Linux From Scratch documentation.

 

 


Man-pages-1.60

Glibc-2.3.2

Re-adjusting the toolchain

Binutils-2.14

GCC-3.3.1

Coreutils-5.0

Zlib-1.1.4

Lfs-Utils-0.3

Findutils-4.1.20

Gawk-3.1.3

Ncurses-5.3

Vim-6.2

M4-1.4

Bison-1.875

Less-381

Groff-1.19

Sed-4.0.7

Flex-2.5.4a

Gettext-0.12.1

Net-tools-1.60

Inetutils-1.4.2

Perl-5.8.0

Texinfo-4.6

Autoconf-2.57

Automake-1.7.6

Bash-2.05b

File-4.04

Libtool-1.5

Bzip2-1.0.2

Diffutils-2.8.1

Ed-0.2

Kbd-1.08

E2fsprogs-1.34

Grep-2.5.1

Grub-0.93

Gzip-1.3.5

Man-1.5m2

Make-3.80

Modutils-2.4.25

Patch-2.5.4

Procinfo-18

Procps-3.1.11

Psmisc-21.3

Shadow-4.0.3

Sysklogd-1.4.1

Sysvinit-2.85

Tar-1.13.25

Util-linux-2.12

GCC-2.95.3


 

These are all the packages that Linux From Scratch suggests to install. Since we want to have more networking possibilities we will install packages such as apache, proftpd or dhcpd.

 

We won’t describe the packages in this section but in a separate one. These packages are not at the root system level but serve directly the end user by providing network services. They are common software widely used therefore we will describe each one in particular.

If we will not get into their installation now since the goal of the section is to summarize LFS method, it is important to note that they should be installed at this stage of the LFS process in the chroot environment.

 

Once all the packages have successfully been installed, we do not need the /tools directory to be used by programs anymore so we can modify the chroot environment so as it does not specifies it. Here is our new chroot:

 

chroot $LFS /usr/bin/env -i \

    HOME=/root TERM=$TERM PS1='\u:\w\$ ' \

    PATH=/bin:/usr/bin:/sbin:/usr/sbin \

    /bin/bash –login

 

 


2- Installing LFS-bootscipts-1.2

 

LFS-bootscripts

 

“The LFS-Bootscripts package contains SysV init style shell scripts. These scripts do various tasks such as check file system integrity during boot, load keymaps, set up networks and halt processes at shutdown.” http://linuxfromscratch.org

 

List of the scripts that are installed:


 


Checkfs

Cleanfs

Functions

Halt

Ifdown

Ifup

Loadkeys

Localnet

Mountfs

Mountproc

Network

Rc

Reboot

Sendsignals

Setclock

Swap

Sysklogd

Template


 


To install the scripts and set root ownership:

 

cp -a rc.d sysconfig /etc

chown -R root:root /etc/rc.d /etc/sysconfig

 

 

Before configuring boot scripts, we can set the root password:

 

passwd root

 


C- Installing the boot scripts

 

1-     The booting process

 

When a Linux system is booted it passes through several distinct stages, known as runlevels, before the system has completed booting and is usable. The same process occurs when a Linux system is shut down it passes through another set of runlevels before the system is ready to be turned off.

 

A runlevel can be seen as a system state; it could be compared with the several modes into which Microsoft Windows is able to boot: normal, safe-mode without network, safemode with networking and command prompt only. Each runlevel is associated with a set of services that are initialised or stopped when the system enters the runlevel. These services launched by initialisation scripts located in /etc. There is one directory for each runlevel: rc0.d, rc1.d … rc6.d.

 

There are generally eight runlevels used by most Linux distributions, though some may vary this organisation slightly.

 

 

Runlevel

System State

0

Halt the system 

1

Single user mode 

2

Basic multi user mode 

3

 Multi user mode 

5

Multi user mode with GUI 

6

Reboot the system 

S, s 

Single user mode 

 

 

Many desktop Linux systems by default reach the runlevel 5 and offer a graphical interface to the user. Most server systems by default boot into runlevel 3 and administrator use a text-mode login prompt. Runlevels 1and 2 are rarely used and usually for debugging purposes. Runlevels S and s are not intended for direct use by users and are used to prepare the system for Single User mode.

 

The advantage Linux runlevels have over Windows’ boot modes is that Linux runlevels can be changed in command line using the init tool. Part of the shutdown process involves calling init with the corresponding runlevel (0 or 6) to stop all running processes.

 

 

Just to get used to the runlevel concept I have been testing some commands that can be used with runlevels:

 

If you type runlevel, the utility prints out the runlevel you were previously in followed by the current runlevel.

 

 

The init command can be used to control the init process; you need to be logged in as root to be able to use it.

 

Since each runlevel is associated with a set of applications, switching from runlevel 5 to 3 stops the graphical interface and the applications that are associated to it. The graphical mode can be restarted by switching back to runlevel 5common reason to switch runlevels is to restart certain applications such as XFree86. Switching from runlevel 5 to runlevel 3 will stop XFree86 and its associated programs. XFree86 can then be restarted cleanly by switching back to runlevel 5. To do this type the following commands

init 3

init 5

Concerning the symbolic links in the rcX.d directories, where X is the runlevel, some begin with a K, the others begin with an S, and all of them have two numbers following the initial letter. The K means to stop (kill) a service, and the S means to start a service. The purpose of the number is to control the order in which scripts are executed within each runlevel. The scripts are executed in ascending numerical order.

 

The scripts are in fact in /etc/rc.d/init.d; the symlinks just point to them. The scripts can be called with different parameters like start, stop, restart, reload, status. If a link contains a K, the script is run with the stop argument. If it contains an S the script is run with the start argument.

 

This is what occurs for each parameter:

 

Start

service is started.

Stop

service is stopped.

Restart

service is stopped and then started again.

Reload

Update of the service configuration. This is used after the configuration file of a service was modified, when the service doesn't need to be restarted.

Status

Tells if the service is running and with which PIDs.

 

To add a service to be started at a certain runlevel, we first create a startup script for the service and place it in the directory /etc/rc.d . To associate the script with a runlevel we create a symbolic link in the directory for the runlevel corresponding. The filename of this symbolic link should be prefixed with SXX where XX is a number.

 


For example, we could do:

 

cp apache /etc/rc.d/

ln -s /etc/rc.d/apache /etc/rc3.d/S99apache

 

The next time runlevel 3 is entered, apache will be started.  I have been using this command to start applications such as apache or dhcpd for which the installation was not described in the LFS guide.

 

You can also decide on the default runlevel into which Linux boots by specifying it at boot time. If your system uses LILO, add the runlevel to the boot command this way:

 

LILO: linux 5

 

 

2-     Configuring the scripts

 

a-    Configuring the setclock script

 

To set the right time for the distribution, we use the setclock script to get the time from the BIOS clock and convert it to the local time if the hardware clock is not set to GMT.

 

We create a clock file in /etc/sysconfig/ :

 

cat > /etc/sysconfig/clock << "EOF"

# Begin /etc/sysconfig/clock

UTC=1

# End /etc/sysconfig/clock

EOF

 

We can change the value of the UTC variable 0 if the hardware clock is not set to GMT time.

In that case a hint explains how to deal with time zones at http://www.linuxfromscratch.org/hints/downloads/files/time.txt .

 

 

b-    Configuring the localnet script

 

The system's hostname is configured in the localnet script. This needs to be configured in the /etc/sysconfig/network.

We create the /etc/sysconfig/network file and add the following line:

 

echo "HOSTNAME=computer_name" > /etc/sysconfig/network

 

c-     Creating the /etc/hosts file

 

To configure the network card, you can specify the IP-address, the Fully Qualified Domain Name (FQDN) and aliases in the /etc/hosts file:

 

<IP address> myhost.mydomain.org aliases

The IP-address should be in the private network IP-address range:

 

Class

Networks

A

10.0.0.0

B

172.16.0.0 through 172.31.0.0

C

192.168.0.0 through 192.168.255.0

 

 


It is necessary for using some programs to configure a FQDN, even if you are not using a network card. You should then configure the /etc/host file like this:

 

cat > /etc/hosts << "EOF"

# Begin /etc/hosts (no network card version)

127.0.0.1 <value of HOSTNAME>.mydomain.com <value of HOSTNAME> localhost

# End /etc/hosts (no network card version)

EOF

 

To use with a network card configure the  /etc/hosts file like this:

 

cat > /etc/hosts << "EOF"

# Begin /etc/hosts (network card version)

127.0.0.1 localhost.localdomain localhost

Aaa.bbb.ccc.ddd <value of HOSTNAME>.mydomain.org <value of HOSTNAME>

# End /etc/hosts (network card version)

EOF

 

d-    Configuring the network script

 

If you don't have any network cards, you must remove the network symlinks from all the runlevel directories (/etc/rc.d/rc*.d)

 

For the default gateway, we configure /etc/sysconfig/network file with this:

 

cat >> /etc/sysconfig/network << "EOF"

GATEWAY=aaa.bbb.ccc.ddd

GATEWAY_IF=ethX

EOF

 

The GATEWAY_IF must be configure with the corresponding network interface

 

Network interface configuration files

 

You must specify which interfaces should be brought up and down by the network script in the /etc/sysconfig/network-devices directory. Each interface as an ifconfig file with its name as an extension, ifconfig.eth0 for instance.

 

To create an ifconfig file you can use the following command:

 

cat > /etc/sysconfig/network-devices/ifconfig.ethX << "EOF"

ONBOOT=yes

IP=aaa.bbb.ccc.ddd

NETMASK=255.255.255.0

BROADCAST=aaa.bbb.ccc.255

EOF

 

You can set the ONBOOT variable to yes to bring up the interface during the booting of the system. If it set to something else, the interface will not be brought up.

 

III- LFS: Getting the distribution ready for booting

 

A- Fstab and the kernel

 

In order to make our distribution bootable, we will create an fstab file, build the kernel and install a bootloader.

 

 

1-     Creating the fstab file

 

We use the fstab file in the /etc directory to define which partitions are mounted by default, which file systems must be checked and in which order. The fstab file provides this information to some programs that require it. We create the file like this:

 

cat > /etc/fstab << "EOF"

# Begin /etc/fstab

 

# filesystem  mount-point  fs-type  options         dump  fsck-order

 

/dev/xxx      /                      zzz                  defaults                    1     1

/dev/yyy      swap             swap             pri=1                          0     0

Proc               /proc             proc               defaults                    0     0

Devpts          /dev/pts      devpts          gid=4,mode=620   0     0

 

# End /etc/fstab

EOF

 

Xxx      should be replaced by a partition name (had1 for instance)

Yyy     should be replaced by a partition name (had2 for instance)

Zzz      should be replaced by a partition type (ext2 for instance)

 

For more information about fstab configuration and parameters see man pages.

 

 

2-     Installing the kernel

 

The kernel source tree is not always clean; therefore we clean it with mrproper before configuring the kernel.

 

make mrproper

make menuconfig

 

We now verify dependencies and create the dependencies information files, compile the kernel image and compile the drivers:

make CC=/opt/gcc-2.95.3/bin/gcc dep

make CC=/opt/gcc-2.95.3/bin/gcc bzImage

make CC=/opt/gcc-2.95.3/bin/gcc modules

 

In order to use modules, we must create a module.conf file in /etc .

We can now compile them:

 

make CC=/opt/gcc-2.95.3/bin/gcc modules_install

 

A last thing to do is to build the kernel’s manual pages and copy them in the man 9 directory:

 

make mandocs

cp -a Documentation/man /usr/share/man/man9

 

We have finished the compilation of the kernel but we need to move two file that are still in the source tree to the / boot directory.

The first file is the kernel that we must copy to the /boot directory, the second one is system.map that we also copy to the /boot directory.

 

cp System.map /boot

 

 


B- The boot loader

 

1-     How does it work?

 

At this time we have finished building our distribution, we must now make it bootable. We could use either Lilo either Grub to achieve that task. Since Grub is often preferred to Lilo and since the Linux From Scratch guide explains the procedure with Grub, we will stick to that choice.

 

In case of a problem occurring with this process we create a Grub boot disk to prevent us from taking any risks.

 

dd if=/boot/grub/stage1 of=/dev/fd0 bs=512 count=1

dd if=/boot/grub/stage2 of=/dev/fd0 bs=512 seek=1

 

In contrast with Lilo, Grub has a shell that can be ran typing “grub”. The notation for disks and partitions is different from the default system naming rules:

 

-          hard drives are designated by a n numbered name from hd0 to hdN

-          partitions are designated by a m number 0 one to M

 

To designate partition 3 on disk 2 we would use the following notation: (hd1,2)

 

CD-ROM are not considered as hard drive, so they are not included in the drives counting of Grub.

 


2-     Configuration

 

To tell grub where it can find its stages{1,2} files we use the following command:

Root (hdn,m)

 

To install grub in the boot sector of the LFS partition:

Setup(hdn,m)

To install grub in the Master Boor Record (MBR) of had:

Setup (hd0)

 

Grub will now print that it has found its files in /boot/grub. We can then leave Grub using the command “quit”

 

We can now define Grub’s boot menu, here is an example of a menu we could create, including an entry for our host distribution and one for a dual boot with windows:

 

cat > /boot/grub/menu.lst << "EOF"

# Begin /boot/grub/menu.lst

 

# By default boot the first menu entry.

default 0

 

# Allow 30 seconds before booting the default.

timeout 30

 

# Use prettier colors.

color green/black light-green/black

 

# The first entry is for LFS.

title LFS 5.0

root (hd0,3)

kernel /boot/lfskernel root=/dev/hda4 ro

 

# Second entry for the host distribution

title Fedora2

root (hd0,2)

kernel /boot/kernel-2.4.20 root=/dev/hda3 ro

initrd /boot/initrd-2.4.20

 

# Third entry for windows

title Windows

rootnoverify (hd0,0)

chainloader +1

EOF


Logging out and finishing the distribution.

 

We have achieved the system building process of the distribution; we can reboot and boot the distribution to test it.

 

Before that, let us unmout some devices and exit the environment:

 

umount /proc

umount /dev/pts

logout

umount $LFS

/sbin/shutdown -r now

 

The mini-distribution is however not finished yet. We still need to make it boot in a ramdisk and to make a bootable CD-ROM. Before that, in the next section, we will deal with the applications that we talked about during the package installation such as apache, bind or apt-get. These packages that are not treated in the Linux From Scratch guide, are key elements of our emergency distribution.

 



Articles de la même catégorie

 Pages : Top


136 Visites
0 Commentaires
"Thin Client/ Windows Terminal Server" or lightening of data-processing maintenance
[30 mn de lecture - paru le 11/22/2004 12:11:30 PM - Public : Débutant]

En savoir plus


66 Visites
0 Commentaires
Newsletters management
[15 mn de lecture - paru le 11/22/2004 5:30:18 AM - Public : Débutant]

En savoir plus


55 Visites
0 Commentaires
The Technology for the communities
[20 mn de lecture - paru le 11/21/2004 5:59:47 PM - Public : Débutant]

En savoir plus

   Tous les Articles


SUPINFO Training Center peut vous proposer une formation système ...

   Devenez Ingénieur Système Microsoft en 35 jours avec SUPINFO Training Center
   Devenez Administrateur Système Microsoft avec SUPINFO Training Center


Powered by Campus-Booster Technology
Conditions d'utilisation & Copyright | Respect de la vie privée
© Copyright 1965-2006 Supinfo Paris, Paris Academy of Computer Science
Supinfo, Ecole Supérieure d'Informatique et Paris Academy Of Computer Science are trade marks.
23, rue de Château LANDON - 75010 PARIS - Phone : +33 (0) 153359 700 Fax : +33 (0) 153359 701

Web site autided by :