Home » Byol Malaysia

Howto : Build a Minimal Linux System from Source Code

2 January 2008 26 views One Comment

http://users.rsise.anu.edu.au/~okeefe/p2b/buildMin/buildMin.html#toc14

BYO 1.0 Text Version
(c) 2000, 2001 Jonathan Thorpe
Email: jon@byolinux.org

This document/ contains precise instructions of how to Build Your Own personalized distribution. A HTML and friendly HTML as well as other BYO content may be found at: http://www.byolinux.org

Contents:

  1. Packages required for BYO
  2. Making space
  3. Writing Lilo.conf
  4. Folders and files
  5. SysVinit
  6. Bash
  7. Compiling Statically
  8. Glibc
  9. GCC 2.95.2
  10. A few necessities
  11. Dynamic
  12. scripts

1)BYO : PACKAGES

In order for you to start your own OS, you will have to download the Required Packages for a basic . You will also require the Statically Compiled Programs for a little later on when we start putting our OS together.The Optional Packages will provide extra functionality to your . I suggest that once you have your basic working, decide what sort of functionality is required for your and then download the optional packages. It is a common occurrence that some of the links are broken. If so, visit www.freshmeat. and look for a new download location,but make sure you are downloading the same, or if required, download slightly later versions of the described.

  • autoconf 2.13 at ftp..org//autoconf
  • automake 1.4 at ftp..org//automake
  • bash 2.04 at ftp..org//bash
  • bin86 0.15.4 at http://www.cix.co.uk/~mayday/bin86-0.15.4.tar.gz
  • binutils 2.10 at ftp..org//binutils
  • bison 1.28 at ftp..org//bison
  • bzip2 1.0.1 at ftp://sourceware.cygnus.com/pub/bzip2/v100
  • diffutils 2.7 at ftp..org//diffutils
  • e2fsprogs 1.18 at ftp.metalab.unc.edu/pub///filesystems/ext2
  • fileutils 4.0 at ftp..org//fileutils
  • findutils 4.1.5 at ftp://alpha..org/
  • flex 2.5.4a at ftp..org/non-/flex
  • gcc 2.95.2 at ftp..org//gcc
  • glibc 2.1.3 at ftp..com//-6.2/i386//RPMS
  • glibc-devel 2.1.3 at ftp..com//-6.2/i386//RPMS
  • grep 2.4.2 at ftp..org//grep
  • groff 1.16.1 at ftp..org//groff
  • gzip 1.2.4a at ftp..org//gzip
  • 2.4.0 at www..org [If experiencing problems, use 2.2.18]
  • ld.so 1.9.9 at ftp.metalab.unc.edu/pub//GCC
  • less 358 at ftp..org//less
  • lilo 21.6.1 at ftp.metalab.unc.edu/pub////lilo
  • m4 1.4 at ftp..org//m4
  • make 3.79.1 at ftp..org//make
  • man 1.5h1 at ftp.win.tue.nl/pub/-local/utils/man
  • mawk 1.3.3 at ftp.whidbey./pub/brennan
  • modutils 2.3.17 at ftp..org/pub//utils//modutils/v2.3
  • ncurses 5.1 at ftp..org//ncurses
  • patch 2.5.4 at ftp..org//patch
  • perl 5.6.0 at www.perl.com/pub/language/info/.htmll#stable
  • readline 4.1 at ftp..org//readline
  • sed 3.02 at ftp..org//sed
  • sh-utils 2.0 at ftp..org//sh-utils
  • shadow-20000902 at ftp://piast.t19.ds.pwr.wroc.pl/pub//shadow/
  • sysvinit 2.78 at ftp.metalab.unc.edu/pub///daemons/init
  • tar 1.13 at ftp..org//tar
  • termcap 1.3 at ftp..org//termcap
  • texinfo 4.0 at ftp..org//texinfo
  • textutils 2.0 at ftp..org//textutils
  • util- 2.10 at http://freshmeat./projects/util-/download/util--2.10r.tar.gz
  • vim 5.7 rt and src at ftp.us.vim.org/pub/vim/

OPTIONAL PACKAGES:

  • 1.3.12 at www..org/dist
  • berkeley db library 3.1.17 at www.sleepycat.com/download.html
  • ed 0.2 at ftp..org//ed
  • ipchains 1.3.9 at http://netfilter.filewatcher.org/ipchains
  • jpegsrc v6b at ftp.uu./graphics/jpeg
  • and qt at ftp://ftp..org/pub//stable/2.0.1/distribution/tar/generic/src/
  • libtiff 3.5.5 at ftp.onshore.com/pub/libtiff
  • mesalib 3.3 at ftp.mesa3d.org/pub/sourceforge/mesa3d
  • openssl 0.9.6 at ftp.openssl.org/
  • netkit-combo 0.17 at ftp.metalab.unc.edu/pub////netkit
  • -tools 1.57 at www.tazenda.demon.co.uk/phil/-tools
  • ppp 2.3.11 at ftp://cs.anu.edu.au/pub//ppp
  • procps 2.0.7 at ftp://people..com/johnsonm/procps
  • 3.0.6 at ftp..org/pub//dist/-3.0.
  • sysklogd 1.4 at ftp.metalab.unc.edu/pub///daemons
  • texk and texklib at ftp.tug.org/tex
  • X401src-1.tgz (2 + 3 also) at ftp.xfree86.org/pub/XFree86/4.0.1/
  • zlib 1.1.3 at ftp.info-zip.org/pub/infozip/zlib

