Home » Uncategorized » 2 January 2008 » 9,501 supporters » 2 Comments »

Howto : Build a Minimal Linux System from Source Code

2 January 2008 9,501 supporters 2 Comments

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

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

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

Contents:

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

1)BYO LINUX: PACKAGES

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

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

OPTIONAL PACKAGES:

  • apache 1.3.12 at www.apache.org/dist
  • berkeley db library 3.1.17 at www.sleepycat.com/download.html
  • ed 0.2 at ftp.gnu.org/gnu/ed
  • ipchains 1.3.9 at http://netfilter.filewatcher.org/ipchains
  • jpegsrc v6b at ftp.uu.net/graphics/jpeg
  • kde and qt at ftp://ftp.kde.org/pub/kde/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/source
  • netkit-combo 0.17 at ftp.metalab.unc.edu/pub/Linux/system/network/netkit
  • net-tools 1.57 at www.tazenda.demon.co.uk/phil/net-tools
  • ppp 2.3.11 at ftp://cs.anu.edu.au/pub/software/ppp
  • procps 2.0.7 at ftp://people.redhat.com/johnsonm/procps
  • rpm 3.0.6 at ftp.rpm.org/pub/rpm/dist/rpm-3.0.x
  • sysklogd 1.4 at ftp.metalab.unc.edu/pub/Linux/system/daemons
  • texk and texklib at ftp.tug.org/tex
  • X401src-1.tgz (2 + 3 also) at ftp.xfree86.org/pub/XFree86/4.0.1/source
  • 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 LINUX: 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 linux 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 windows 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 business. Load up your origanal linux1 distribution. In this example, we will assume you are using an IDE type hard drive (as opposed to SCSI) and it is the only hard drive on your system.

At the linux 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 Linux.

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

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

[root@linuxprog /root]#
[root@linuxprog /root]# 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) software that runs at boot time (e.g., LILO)

2) booting and partitioning software from other OSs

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

Command (m for help): _

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

That is what the screen should basically look like after you typed in the command 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 /boot directory likes to be below cylinder 1023 on older Linux 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 partitions are on you hard drive, type p.You will get a screen that looks something like this.

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

[root@linuxprog /root]#

[root@linuxprog /root]# 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) software that runs at boot time (e.g., LILO)

2) booting and partitioning software from other OSs

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

Command (m for help): p

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

Units = cylinders of 16065 * 512 bytes

Device Boot Start End Blocks Id System

/dev/hda1 * 1 259 2072353 o Win95 FAT32

/dev/hda2 259 516 2072385 83 Linux

/dev/hda3 517 700 1477980 83 Linux

/dev/hda4 701 708 64260 82 Linux swap

Command (m for help):_

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

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

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

thing, these are all primary partitions.

Linux allows 4 primary partitions where dos/win only allows

1. One linux 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 partitions, 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 linux

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

existing linux 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

computer 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 linux 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 reboot the computer, if it does, do it.

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

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

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

Linux 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 Linux partition, type mke2fs /dev/hda2. Again,

you substitute the proper hda number.

When you invoke the mke2fs command, 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 Linux filesystem you just created like you would any

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

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

/dev/hda2 a Linux 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 LINUX: Configuring LiLo Boot 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

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

the file. Here is what mine looks like.

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

boot=/dev/hda

map=/boot/map

install=/boot/boot.b

prompt

timeout=50

default=linux

image=/boot/vmlinuz

label=linux

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

root=/dev/hda3

other=/dev/hda1

label=win [-=*WINDOWS*=-]

image=/boot/vmlinuz

label=linux2

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

root/dev/hda2

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

Notice the part that I added is circled. If your new Linux system’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 boot prompt during bootup. vmlinuz is the name of my kernel. It’s also the name of my kernel 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 kernel as you are using now in your existing linux1 setup. You will be copying that kernel over in a later chapter, but don’t worry, we’ll be making a new kernel soon anyways.

Now, save and exit vi by typing : followed by wq followed by ‘enter’. Type lilo -v at the prompt to update the boot 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 kernel before (we’ll discuss that in later chapters), it’s one of the exact same steps.

4)BYO Linux: 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 boot etc home lib mnt proc root 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 command, but it will give you the same output 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 system – 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 kernel from your existing linux1 distribution to the new linux2 distribution. It’s normally located in the /boot directory and that is where you should put it in the new distribution to maintain linux file hierarchy standards. Type cp /boot/vmlinuz /mnt/linux2/boot. You substitute whatever the name of your kernel is for vmlinuz – Again, don’t worry, we will be making our own kernel in a future chapter.

