Howto : Build a Minimal Linux System from Source Code
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:
- Packages required for BYO Linux
- Making space
- Writing Lilo.conf
- Folders and files
- SysVinit install
- Bash install
- Compiling Statically
- Glibc install
- Kernel install
- GCC 2.95.2 Install
- A few necessities
- Dynamic install
- 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]# 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
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.
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
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
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:
make
make install
BISON:
This package is what is known as a parser generator. Unpack it and type the following:
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:
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:
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:
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:
make shared
make install
ldconfig -v
FLEX:
Next, install flex. Unpack it and type the following:
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:
make
make install
MODUTILS:
Next, install modutils. Unpack it and type the following:
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:
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:
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:
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
make
make install
-Binutils
-Find Utils
-Grep
-M4
-Make
-Mawk
-Sed
-Tar
These next packages need special attention
GCC 2.95.2:
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:
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:
make
-Next, edit the Makefile to replace the variable bindir with /bin as described above
make install
SH-UTILS:
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:
make
make install
Create a symlink that links /usr/bin/makeinfo /usr/bin/tex
TEXUTILS:
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
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.)
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
———————————————————