STATICALLY COMPILED PROGRAMS:

These programs have been statically compiled as on some systems, the normal method of compiling may not work correctly.

M4 at http://www.byolinux.org/files/m4
SED at http://www.byolinux.org/files/sed

2)BYO : MAKING SPACE

In order to complete this project, you could probably get away with 500 megabytes for a minimum project. Obviously the more space, the more goodies. Since you will already be running to create this project, you can share the existing swap partition. If you do not currently have a swap but want one, keep reading, it’s creation is explained later in this chapter. Let’s say you are all filled up with no space left to partition. That’s ok because there is a wonderful, free utitlity called fips that will non-destructively repartition your hard drive. Remember to defragment your partition first if you plan to use fips there. I am not going to provide directions for this since some pretty good ones already come with it. It’s really not that hard to figure out anyways.

Now, assuming you have some free, unpartitioned hard drive space, let’s get down to . Load up your origanal linux1 distribution. In this example, we will assume you are using an IDE type hard drive (as opposed to ) and it is the only hard drive on your .

At the prompt, type fdisk /dev/hda The ‘a’ in hda means ide0 - master. If it was a ‘b’, that would be ide0 - slave. ‘c’ is ide1 - master. Etc, etc.. That’s the way it works in .

Now when you see hda1 later, that just means the partition number 1 on the drive located on ide0 - master. See how easy that was? Let’s take a look at my screen and explain whats going on a little

bit inside this program

————————————-

[@linuxprog /]#
[@linuxprog /]# fdisk /dev/hda
The number of cylinders for this disk is set to 1216. There is nothing wrong with that, but this is larger than 1024,

1) that runs at time (e.g., LILO)

2) booting and partitioning from other OSs

(e.g., FDISK, OS/2 FDISK)

(m for help): _

————————————-

That is what the screen should basically look like after you typed in the from above. It is slightly misleading regarding the cylinder 1023 limitation because with newer versions of the package
lilo, this is no longer a concern. You can safely ignore this if you are running a newer distribution, but it may be a concern now while we are creating this if you are using an older version. Basically,
it just means that everything in the / directory likes to be below cylinder 1023 on older distributions. If you fall into this category, you are probably going to want to limit your partition
to below cylinder 1023 (we’ll get to making them in a minute). Now, to see what are on you hard drive, type p.You will get a screen that looks something like this.

————————————-

[@linuxprog /]#

[@linuxprog /]# fdisk /dev/hda

The number of cylinders for this disk is set to 1216.

There is nothing wrong with that, but this is larger than 1024,

1) that runs at time (e.g., LILO)

2) booting and partitioning from other OSs

(e.g., FDISK, OS/2 FDISK)

(m for help): p

Disk /dev/hda: 255 heads, 63 sections, 1216 cylinders

Units = cylinders of 16065 * 512 bytes

Device Start End Id

/dev/hda1 * 1 259 2072353 o Win95 FAT32

/dev/hda2 259 516 2072385 83

/dev/hda3 517 700 1477980 83

/dev/hda4 701 708 64260 82 swap

(m for help):_

————————————-

If you noticed, partition 1 on my drive is , partition 2 is ,

partition 3 is also , and partition 4 is the swap. One nice

thing, these are all primary .

allows 4 primary where /win only allows

1. One partition is for the new distro we are making and the

other is my other distro that’s used to create the new distro

Ok, let’s get back to that fdisk we started running a few paragraphs ago

To begin creating , type n at the fdisk prompt. It will ask you

whether this will be a primary partition. Choose p for primary.

Next it will ask you the partition number. Make one partition for

and one for swap (if you don’t already have a swap partition from your

existing distribution).

If by some chance you need/want to remove a partition, type d and then

enter the partition number. If you really mess this up at anytime, type

q at the prompt to quit fdisk without saving. This is serious stuff

here so make sure you get it correct (not that it will damage the

but you could wipe out the contents of your hard drive if

you mess up).

Now type p again to view what you have done. Nothing is saved yet so

don’t worry. How’s it looking?

Now, if you notice in the illustration above, my swap partition

has a different id number. It is 82 as opposed to 83(which yours will

say if you just created this partition). At the prompt, type t to

toggle the number. It will ask you the partition number. Enter whatever

partition it happens to be. When it asks for the code, simply type 82

and select enter. Type p at the prompt to confirm all looks well.

If all is looking well, the final thing to do is type w to write the

partition(s) as well as quit the fdisk program. The fdisk program may

recommend you the , if it does, do it.

Let’s make the filesystems on these new . This is the equivalent

of formatting the drive if it were a / partition. If you have

created your own swap partition because it didn’t exist on your existing

distro, you will need to type mkswap -c /dev/hda4 at the prompt to

create the swap filesystem. You substitute the proper hda number for the

correct partition. For the partition, type mke2fs /dev/hda2. Again,

you substitute the proper hda number.

When you invoke the mke2fs , the hard drive will churn for a few

seconds and some fancy numbers will come up on the screen. When it returns

you to the prompt, congratulations, you have a working filesystem on

your hard drive ready to accept directories and files.

Now let’s fish around your new linux2 filesystem to be sure it works

(not that there is much to see). Before we are able to mount it, you’ll

need to create a directory in your /mnt directory on linux1 for this

partition. I created one called linux2 and you should call yours the

same to help keep us together for the rest of the project. We’ll be

using this directory quite a bit so go ahead and make it by typing

mkdir /mnt/linux2.