Next, we need to copy the /etc/passwd and the /etc/group file from your existing system to the new system. These are your password and group belonging files. But, BEFORE we can do that, we need to determine weather or not your system is using shadow passwords 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!):

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

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

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

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

Now, let’s re-enable your shadow passwords 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 root. Go ahead and save.

5) BYO LINUX: SysVinit

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

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

Your linux2 system 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: ROOT=/mnt/linux2

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

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

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

echo “Creating $(ROOT)/dev/initctl”

rm -f $(ROOT)/dev/initctl;

mknod -m 600 $(ROOT)/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 install

Linux 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 system, 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 Linux: Bash Install

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

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

There are many shells available for linux, 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

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

./configure –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 system. Reboot the computer. At the lilo boot prompt, type linux2. If all

goes well, linux will boot up and ask you for your password. Type in whatever your password is from the system 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 reboot -f command to reboot the system back

to linux1.

6) BYO LINUX: Compiling Statically

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

new system.

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 compile statically. When you get to these packages, just click

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

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

these packages in the future. If you’re downloading these in MS Windows, 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. Linux (as well as windows) can make use of what’s called dynamic libraries. These are

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

files in the system 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 memory. 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 system to start with, we have to make these programs

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

Once we are all done installing these 17 packages, we will install 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 compile 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 install other packages as a

free standing system.

You’ll notice that many of the packages have the configure option –disable-nls because my system 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 compile.

If they don’t compile, 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 system.

I created a directory in /root 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

/root/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 configure the source code in packages you install

-Unpack the autoconf zip/tar file

-Go into the directory and configure it by typing ./configure

-Compile 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 configure it by typing ./configure

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

-Copy: acinstall, config.guess, config.ssub, elisp-comp, install-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 configure it by typing ./configure –disable-nls

-Compile 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 configure it by typing ./configure –disable-nls

-Compile 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 install

FINDUTILS:

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

-Unpack the findutils zip/tar file

-Go into the directory and configure it by typing ./configure

-Compile 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 configure it by typing ./configure –disable-nls –without-included-regex

-Compile 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 configure it by typing ./configure

-Compile 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

-Compile ldd by running make ldd

-Compile 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-compile them

-Unpack the make zip/tar file

-Go into the directory and configure it by typing ./configure

-Compile 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 configure it by typing ./configure

-Compile 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 configure it by typing ./configure

-Compile 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 configure it by typing ./configure –disable-nls

-Compile 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 configure it by typing ./configure –disable-nls

-Compile 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 configure it by typing ./configure –disable-nls

-Compile 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 configure it by typing ./configure –disable-nls

-Compile 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-LINUX:

-Unpack the util-linux zip/tar file

-Go into the directory and configure it by typing ./configure

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

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

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

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

-Copy from the /login-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 system 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 LINUX: Glibc Install

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

mount the system in read-write mode. Make sure you are in your original, linux1 system 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 linux system as well as your swap location.

Save this file.

The glibc install will be a 2 part install. 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 Redhat’s latest glibc RPM BINARIES and glibc-development RPM BINARIES.

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

file. It works by typing the following:

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

alien -t filename.rpm

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

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 root

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

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

with your glibc tarfiles.

Mount this system 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 LINUX: Kernel Install

You should still be inside the linux2 system with it mounted.

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

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

linux1 system is).

You substitute hda3 for where your normal linux1 system is.

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

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

for the next chapter. Compiling a false kernel 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/linux/include/asm asm

ln -s ../src/linux/include/linux linux

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

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/linux 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 kernel for now, we’ll remake the kernel 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 boot back to Linux1 but first, let’s unmount

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

Now go ahead and issue a reboot -f. This will reboot 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 LINUX: GCC 2.95.2 Install

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 install will be a static install. We’ll re-install 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 /root/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:

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

./configure –enable-shared –disable-nls

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

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

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

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

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

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

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

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

mkdir /root/origanals

cd /root/origanals

ln -s /mnt/linux1/root/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/root/origanals/gcc-2.95.2 and type

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

make install

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

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 LINUX: 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:

./configure

make

make install

BISON:

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

./configure

make

make install

PERL:

Next, unpack and type the following:

./Configure -d

make (this will take about 10 minutes)

make install

NCURSES:

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

then type the following in that directory:

./configure –with-shared

make

make install

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:

./configure

make

make install

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 /root/.vimrc

and put the following two lines in there:

set nocompatible

set bs=2

TERMCAP:

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

./configure

make

make install

READLINE:

Next, install 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:

./configure

make shared

make install

make install-shared

ldconfig -v

FLEX:

Next, install flex. Unpack it and type the following:

./configure

make

make install

LESS:

Next, install 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:

./configure

make

make install

MODUTILS:

Next, install modutils. Unpack it and type the following:

./configure

make

make install

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

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

which will be necessary later.

E2FSPROGS:

Next, install 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 source directory called build and go into that directory. Type the

following:

../configure (NOTE: Two periods)

make

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

make install

Remove the symlink

BIN86:

Next, we’ll install 2 files from this package. This package is necessary for lilo to compile. 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, install lilo. This is your boot loader that chooses which OS to start at boot time. Unpack it and type the following:

make

make install

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

say goodbye to the old system.

WARNING!

If you are installing lilo 21-5 or higher, you MUST install this on your linux1 system 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, install groff. This is a text formatter. Unpack it and type the following:

./configure

make

make install

MAN:

Next, install 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:

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

make

make install

Next, install the shadow password suite. This is installed for better password security 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:

./configure

make

make install

pwconf

grpconv

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

login.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 login prompt.

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

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

PATCH:

This program is optional. It can patch source 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 kernel versions. Unpack the archive and type:

./configure

make

make install

BZIP:

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

make

make install

12) BYO Linux: Dynamic Install

Now, let’s re-install 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 system CONSIDERABLY smaller.

The following packages get the standard

./configure

make

make install

-Binutils

-Find Utils

-Grep

-M4

-Make

-Mawk

-Sed

-Tar

These next packages need special attention

GCC 2.95.2:

./configure –enable-shared

make

make install

ldconfig

BASH:

./configure –with-installed-readline

make

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

make install

FILE UTILS:

./configure

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 install

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

GZIP:

./configure

make

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

make install

SH-UTILS:

./configure

make

make install

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 install:

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

make install

TEXINFO:

./configure

make

make install

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

TEXUTILS:

./configure

make

make install

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

UTIL-LINUX:

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

./configure

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 /login-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 root)

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 LINUX: Boot Scripts

This is the final chapter in the base system. 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 software that is installed.

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

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

finally be able to execute the shutdown command 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 system by typing cp -dpR * /etc

Next, go into your /etc/init.d folder on your linux2 system. 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.boot] && run-parts /etc/rc.boot 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 computer 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 system and rename it to rcS. Also from this folder, copy bootlogd, network, 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 linux

knows what to load up at bootup as well as what to do at shutdown or reboot 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/reboot 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

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

Next, goto /etc/rcS.d and type the following (these generally load up no matter what runlevel your going to in /etc/inittab):

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

ln -s /etc/init.d/checkroot.sh S10checkroot.sh

ln -s /etc/init.d/checkfs.sh S20checkfs.sh

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

Next, create a /var/log directory.

Next, at the prompt, type touch /var/run/utmp and touch /var/log/wtmp

This creates a zero byte file that will be written to later. Linux will complain without these files.

This next step is completely optional but I think it looks good, lets change the way the ls command shows you directories

and files. Use vi to edit the /etc/profile file. Add the following line:

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

alias ls=’ls –color=auto’

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

From now on (after your next reboot), files, directories, and symlinks will be shown in different colors.

Essentially, this is the end of the project as far as a base system. Congratulations. What you install from this point on

is generally up to you. At this point, it would be nice if you could send me an email to let me know of your achievment.

Make another backup of your hard work. This backup is different then the last one we did because we are making the backup

right from the same filesystem we are currently in instead of linux1. Do a cd / to get to the main (root) directory. Next,

unmount Linux1 so you don’t backup everything on that filesystem as well. Type:

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

tar cvf backup3.tar *

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

This will create a file called backup3.tar

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

gzip backup3.tar

Try a normal reboot now by typing shutdown -r now and see what happens. You may get an error regarding the swap. This is a

one time error so don’t worry about it. Make sure you check out your /proc (assuming it’s enabled in your kernel)

directory after reboot as well as try a alt-F2 through F6 to make sure your consoles are working (assuming these are

enabled in your kernel).

14) BYO LINUX: Making a New Kernel

Mount Linux1.

The first thing you should do is copy the /etc/lilo.conf file from linux1 over to linux2.

If you want to patch your kernel to update it to a new version, copy the patch(es) to the /usr/src directory. Type gzip -cd

patchXX.gz | patch -p0 where XX is the rest of the name of the patch file. You must patch in the proper order.

For example, if you are currently using kernel 2.2.14 and you notice that 2.2.16 is available, download 2 patches,

number 15 and number 16 and apply them in the proper order. If you haven’t guessed, this saves a whole lot of download time.

If you already have the latest kernel, you can ignore this entire paragraph.

Now, goto the /usr/src/linux directory.

First, type make mrproper (This will remove any stale .o files and dependencies that are laying around)