Now, mount the filesystem you just created like you would any

other device on your . For example, type mount /dev/hda2

/mnt/linux2 where /mnt/linux2 is the directory you just created and

/dev/hda2 a partition you created earlier (again, substitute

the proper hda number for your setup). After it is mounted, type

cd /mnt/linux2 to go there.

Type ls to have a look around. The only thing you might notice

(maybe not) is a directory in there called ‘lost+found’. We don’t

really need this directory so type rmdir /mnt/linux2/lost+found to

get rid of it if you like. Now the filesystem is empty.

If you have made it this far, I promise that you have the necessary

skills to complete this project. This chapter was truly the

most difficult part.

3)BYO : Configuring LiLo Loader

Hopefully, you are familiar with how to edit text files with vi

because that’s what I use. It’s not difficult to use but it’s a

little strange to get used to. If you are going to be using

another editor, that’s fine too. If you want to try vi, type man

vi at your prompt to read how to use it.

We need to update the /etc/lilo.conf file on your running linux1

. Type vi /etc/lilo.conf at the prompt to begin editting

the file. Here is what mine looks like.

————————————-

=/dev/hda

map=//map

=//.b

prompt

timeout=50

default=

image=//vmlinuz

label=

read-only [-=*EXISTING DISTRO*=-]

=/dev/hda3

other=/dev/hda1

label=win [-=**=-]

image=//vmlinuz

label=linux2

read-only [-=*YOUR BYO DISTRO*=-]

/dev/hda2

————————————-

Notice the part that I added is circled. If your new ’s partition is not on /dev/hda2, change the wording to where it is located. The ‘label=linux2′ means you will type linux2 at the prompt during bootup. vmlinuz is the name of my . It’s also the name of my for my linux1 distribution. This is very important that these names match (at least at first), otherwise lilo (the bootloader program) won’t work. Basically, just use the same name for your new as you are using now in your existing linux1 setup. You will be copying that over in a later chapter, but don’t worry, we’ll be making a new soon anyways.

Now, save and exit vi by typing : followed by wq followed by ‘enter’. Type lilo -v at the prompt to update the loader. Lilo should not report any errors, it should just say that it added the filesystems. It’s really as simple as that. If you have ever made your own before (we’ll discuss that in later chapters), it’s one of the exact same steps.

4)BYO : Folders and Files

Now, let’s populate our new filesystem with a few folders and files. Make sure your linux2 partition is still mounted(however, you are still in linux1). If you haven’t rebooted, it will still be. Goto that directory by typing cd /mnt/linux2

Type the following (be careful of spelling, and again, make sure you are mounted):

————————————————————-

mkdir bin etc home lib mnt proc sbin tmp usr var

————————————————————-

Next, go into your newly made /usr directory by typing cd /mnt/linux2/usr

Make the following directories inside this directory by typing:

————————————————————-

mkdir bin include man sbin share src

————————————————————-

Next, go into your newly made /usr/man directory by typing:

————————————————————-

cd /mnt/linux2/usr/man

————————————————————-

Make the following directories inside this directory by typing:

————————————————————-

mkdir man1 man2 man3 man4 man5 man6 man7 man8

————————————————————-

Next, go into your newly made /usr/share directory by typing

————————————————————-

cd /mnt/linux2/usr/share

————————————————————-

Make the following directories inside this directory by typing:

————————————————————-

mkdir aclocal autoconf automake

————————————————————-

Next, type the following to create another directory:

————————————————————-

mkdir /mnt/linux2/var/run

————————————————————-

Now, the only directory we are missing is the /dev directory. The easiest way to make this as well as populate it is to copy it from your existing distribution. We could make it from scratch with the mknod , but it will give you the same as copying it plus it takes a while. So, at the prompt, type cp -dpR /dev /mnt/linux2. The -dpR will keep order in this directory, preserve permissions, and not attempt to read the files while copying (this has a nasty habit of locking up the - and yes, that is a space after /dev). Feel free to prune out this directory by deleting un-needed devices if you know what these devices are.

Now, let’s copy the from your existing linux1 distribution to the new linux2 distribution. It’s normally located in the / directory and that is where you should put it in the new distribution to maintain file hierarchy standards. Type cp //vmlinuz /mnt/linux2/. You substitute whatever the name of your is for vmlinuz - Again, don’t worry, we will be making our own in a chapter.

Next, we need to copy the /etc/passwd and the /etc/group file from your existing to the new . These are your password and group belonging files. But, BEFORE we can do that, we need to determine weather or not your is using shadow or not. If it is, we need to temporarily disable it for the copy. The easiest way to check this is to open up your /etc/passwd file with vi. Here’s what mine looks like (and yes, I changed the password for this purpose!):

————————————————————-

:$1$62$23sdfl121$34023gdfg$

————————————————————-

Now go ahead and copy them over to /mnt/linux2/etc

Now, let’s re-enable your shadow by typing the following

————————————————————-

pwconv

grpconv

————————————————————-

Now that these files are copied over, edit them both and get rid of everything except for the first line that contains the stuff for . Go ahead and save.

5) BYO : SysVinit

Next, we are going to and SysVinit. The init program is the very first file that is loaded into after

the boots into . It also always has process id number 1. This would be a good place for us to start.

Your linux2 should still be mounted.

Go ahead and unzip sysvinit by typing gzip -d filename.tar.gz You substitute whatever the filename is. Next, untar it by

typing tar -xvf filename.tar Again, substitute the filename, this time without the .gz extension but with the .tar

extension.

Now, go into the /src directory of this package. Find a file in there called Makefile - we need to edit this so fire up vi.

On the very first line, add the following to the text file: =/mnt/linux2

Next, go to the last 4 lines of this file. Precede every /dev by $()

—————————————————————

@if [! -p $()/dev/initctl ]; then

echo “Creating $()/dev/initctl”

rm -f $()/dev/initctl;

mknod -m 600 $()/dev/initctl p; fi

—————————————————————

It may be hard to see, but there is a space before every $. Save and exit vi. Make sure your linux2 filesystem is mounted.

Type make LDFLAGS=-static followed by make

will complain about a missing /usr/share/man directory, this is normal. The directory doesn’t exist yet. Actually, it

will be a symlink to another directory later. Don’t worry, we’ll be re-installing this package again dynamically later

and the error will be taken care of.

You just compiled and installed your first package into your new , congratulations!

Next, we need to write a quick, temporary, /mnt/linux2/etc/inittab file. Fire up vi again and copy what I have below.

—————————————————————

id:S:initdefault:

~~:S:wait:/sbin/sulogin

z6:6:wait:/sbin/sulogin

1:2345:respawn:/sbin/sulogin

—————————————————————

Go ahead and save that.

5) BYO : Bash

The last package we’ll be installing before we can give this sucker a for the first time is ‘bash’. This is what is

known as a shell. It’s kind of like .com

There are many shells available for , but this is the standard. It’s also refered to as ’sh’ sometimes.

Unpack the archive just like you did in the last chapter with gzip and tar. Go into the bash directory that was just

created and type

———————————————-

./ –enable-static-link

———————————————-

Now type

———————————————-

make

———————————————-

Copy the file bash to /mnt/linux2/bin

Now, we are ready for a test run into the new . the . At the lilo prompt, type linux2. If all

goes well, will up and ask you for your password. Type in whatever your password is from the you copied

the passwd file from. You should see a bash prompt. If you are there, congratulations! If not, you better re-read and make

sure all was done correctly. The only thing you are able to do now is issue a -f to the back

to linux1.

6) BYO : Compiling Statically

Make sure you are in your normal, linux1 and linux2 is mounted. All these files will be made here and copied to the

new .

This is going to be a long chapter. There are so many different distributions out there with so many different libraries

and so many different compilers, it’s taken me alot of tinkering in order to come up with something that everybody should

be able to use.

Two of the packages needed, m4 and sed, will not currently statically. When you get to these packages, just

the links and download them from me already prebuilt. Alot of code needed to be re-written in order for them to

statically so just get them from me. They will dynamically later just fine. Hopefully, there authors will re-write

these packages in the . If you’re downloading these in MS , make sure they are saved or renamed in all

lowercase letters if necessary.

We talked a bit about static vs. dynamic compiling in ‘Getting started’, let’s just hit the fine points for those that

don’t understand the difference. (as well as ) can make use of what’s called dynamic libraries. These are

also known as libraries. In , they are usually located in the /lib directory. In , these are the .dll

files in the directory. Without dynamic libraries, the library would have to be compiled into the program itself.

This can be done (and we will at first), but, the disadvantages are the program is bigger and takes up more . Alot

of programs require the exact same library, so, why load that library more than one time? Get the point? It would be a

waste of resources. Now, since we don’t have a library on our new to start with, we have to make these programs

statically just to get the to . We already did this twice in ‘SysVinit’ and ‘Bash’.

Once we are all done installing these 17 packages, we will the libraries and compiler, THEN recompile the packages

dynamically. This will also put the man files (help files), etc.. in there correct folders. Basically, I’m going to present

the proper way to these packages statically now.

If your not sure if you compiled your binary correctly, go to the directory of its location and type ldd filename and it

will tell you if it’s static or requires libraries.

Also, if your wondering, these 17 ‘required’ packages are the packages that will allow you to other packages as a

free standing .

You’ll notice that many of the packages have the option –disable-nls because my does not have NLS

(National Language Support) installed. If you speak english and do not need any other language support, this may be

appropriate for you. My suggestion is to try all these packages first without using that option and see if they .

If they don’t , add that option in and try again.

You need to create a directory to store all the files you’ve downloaded as well as unpacked on your existing .

I created a directory in / called /origanals for lack of a better name. I suggest you do the exact same thing because

we’ll need to make static links to this directory for the compiler installation. Trust me, just make a directory called

//origanals and save all your downloads there. We’ll just take these in alphabetical order. ‘Required packages’ has

the location of where I downloaded all these files.

AUTOCONF:

-This package produces shell scripts whiich automatically the code in packages you

-Unpack the autoconf zip/tar file

-Go into the directory and it by typing ./

- it by running make

-Copy: autoconf, autoheader, autoreconf,, autoscan, autoupdate, and ifnames to /mnt/linux2/usr/bin

-Copy all *.m4 and *.m4f files to /mnt/llinux2/usr/share/autoconf by typing cp *.m4* /mnt/linux2/usr/share/autoconf

-Copy: acconfig.h, acfunctions, acheaderrs, acidentifiers, acmakevars, and acprograms to /mnt/linux2/usr/share/autoconf

AUTOMAKE:

-This package generates the ‘Makefile.inn’ file for use with autoconf

-Unpack the automake zip/tar file

-Go into the directory and it by typing ./

-Copy aclocal and automake to /mnt/linuxx2/usr/bin