Next, type make menuconfig

Choose the options you want setup. Pressing the space bar cycles through weather you want the feature compiled into the

kernel, not used, or used as a module independent of the kernel. If you don’t know what to do, use a ? for an explanation

of the feature.

After you have finished and saved and are back at the prompt, do a make dep followed by a make clean followed by a make

bzImage (and yes, that is a capital ‘I’ in bzImage)

After the kernel is finished compiling, remove or rename the old modules directory (un-necessary if this is your first

kernel install). For example, if you have kernel 2.2.16 and just recompiled the kernel for your needs, remove or rename

the /lib/modules/2.2.16 directory.

Next, do a make modules followed by a make modules_install

Next, go into the /usr/src/linux/arch/i386/boot directory and copy the bzImage file to the /boot directory. If you are

using something other than the i386 architecture like a sparc, you substitute the proper directory for i386. Next, rename

this bzImage file to whatever your kernel name is in /etc/lilo.conf (usually vmlinuz).

Next, go into the /usr/src/linux directory and copy the System.map file over to the /boot directory. Rename it to map if

that is what you called it in your /etc/lilo.conf file.

Finally, type lilo -v at the prompt to update the bootloader.

Upon reboot, if linux should complain that the /etc/modules.conf file is newer than the /lib/modules/X.X.XX/modules.dep

file, use vi to edit the modules.dep and add a space or a blank line and then save the file. This will cure the problem.

Lastly, let’s install the sysklogd package. It’s optional. This package logs all your systems kernel messages. I put it

here because it won’t install until the kernel has been compiled and lilo ran. Unpack it and type the following:

make

make install

Copy the syslog.conf from the packages directory to your /etc directory. Edit this file. Find a line in there that reads:

mail.=info /dev/tty12 and change it to read *.* /dev/tty12

This will enable you to see all system logs by pressing alt-F12 in a console

Next, create these two directories: /var/adm and /usr/adm

Use vi to create the /etc/init.d/syslog script. Add the following 2 lines to enable system logging:

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

syslogd -m 0

klogd

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

Save this file.

Next, type ln -s /etc/init.d/syslog /etc/rc2.d/S20syslog to make it start on bootup.

Finally, do a chmod 755 /etc/init.d/syslog to set the files permissions to make it exececutable.

Backups from this point on are at your option.

15) BYO LINUX: Networking

I’m starting out with a basic lan configuration. We’ll do a lan configuration first then add PPP for your modem towards the

end of this chapter.

The first package we’ll install is net-tools. Type the following

make config

Hit enter to accept all the default answers.

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

make

make install

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

The next package we’ll install is Netkit-Combo. Type the following:

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

./configure –without-pam

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

You probably will not want to install this entire package because of security considerations, but it’s up to you. You

should only install and use what is absolutely needed. The only two packages I installed were ftp and telnet. Keep in mind,

ftp and telnet are both un-encrypted applications. Anyone running a sniffer can decode every keystroke you type. If you

require something secure, consider installing ssh (secure shell). To compile these individually, go into there individual

directories and run make followed by make install.

Next, go into the packages /netkit-base/etc.sample folder. Copy the following files to your /etc folder: inetd.conf, hosts,

host.conf, services, protocols, hosts.allow, hosts.deny

This next step is for everyone

Use vi to create a file called /etc/resolv.conf (Note: It’s not resolve, it’s resolv)

This is where the nameserver addresses are stored. These are the IP addresses your ISP gives you (usually two of them).

These addresses convert www.whatever.com into an numeric IP address. All names are translated into a number on the internet.

Here’s an example:

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

nameserver 192.168.0.1

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

If your ISP gave you two addresses (most likely), line two would start with ‘nameserver’ as well, then the IP address.

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

This next step is for people with NIC’s (Network Interface Card, or ethernet):

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

In order for your nic to be recognized, you will need to create a /etc/modules.conf file. The proper way to edit this file

is to type the following:

————————-

alias eth0 3c59x

————————-

where 3c59x is the name of the module in /lib/modules/X.X.XX/net without the .o assuming you compiled your nic as a module.

Please note, this setup assumes you are using a pci nic. You may get an isa nic to work but I had some trouble with mine

until I put some configuration options in this file as well. It can’t hurt to try. If worst comes to worst, you could try

and copy the file over from linux1. If you are using Redhat, they call it conf.modules which is no longer an accepted

practice. It will still work, but linux will complain.

Type depmod to update the modules dependency file (This is located in /lib/modules/X.X.XX in case your curious).

Also, upon reboot, if linux should complain that the /etc/modules.conf file is newer than the