-Copy: acinstall, config.guess, config.ssub, elisp-comp, -sh, mdate-sh, missing, mkinstalldirs, and ylwrap to

/mnt/linux2/usr/share/automake

-Copy all *.am files to /mnt/linux2/usr//share/automake

-Go into the /m4 directory and copy all *.m4 files to /mnt/linux2/usr/share/aclocal

BINUTILS:

-Unpack the binutils zip/tar file

-Go into the directory and it by typing ./ –disable-nls

- it by running make LDFLAGS=-alll-static

-Go into the /gas directory and copy as–new and gasp-new to /mnt/linux2/usr/bin

-Rename the files in /mnt/linux2/usr/binn to as and gasp (remove the -new)

-Next go into the /ld directory and copyy ld-new to /mnt/linux2/usr/bin

-Rename the file in /mnt/linux2/usr/bin to ld (remove the -new)

-Next go into the packages /binutils dirrectory and copy: addr2line, ar, nm-new, objcopy, objdump, ranlib, size, strings,

and strip-new to the /mnt/linux2/usr/bin directory.

-Rename the files in /mnt/linux2/usr/binn to nm and strip (remove the -new)

FILEUTILS:

-Basic files used in the OS for copying,, making directories, etc..

-Unpack the fileutils zip/tar file

-Go into the directory and it by typing ./ –disable-nls

- it by running make LDFLAGS=-staatic

-Copy from the /src directory: chgrp, chhmod, chown, cp, dd, df, dir, dircolors, du, ln, ls, mkdir, mkfifo, mknod, mv, rm,

rmdir, sync, touch, vdir to /mnt/linux2/usr/bin

-Copy ginstall to /mnt/linux2/usr/bin annd rename to

FINDUTILS:

-This package helps you find the locatioon of files on the

-Unpack the findutils zip/tar file

-Go into the directory and it by typing ./

- it by running make LDFLAGS=-alll-static

-Copy from the /find directory the find file to /mnt/linux2/usr/bin

-Copy from the /xargs directory the xarggs file to /mnt/linux2/usr/bin

GREP:

-Unpack the grep zip/tar file

-Go into the directory and it by typing ./ –disable-nls –without-included-regex

- it by running make LDFLAGS=-staatic

-Copy from the /src directory: egrep, fggrep, and grep to /mnt/linux2/usr/bin

GZIP:

-Unpack the gzip zip/tar file

-Go into the directory and it by typing ./

- it by running make LDFLAGS=-staatic

-Copy the gzip file to /mnt/linux2/bin

LD.SO:

-Unpack the ld.so zip/tar file

-Go into the /util directory

- ldd by running make ldd

- ldconfig by running make ldconffig

-Copy ldd to /mnt/linux2/usr/bin

-Copy ldconfig to /mnt/linux2/sbin

M4:

-Had trouble compiling, download this fiile (if you haven’t already from www.byolinux.org/files/m4) to /mnt/linux2/usr/bin

MAKE:

-This package determines which pieces off a program need to be re-compiled and issues commands to re- them

-Unpack the make zip/tar file

-Go into the directory and it by typing ./

- it by running make LDFLAGS=-staatic

-Copy make to /mnt/linux2/usr/bin

MAWK:

-Unpack the mawk zip/tar file

-Go into the directory and it by typing ./

- it by running make CFLAGS=”-O –static”

-Note that -O is not a zero

-Copy mawk to /mnt/linux2/usr/bin

SED:

-Unpack the mawk zip/tar file

-Go into the directory and it by typing ./

- it by running make CFLAGS=”-O –static”

-Note that -O is not a zero

-Copy mawk to /mnt/linux2/usr/bin

SH-UTILS:

-This package contains shell programmingg utilities

-Unpack the sh-utils zip/tar file

-Go into the directory and it by typing ./ –disable-nls

- it by running make LDFLAGS=-staatic

-Copy from the /src directory: basename,, date, dirname, echo, env, expr, factor, false, groups, id, logname,

nice, nohup, pathchk, printenv, printf, pwd, seq, sleep, stty, su, tee, test, true, tty, uname, uptime, users, who, whoami,

and yes to /mnt/linux2/usr/bin

-Copy from the /src directory the chroott file to /mnt/linux2/sbin

TAR:

-Unpack the tar zip/tar file

-Go into the directory and it by typing ./ –disable-nls

- it by running make LDFLAGS=-staatic

-Copy from the /src directory the tar fiile to /mnt/linux2/usr/bin

TEXINFO:

-This package generates some printed mannuals

-Unpack the texinfo zip/tar file

-Go into the directory and it by typing ./ –disable-nls

- it by running make LDFLAGS=-staatic

-Copy from the /makeinfo directory the mmakeinfo file to /mnt/linux2/usr/bin

TEXTUTILS:

-Unpack the textutils zip/tar file

-Go into the directory and it by typing ./ –disable-nls

- it by running make LDFLAGS=-staatic

-Copy from the /src directory the cat fiile to /mnt/linux2/bin

-Copy from the /src directory: cksum, coomm, csplit, cut, expand, fmt, fold, head, join, md5sum, nl, od, paste, pr, sort,

split, sum, tac, tail, tr, unexpand, uniq, and wc to /mnt/linux2/usr/bin

UTIL-:

-Unpack the util- zip/tar file

-Go into the directory and it by typing ./

-Go into the packages /lib directory herre and type make

-Go into the packages /mount directory aand it by running make LDFLAGS=-static

-Copy from the /mount directory: losetupp, mount, swapon, and umount to /mnt/linux2/sbin

-Go into the packages /-utils direcctory and it by running make LDFLAGS=-static

-Copy from the /-utils directory thhe agetty file to /mnt/linux2/sbin

MAKING A BACKUP:

Ok, let’s save all your hard work to this point. On your linux1 goto /mnt/linux2. Type the following:

————————————–

tar cvf backup1.tar *

————————————–

This will make a backup of the contents of the /mnt/linux2 directory called backup1.tar

You should also compress this file with gzip because it’s huge by typing:

————————————–

gzip backup1.tar

————————————–

Move this file off of linux2 afterwards to where you keep your downloaded files on linux1

8) BYO : Glibc

Next, we are going to glibc (aka C library). But first, we need to create a ‘fstab’ file so we will be able to

mount the in read-write mode. Make sure you are in your original, linux1 and linux2 is mounted. Type

vi /mnt/linux2/etc/fstab and type the following.

——————————————————–

/dev/hda2 / ext2 defaults 0 1

/dev/hda4 none swap sw 0 0

proc /proc proc defaults 0 0

——————————————————–

You substitute the proper locations for your new as well as your swap location.

Save this file.

The glibc will be a 2 part . We need the actual libraries as well as the developement libraries in compiled

format. These are the only packages that we are using that are already compiled. In the ‘Required Packages’ chapter, I

used ’s latest glibc BINARIES and glibc-development BINARIES.

I’m going to use a program called ‘alien’ that I got from .tucows.com to convert these files to a normal tar/zip

file. It works by typing the following:

——————————————————–

alien -t filename.

——————————————————–

Note: The alien package requires the cpio package to be installed.

Now that you have the files in the .tgz format, you can run gzip -d on them to put them into tar format. Copy these tar

files to /mnt/linux2, right there in the main directory. NOTE: I called it the main directory instead of the

directory. I just didn’t want anyone to confuse it with the / directory.

Next, up the linux2 . Do a cd / to get to the main directory. You should see your normal folders there along

with your glibc tarfiles.

Mount this in read/write mode by typing mount -n -o remount,rw /

Do a tar -xvf glibc-2.1.3.tar (or whatever the name of your file is) to place the lib files where they belong.

Do a tar -xvf on the development tar file as well. Type ldconfig -v to link everything up correctly. Now you have

working libraries, the latest ones also. Remove the tarfiles.

Create the following directory symlinks:

——————————————————–

ln -s /etc /usr/etc

ln -s /usr /usr/local

ln -s /var /usr/var

ln -s /usr/man /usr/share/man

——————————————————–

Create the following file symlinks:

——————————————————–

ln -s /bin/bash /bin/sh

ln -s /usr/bin/mawk /usr/bin/awk

ln -s /sbin/agetty /sbin/getty

ln -s /sbin/swapon /sbin/swapoff

9) BYO :

You should still be inside the linux2 with it mounted.

Create a directory called linux1 by typing mkdir /mnt/linux1

Next, mount the linux1 from linux2 by typing mount /dev/hda3 /mnt/linux1 (You substitute hda3 for where your normal

linux1 is).

You substitute hda3 for where your normal linux1 is.

Now, we are going to the . Copy the downloaded tar file from linux1 to /usr/src on linux2.

Note, I’m not interested in actually making a new now, I just want to get a few symlinks setup that are necessary

for the next chapter. Compiling a false is just a sneaky way of doing so. I guess that’s what I get for reading

directions every now and then because that’s where I learned this trick.

Unpack the tar file.

Remove the tar file from /usr/src

Now, let’s create some necessary symlinks. Change directories to /usr/include then type the following:

————————————————-

ln -s ../src//include/asm asm

ln -s ../src//include/

————————————————-

Now, assuming you copied the m4 and sed file from me earlier, go to the /usr/bin directory and change the permissions of

these files to make them executable by typing the following:

————————————————-

chmod 755 m4

chmod 755 sed

————————————————-

Next, goto /usr/src/ and type make config

Answer n to as many questions as possible. This will setup the rest of the symlinks automatically.

That’s all we are doing for the for now, we’ll remake the for real in a later chapter.

TIME FOR ANOTHER BACKUP:

Ok, let’s save all your hard work to this point again. We’ll need to back to Linux1 but first, let’s unmount

everything. Do a cd / to get to the directory. Next, type umount /mnt/linux1. Next, type mount -o remount,ro /.

Now go ahead and issue a -f. This will you. Once your back in Linux1, mount linux2 and goto the /mnt/linux2

directory. Type the following:

————————————————-

tar cvf backup2.tar *

————————————————-

This will make a backup of the contents of the /mnt/linux2 directory called backup2.tar

You should also compress this file with gzip because it’s huge by typing:

gzip backup2.tar

Move this file off of linux2 afterwards to where you keep your downloaded files on linux1.

10) BYO : GCC 2.95.2

Next, we will be installing GCC 2.95.2 as our default compilers. It’s interesting to note that with the release of 2.95.2,

many compilers such as c, c++, fortran and others have been included in the package whereas older gcc compilers were only

c compilers. This first will be a static . We’ll re- dynamically later.

You should still be in Linux1 after you backed everything up in the last chapter.

Goto the place your gcc-2.95.2 package is and unpack it there. Mine is in //origanals. Wherever it is, you will need to

remember it’s location later in order to create a symlink to it on linux2.

Next, go into that gcc-2.95.2 directory and type the following:

—————————————————–