/lib/modules/X.X.XX/modules.dep file, use vi to edit the modules.dep and add a space or a blank line and then save the file.

This will cure the problem.

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

This next step is for people with NIC’s also

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

Edit /etc/init.d/network and put in your proper IP address for your machine as well as your netmask. Put in your gateway if

you are using one. (A gateway is just as the name sounds, a gateway to another network. I use this because another

computer on my home network is the computer that is always hooked up to the internet). You can leave the other two fields

blank, linux will fill them in for you next time you reboot.

If your machine is not on a network, or you do not have a STATIC IP address assigned to you from your IP, you can make up

your own IP and netmask, HOWEVER, make sure you are using an IP that is set aside for lan use and NOT an internet address.

This WILL create havoc on the internet if you just make one up out of the blue! Here are suitable addresses for use on a

private lan:

10.0.0.0 through 10.255.255.255 with a netmask of 255.0.0.0

172.16.0.0 through 172.31.255.255 with a netmask of 255.255.0.0

192.168.0.0 through 192.168.255.25 with a netmask of 255.255.255.0

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

ln -s /etc/init.d/network S10network

Give the computer a reboot and then ping the loopback address and the pc itself by typing the following:

ping 127.0.0.1

ping 192.168.0.1 (or whatever ip address you assigned to the pc)

This should not have any errors. Type ctrl-c to stop the output.

If you are connected to a LAN that is connected to the internet, you should also be able to ping outside of the network to

the internet provided the gateway address is setup on your box.

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

This next step is for people who want to use modems

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

Let’s install ppp. First, we need to add a group to the system called daemon. Type the following:

—————————

groupadd -g 1 daemon

—————————

Next, unpack ppp and give it the standard configure, make, and make install. This is all we need to do. KDE will handle

your modem dialing.

16) BYO LINUX: Xwindows install

Here’s a nice break after all your hard work. Let’s get Xwindows running. Actually, getting Xwindows running was simpler

than I thought it would be.

The most difficult thing in this chapter will be the downloading of 3 packages. I say difficult because they’re like 12

Megabytes each and it will take a while for you to download them.

Next, unpack the three X src files in the directory of your choice. They will explode into a directory called xc.

Go into this /xc directory and type make World

Next, leave the room and go get yourself a nice cup of coffee. As a matter of fact, pick up the newspaper and catch up on

current events because it’s going to be over an hour for all this to compile (I’m using a Celeron 500MHz with 96Mb RAM and

it took 1hr and 20min).

This should compile without any errors and give you a nice message at the end that it’s completed sucessfully. Next let’s

install it by typing the following:

——————————–

make

make install

——————————–

One nice thing, if you ever want to remove xwindows, everything resides in the /usr/X11R6 directory. Simply deleting that

directory with the symlinks we are going to make next removes everything.

Next, create the following symlink (and watch your upper and lower cases):

——————————–

ln -s /usr/X11R6 /usr/X11

——————————–

Next, we need to create a path to /usr/X11/bin by typing the following:

vi /etc/profile

Add the following in there:

——————————–

PATH=”$PATH:/usr/X11/bin”

export PATH

——————————–

Go ahead and save that. Now in order for this new path to take effect, logout and then log back in.

Next, create a file with vi called /etc/ld.so.conf

Type /usr/X11R6/lib in there. Save the file and do a ldconfig -v to update everything.

Next, type mkdir /var/log – this directory will be needed.

Now type xf86config (xf86cfg may work for a more graphical configuration) at the prompt to setup your keyboard, mouse and

video.

If you are using a ps/2 mouse and you just can’t seem to get it to work, try another ps/2 mouse. For some reason, some

ps/2 mice need special drivers or parameters setup (I have no idea which) in order to use them. I had trouble with a

compaq mouse that just would not work in linux.

After the setup exits, at the prompt type startx

If all went well your looking at a GUI right now with 3 windows open. I could type commands into the terminal as well. The

only other thing to do now is a ctrl-alt-backspace to exit the GUI.

Lastly, let’s install procps. The reason I included it in this chapter is because it requires Xwindows to install. This

program is optional. It includes useful utilities such as top, ps and uptime which can tell you what processes are running,

how long the computer has been up and a few other things.

Unpack the archive and type:

——————————–

make

make install

ldconfig

17) BYO LINUX: RPM Install

Next we’ll be installing RPM, or Redhat Package Manager. Obviously this isn’t required but I thought I would include it

anyways. As far as package managers go, RPM is definitely one of the most popular ones and it’s very simple to use. Before

we install it, we’ll need two other packages first.

ZLIB LIBRARY:

zlib gets the standard – configure, make, make install

BERKELY DB LIBRARY:

Unpack the archive and go into the packages build_unix directory. Type the following:

../dist/configure –enable-compat185 (notice two periods not one)

make

make install

ldconfig

RPM:

Unpack the archive and type the following:

./configure –disable-nls

make

make install

rpm –initdb

Go ahead and remove the /usr/src/redhat directory.

A FEW RPM COMMANDS TO REMEMBER:

rpm -i installs a package

rpm -U upgrades a package, all older versions removed

rpm -e removes a package

rpm -qa queries the package database

rpm -ivh filename.rpm checks the packages dependencies

You will most likely have to use the –nodeps flag when using RPM because the dependencies the RPM package requires will

not be there, they were installed via source code most likely and RPM doesn’t know this. Example: rpm -i filename.

rpm –nodeps

This would be a good place for a backup, especially before we get involved in the next chapter

18) BYO LINUX: KDE2

We will be installing KDE 2.01

Follow these install directions in the order shown

LIBJPEG:

./configure –enable-shared

make

make install

LIBTIFF:

./configure -Select yes to accept default parameters make make install

Remove the tiff.sw.tools directory from root (/ not /root)

MESALIB:

./configure (ignore messages about missing makefiles)

make

make install

OPENSSL:

./config

make

make install

ldconfig

QT:

Copy qt to /usr and unpack there

Remove the tar file

Make a symlink linking qt-2.2.0 to qt

Edit the /etc/profile file and add the following lines there:

QTDIR=/usr/qt

PATH=$QTDIR/bin:$PATH

MANPATH=$QTDIR/man:$MANPATH

LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH

KDEDIR=/usr/kde

PATH=$KDEDIR/bin:$PATH

export KDEDIR PATH MANPATH QTDIR LD_LIBRARY_PATH

Logout and then log back in so the new paths take effect

Go into the /usr/qt directory and type the following:

./configure -gif -system-jpeg

Accept the lisence by typing yes

make

make a symlink that links /lib/libshadow.so.0.0.0 to /lib/libshadow.so

KDE2:

Install the following in the order listed by doing a standard ./configure, make, make install:

kdesupport

kdelibs

kdebase

These are the bare minimum packages to run kde2. They will take several hours to compile. I recommend opening up several

consoles and letting them compile overnight. I suggest you download and install them all. If you have a modem, you will

need to get kdenetwork. Don’t worry about the i18n folder unless you need different languages.

All the rest of the packages will get the standard configure, make, and make install with the exception of kdegraphics.

Here’s what needs to be done for kdegraphics:

First, install ed. Next, goto /usr/share and unpack texklib there. Remove the tarfile after it’s unpacked. Next, install

texk with the standard configure, make and make install. Now you will be able to successfully install kdegraphics. The

final step is to create a file with vi called /root/.xinitrc and add the word startkde to it and save.

Type startx to start up kde2

You might want to surf over to netscapes website and download communicator v475, however, I must say that konqueror is

really a pretty good browser.

If you decide to install netscape, you’ll need to create the following symlink:

ln -s /usr/lib/libstdc++-3-libc6.1-2-2.10.0.so libstdc++-libc6.1-1.so.2

You’ll definitely want to make a backup now.

19) BYO LINUX: Using BYO Linux as a Router

This chapter is dedicated to those who would like to setup a linux router. What does a router do you ask? Well, it’s

useful if you have a home network with only one static ip address from your isp. It allows you to basically turn that one

ip address into as many as you need so all the computers on your network can use the internet.

You do have one other choice, go out to a store like Best Buy and buy a hardware router for about $180. These can be

configured from a pc via telnet which makes them nice. Also, they come with 4 open ports on them so if you’ve been

considering buying a new hub, it’s already built into the router. With the linux router, you’ll need two NIC’s and a hub.

As you can see, it may be more cost effective to just buy the hardware router unless you got an old pentium 100 laying

around collecting dust. Technically, you don’t even need a monitor, keyboard, or mouse hooked up to it to do it’s job.

One nice thing about the linux router as opposed to a hardware router, it can be more than a router. You can also setup a

firewall. In fact, you use the firewall software IPCHAINS to setup the box as a router, so, with just a bit of tinkering,

you have a full fledged firewall as well. A firewall is probably not required for the average setup since I’m assuming you

will be using lan addresses on your host pc’s instead of internet addresses, otherwise, what’s the point in setting this

up? The reason it would not be required with lan addresses is that they cannot be seen on the internet.

Also, you can use this box for other things such as a web or ftp server. These will no doubt follow in later chapters.

The only other requirement is that you have Networking setup from the Networking chapter.