./ –enable- –disable-nls

—————————————————–

—————————————————–

make CFLAGS=’-g -O2 -static’ bootstrap (this will take about 30 minutes)

—————————————————–

(Note: That’s an O2, not a zero two)

Next, to linux2 and mount the read-write. Mount linux1 as well. Since my GCC package was located in

//origanals on linux1, I need to create a symlink on linux2. Type the following:

—————————————————–

mkdir //origanals

cd //origanals

ln -s /mnt/linux1//origanals/gcc-2.95.2 gcc-2.95.2 (and yes, that is a space between the 2 and the g).

—————————————————–

Next, goto /mnt/linux1//origanals/gcc-2.95.2 and type

—————————————————–

make

—————————————————–

Ignore any errors regarding a clock skew. Next, a few symlinks are necessary. Type the following:

—————————————————–

ln -s /usr/bin/gcc /usr/bin/cc

ln -s /usr/bin/cpp /lib/cpp

—————————————————–

Remove the origanals directory and the symlink inside by typing rm -r dirname where dirname is the name of the directory.

Remain in this distribution now, linux1 is no longer necessary except to access the downloaded packages.

11) BYO : A Few Necessities

These packages should be compiled in the order shown

DIFFUTILS:

The diffutils package compares files by showing line by line changes in multiple formats. Unpack it and type the following:

./

make

make

BISON:

This package is what is known as a parser generator. Unpack it and type the following:

./

make

make

PERL:

Next, unpack and type the following:

./ -d

make (this will take about 10 minutes)

make

NCURSES:

The ncurses package is required to vim. It displays and updates text on a text only terminal. Unpack ncurses and

then type the following in that directory:

./ –with-

make

make

VIM:

Vim is your text edititor. Vim itself comes in two packages, a src and a rt package. Create a folder and put both of these

packages in it. Untar them there. It will produce one vim folder where everything is located. Go into that folder and type

the following:

./

make

make

Create a symlink in /usr/bin to link vi to vim.

Here’s a tip I got from the vim faq to make vim operate more like you may be used to. Create a file called //.vimrc

and put the following two lines in there:

set nocompatible

set bs=2

TERMCAP:

Next, the termcap library. Unpack it and type the following:

./

make

make

READLINE:

Next, the readline library. Readline maintains a list of previously typed commands for easy recall by pressing the

up arrow button. Unpack it and type the following:

./

make

make

make -

ldconfig -v

FLEX:

Next, flex. Unpack it and type the following:

./

make

make

LESS:

Next, less. Less enables you to show a screen at a time and will allow you to scroll backwards. Less is sometimes

referred to as a pager. Unpack it and type the following:

./

make

make

MODUTILS:

Next, modutils. Unpack it and type the following:

./

make

make

Make a /lib/modules/..XX directory (you substitue the proper version number for ..XX).

Finally, do a depmod to generate the modules dependency file (this file will be automatically placed in /lib/modules/..XX)

which will be necessary later.

E2FSPROGS:

Next, e2fsprogs. These are the utilities used for checking the integrity of the hard drive and the filesystem for

corruption. Unpack it, create a directory in the directory called build and go into that directory. Type the

following:

../ (NOTE: Two periods)

make

Make this temporary symlink ln -s /usr/bin/rm /bin/rm

make

Remove the symlink

BIN86:

Next, we’ll 2 files from this package. This package is necessary for lilo to . Unpack it and do the

following:

Go into the packages /as directory and type make as86

Copy the as86 file to /usr/bin

Next, go into the packages /ld directory and type make ld86

Copy the ld86 file to /usr/bin

LILO:

Next, lilo. This is your loader that chooses which OS to start at time. Unpack it and type the following:

make

make

Do not type /sbin/lilo as it says to, we don’t have a /etc/lilo.conf file on the new and won’t until we are ready to

say goodbye to the old .

WARNING!

If you are installing lilo 21-5 or higher, you MUST this on your linux1 as well. They are NOT compatible and

you WILL run into problems later updating the bootloader between the two distributions! Use the same instructions as above

but go ahead and type lilo on linux1 after you have installed it.

GROFF:

Next, groff. This is a text formatter. Unpack it and type the following:

./

make

make

MAN:

Next, man. This is the man page reader used to invoke help documentation that comes with each package that is

installed. Unpack it and type the following:

./ -d (Ignore the message about various decompressors missing)

make

make

Next, the shadow password suite. This is installed for better password plus it comes with many useful

tools for user administration. The most current shadow password suite is always named shadow-current when downloading.

After unpacking the archive you will notice the directory name is a date. They use a date as the version number.

After the archive is unpacked, type the following inside the packages directory:

./

make

make

pwconf

grpconv

Go into the packages /etc directory and copy the file .defs. to the /etc directory. Rename this file to

.defs

Next, use vi to edit this file. Find a field in there called MAIL_CHECK_ENAB and change the yes to no

If you would like, create a file with vi called /etc/issue and you can put a bootup message of your choice in there that a

user will see just before the prompt.

That’s it, you now have a running shadow .

(Note: pwconv and grpconv can be ran inside any directory)

PATCH:

This program is optional. It can patch code to a newer version so you don’t have to download a lengthy new package

if it was just a minor bug fix. This is useful for new versions. Unpack the archive and type:

./

make

make

BZIP:

This is a different zipper program. It’s is increasing so it’s being included. Unpack the archive and type:

make

make

12) BYO : Dynamic