Here is a basic diagram of a simple lan with a router to the internet. It illustrates a dsl modem but cable modems work

just the same way.

This chapter is dedicated to those who would like to setup a linux router. What does a router do you ask? Well, it’s

useful if you have a home network with only one static ip address from your isp. It allows you to basically turn that one

ip address into as many as you need so all the computers on your network can use the internet.

You do have one other choice, go out to a store like Best Buy and buy a hardware router for about $180. These can be

configured from a pc via telnet which makes them nice. Also, they come with 4 open ports on them so if you’ve been

considering buying a new hub, it’s already built into the router. With the linux router, you’ll need two NIC’s and a hub.

As you can see, it may be more cost effective to just buy the hardware router unless you got an old pentium 100 laying

around collecting dust. Technically, you don’t even need a monitor, keyboard, or mouse hooked up to it to do it’s job.

One nice thing about the linux router as opposed to a hardware router, it can be more than a router. You can also setup a

firewall. In fact, you use the firewall software IPCHAINS to setup the box as a router, so, with just a bit of tinkering,

you have a full fledged firewall as well. A firewall is probably not required for the average setup since I’m assuming you

will be using lan addresses on your host pc’s instead of internet addresses, otherwise, what’s the point in setting this

up? The reason it would not be required with lan addresses is that they cannot be seen on the internet.

Also, you can use this box for other things such as a web or ftp server. These will no doubt follow in later chapters.

The only other requirement is that you have Networking setup from the Networking chapter.

Here is a basic diagram of a simple lan with a router to the internet. It illustrates a dsl modem but cable modems work

just the same way.

The first thing to do is install IPCHAINS. Unpack it and type the following

make all

make install

Next, after you have physically installed the second nic into the machine, recompile the kernel with the proper nic drivers

compiled as modules. As explained in networking, it’s best to have pci nic’s because they don’t require any configuration.

Also, make sure the following options are compiled into the kernel as well:

sysct1 (found in general setup)

network firewalls (all the rest are in networking options)

advanced router

verbose route monitoring

firewalling

masquerading

icmp masq

optimize as router

syncookie support

Now, like in networking, modify the /etc/modules.conf and add in your NIC’s. You should make eth0 the card that will be

connected to the internet(modem) and eth1 the card that will be connected to the lan. After this is complete, run depmod

Upon reboot, if linux should complain that the /etc/modules.conf file is newer than the /lib/modules/X.X.XX/modules.dep

file, use vi to edit the modules.dep file and add a space or a blank line and then save the file. This will cure the

problem.

Next, cut and paste the following and save it into a file called /etc/init.d/firewall

Do a chmod 755 /etc/init.d/firewall to make this executable.

The parts in red are the only options that you will need to modify.

#!/bin/sh

# A simple example of ipchains saved as /etc/init.d/firewall

# Load required ip_masq modules (FTP included here)

/sbin/depmod -a

/sbin/modprobe ip_masq_ftp

# Enable IP forwarding

echo “1” > /proc/sys/net/ipv4/ip_forward

# Assign external IP variables (to the internet, the ip your isp assigned you)

extip=”123.456.789.012″

extif=”eth0″

# Assign internal IP variables (to the lan)

intif=”eth1″

intnet=”192.168.0.0/24″

# The address above will make it possible to use 192.168.X.X on your lan where X.X are any numbers you choose form 0 to 255

# Initialize MASQ timeout and standard chains

ipchains -M -S 7200 10 60

ipchains -F input

ipchains -P input REJECT

ipchains -F output

ipchains -P output REJECT

ipchains -F forward

ipchains -P forward DENY

# Setup input policy

# local interface, local machines, going anywhere is valid

ipchains -A input -i $intif -s $intnet -d 0.0.0.0/0 -j ACCEPT

# reject IP spoofing where external computer claims to be a local

ipchains -A input -i $extif -s $intnet -d 0.0.0.0/0 -l -j REJECT

# allow external access via external interface

ipchains -A input -i $extif -s 0.0.0.0/0 -d $extip/32 -j ACCEPT

# loopback interface is valid

ipchains -A input -i lo -s 0.0.0.0/0 -d 0.0.0.0/0 -j ACCEPT

# Setup output policy

# all outgoing traffic is allowed

ipchains -A output -i $intif -s 0.0.0.0/0 -d $intnet -j ACCEPT

# prevent traffic for local network from using external interface

ipchains -A output -i $extif -s 0.0.0.0/0 -d $intnet -l -j REJECT

# prevent traffic from local network from using external interface

ipchains -A output -i $extif -s $intnet -d 0.0.0.0/0 -l -j REJECT

# anything else can go out

ipchains -A output -i $extif -s $extip/32 -d 0.0.0.0/0 -j ACCEPT

# loopback interface is valid

ipchains -A output -i lo -s 0.0.0.0/0 -d 0.0.0.0/0 -j ACCEPT

# Setup forwarding policy

# Masquerade local net traffic to anywhere

ipchains -A forward -i $extif -s $intnet -d 0.0.0.0/0 -j MASQ

Editing /etc/init.d/network

#! /bin/sh

#

# network Establish the network connection.

#

# Version: @(#)network 2.2 19-Apr-1999 miquels@cistron.nl

#

IPV4_FORWARD=1

case “`uname -r`” in

2.0.*) ADDROUTE=”yes” ;;

*) ADDROUTE=”” ;;

esac

# Configure the loopback device.

ifconfig lo 127.0.0.1

[ “$ADDROUTE” ] && route add -net 127.0.0.0 dev lo

# Configure the ethernet device or start SLIP/PPP below (notice the addition of a 0 after IPADDR, NETWORK, and BROADCAST).

IPADDR0=”123.456.789.012″ # Your IP address.

NETMASK=”255.255.255.224″ # Your netmask.

NETWORK0=”192.168.1.0″ # Your network address.

BROADCAST0=”192.168.1.255″ # Your broadcast address (blank if none).

GATEWAY=”123.456.789.012″ # Your gateway address.

ifconfig eth0 ${IPADDR0} netmask ${NETMASK} broadcast ${BROADCAST0}

[ “$ADDROUTE” ] && route add -net ${NETWORK0}

[ “$GATEWAY” ] && route add default gw ${GATEWAY}

#Stuff added by tom for masquerading

IPADDR1=”192.168.0.1″

NETWORK1=”192.168.1.1″

BROADCAST1=”192.168.2.255″

ifconfig eth1 ${IPADDR1} netmask ${NETMASK} broadcast ${BROADCAST1}

[ “$ADDROUTE” ] && route add -net ${NETWORK1}

[ “$ADDROUTE” ] && route add default gw ${GATEWAY}

/etc/init.d/firewall

/sbin/ipchains -A forward -s 192.168.0.0/24 -j MASQ

That should do it. Reboot the machine and give it a test. Ping the loopback, eth1, and eth2 addresses. Ping a www address

to make sure dns is working.

On your host computers, assign them ip addresses in the 192.168.X.X range with matching NETMASKS (subnets) as selected

above. The gateway device should be 192.168.0.1 if you didn’t change anything from above. You put in the dns addresses

that your isp gave you (If you are using linux machines as hosts instead of windows machines, the dns info goes in

/etc/resolv.conf just like in the networking chapter. Also, it’s not resolve.conf, it’s resolv.conf without the ‘e’).

That should do it, there shouldn’t be any problems. Re-check for typos if your having problems.

20) BYO LINUX: Apache Web Server

To my surprise, apache was very easy to install and configure. As a matter of fact, if you haven’t already guessed, this

particular web page was being hosted on a BYO Linux distribution that’s running apache. I have a static ip for my dsl line

and I just redirected you to my ip address. Anyways, on with the install.

Unpack the apache archive and type the following:

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

./configure –prefix=/usr/apache

make

make install

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

Next, create a new user on the system and assign him a password. Type the following:

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

useradd apache

passwd apache

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

You don’t need to login as this user, you can run apache as root if you would like but you will need this name in the next

step.

Edit /usr/apache/conf/httpd.conf

Find a line that says User nobody and change the nobody to apache or whatever user you just created above.

Scroll down a little farther and edit the line that says #ServerName *****. The asterics indicate whatever the name of your

server is. You will need to uncomment this line and add the appropriate server name. In my case, I just put my static ip

number in there.

That’s really all there is to a basic configuration of apache.

Goto /usr/apache/bin and type apachectl start and you are now running a web server. To test it, if this machine is on a

network, type it’s ip address into your web browser and you should get a nice message on the screen from apache telling

you it’s working. If this is a stand-alone machine, if you installed kde2, you can use it’s filemanager just like a web

browser and put the loopback address in there, 127.0.0.1

Lastly, the /usr/apache/htdocs directory is where you put your webpages.




2 Comments »

  • telnet software router top linux distros said:

    I take pleasure in, result in I discovered just what I used to be
    looking for. You have ended my 4 day lengthy hunt! God Bless you
    man. Have a great day. Bye

  • how to configure best arris tg862g /ct arris tg862 wireless said:

    Hi, Neat post. There is an issue with your site in web explorer,
    could test this? IE still is the marketplace chief and a good element of other folks will miss your magnificent writing due to this problem.

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.