Now, let’s re- dynamically the packages we made statically before. You will have to delete all the package folders

and unzip them again to make them fresh. Remaking these packages dynamically will make the CONSIDERABLY smaller.

The following packages get the standard

./

make

make

-Binutils

-Find Utils

-Grep

-M4

-Make

-Mawk

-Sed

-Tar

These next packages need special attention

GCC 2.95.2:

./ –enable-

make

make

ldconfig

BASH:

./ –with-installed-readline

make

-Find the file called Makefile and edit the variable bindir to read bindir = /bin

make

FILE UTILS:

./

make

-Find the file called Makefile and edit the following variables:

bindir to read bindir = /bin sbindir to read sbindir = /sbin sysconfdir to read sysconfdir = /etc localstatedir to read

localstatedir = /var

make

Next, move the /usr/bin/rm file to /bin

GZIP:

./

make

-Next, edit the Makefile to replace the variable bindir with /bin as described above

make

SH-UTILS:

./

make

make

Next, move the /usr/bin/echo file to /bin

SYSVINIT:

Go into the packages /src directory make

Next, edit the Makefile and look for a line that begins with :

Remove sulogin from the Makefile (shadow installs there own version).

make

TEXINFO:

./

make

make

Create a symlink that links /usr/bin/makeinfo /usr/bin/tex

TEXUTILS:

./

make

make

Move the cat file from /usr/bin to /bin

UTIL-:

WARNING: Don’t be tempted to the entire package, it will break

./

Go into the packages /lib directory and run make

Next, go into the /disk-utils directory and run make mkswap and make fdformat

Copy mkswap to /sbin

Copy fdformat to /bin

Copy mkswap.8 and fdformat.8 to /usr/man/man8

Next, go into the /fdisk directory and run make fdisk and make cfdisk

Copy both of these to /sbin

Copy fdisk.8 and cfdisk.8 to /usr/man/man8

Next, go into the /-utils directory and run make agetty

Copy agetty to /sbin

Copy agetty.8 to /usr/man/man8

Next, go into the /mount directory and run make

Copy mount, umount, swapon, and losetup to /sbin

Copy all *.8 files to /usr/man/man8

Next, go into the /sys-utils directory and run make dmesg and make rdev and make ctrlaltdel

Copy dmesg to /bin and rdev to /sbin and ctrlaltdel to /bin

Copy all *.8 files to /usr/man/man8

Create symlinks that link rdev to swapdev, ramsize, vidmode, and rootflags in the /sbin directory

Next, go into the /text-utils directory and run make more MOREHELPDIR=/usr/share/more (all one line) Copy the more file to

/usr/bin Copy the more.1 file to /usr/man/man1

Do a mkdir /usr/share/more and copy the more.help file there

Now let’s get the clock working:

Go into the /clock directory and run make hwclock

Copy the hwclock file to /sbin

Copy the hwclock.8 file /usr/man/man8

Type chmod a=rx,u=s /sbin/hwclock (this sets the UID bit to )

Next, type tzselect and follow the prompts to get your timezone information

Use vi to create the /etc/profile file and add the following in there:

hwclock –localtime –hctosys TZ=’Africa/South_Africa’; export TZ (You substitute the exact wording of the timezone it

outputed when you ran tzselect. If you can’t read it clearly, that is a semicolon after the quote mark.)

13) BYO : Scripts

This is the final chapter in the base . I considered just mixing this chapter in when we installed sysvinit

dynamically, but I can see that over time, it will need modifications depending on the that is installed.

We’ll just be doing a minimal of the scripts for now, basically everything necessary to be able to log in as a

user and automatically mount the , proc and swap file systems as well as unmount them at shutdown. Also, you will

finally be able to execute the shutdown like normal.

First, go back into the sysvinit package. Go into the /debian/etc folder. Copy everything inside this folder into your

/etc folder on the linux2 by typing cp -dpR * /etc

Next, go into your /etc/init.d folder on your linux2 . Find a file in there called rcS. We’ll need to edit this file

with vi. Find a line in there that reads [ -d /etc/rc.] && run-parts /etc/rc. and put a # in front of it to comment

it out. Also, on the very last line of this file, you can add a line that says hostname NAME where NAME is whatever you

want your to be called (BYOLINUX always looks nice). Save this file.

In this same folder, find a file in there called sendsigs. Use vi to edit this file as well. There are 4 lines in there

that begin with the word echo. Comment these out as well. The reason for this is that bash says these same comments so it

would be showing up on your screen twice. Feel free to see for yourself if you want, or even change what the scripts are

saying. I prefer just to let bash do the talking.

Next, go back in the sysvinit package. Go into the /debian/examples directory and copy a file called default.rcS to your

/etc/default folder on the linux2 and rename it to rcS. Also from this folder, copy bootlogd, , and

powerfail to /etc/init.d

Next, we need to create symlinks to the files in /etc/init.d to the appropriate runlevel directories. This is how

knows what to load up at bootup as well as what to do at shutdown or depending on what runlevel is selected.

First, goto /etc/rc6.d and type the following:

————————————————————

ln -s /etc/init.d/sendsigs S80sendsigs

ln -s /etc/init.d/umountfs S90umountfs

ln -s /etc/init.d/ S99reboot

————————————————————

Next, goto /etc/rc0.d and type the following:

————————————————————

ln -s /etc/init.d/sendsigs S80sendsigs

ln -s /etc/init.d/umountfs S90umountfs

ln -s /etc/init.d/halt S99halt

———————————————————