discuss: Some work I've been doing


Previous by date: 29 Jan 2003 20:58:22 -0000 re:Moving from "draft available" to "complete", Greg Ferguson
Next by date: 29 Jan 2003 20:58:22 -0000 Re: A new project: Xbox-Linux HOW-TO, Tabatha Persad
Previous in thread:
Next in thread: 29 Jan 2003 20:58:22 -0000 Some work I've been doing, SAK

Subject: Some work I've been doing
From: SAK ####@####.####
Date: 29 Jan 2003 20:58:22 -0000
Message-Id: <20030129205754.69229.qmail@web41508.mail.yahoo.com>

     I've recently completed work on a minimal linux system based on
Greg O'Keefe's HOWTO.  I've updated it to use the latest software &
expanded it  so that it could support itself.  I sent him a copy which
he is currently reviewing.  He suggested I submit it directly to tldp,
so here it is.  Please have a look.
     I don't have a web page so I've attached them to this message.

Thanks,

Steven A Kewish MD
Yokosuka, Japan

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

A Minimal Linux System Part 1
By Steven A Kewish MD			Copyright January 2003
___________________________________________________________________
Footnotes are labeled with #[N] where N is the reference number.

Obtain the latest, unless otherwise indicated, source code for the 
following:

PACKAGE				USEFUL SITE

bash		  		http://gnu.org/software/bash
coreutils			http://gnu.org/software/coreutils
e2fsprogs			http://e2fsprogs.sourceforge.net
glibc & linuxthreads		http://gnu.org/software/glibc #[1]
linux				http://kernel.org
ncurses				http://gnu.org/software/ncurses
procps		  		http://procps.sourceforge.net
sed				http://gnu.org/software/sed
util-linux			http://kernel.org

**AS SUPER USER (MAKE SURE /sbin & /usr/sbin ARE IN YOUR PATH)**

Run fdisk to make a 1 Gb Partition.  If you need swap, make it here.

    I use hda3 through-out this example for both the device and
    the partition's name/mount point.  Choose whatever works best 
    for you.  Note: you may need to reboot after fdisk. #[2]

Run the following to make the filesystem and mount the device:

    mke2fs -c /dev/hda3
    mkdir /mnt/hda3
    mount -t ext2 /dev/hda3 /mnt/hda3

    If you need to format swap, run: mkswap -c /dev/hdXX #[3]

Create directories and basic files:

cd /mnt/hda3
mkdir -p {bin,dev,home/user,lib,opt,proc,root}
mkdir -p {boot/grub,etc/opt,sbin/rc.d}
mkdir -p mnt/{cd0,fd0}
mkdir -p usr/{bin,include,lib,sbin,share/misc,src}
mkdir -p usr/local/{bin,games,include,lib,sbin,share,src}
mkdir -p usr/share/man/man{1,2,3,4,5,6,7,8}
mkdir -p var/{cache,lib/misc,local,lock,log,opt,run,spool,tmp}
cd usr/local
ln -f -s ../share/man
cd ..
ln -f -s share/man
cd ..
touch etc/ld.so.conf etc/securesingle
touch var/log/lastlog var/log/wtmp
chmod 1777 var/tmp
chmod 0750 root
chmod 0700 home/user

Create basic devices by running the following:

	/dev/MAKEDEV -v -d /mnt/hda3/dev generic

	Or you can manually make devices using mknod, or copy them
	from the parent system or anywhere else.  I've included a 
	set you might find useful (in /misc).  You may also require 
	devices in addition to the generics made above, such as 
	/dev/console.

	    mknod /mnt/hda3/dev/console c 5 1

Unpack & copy ALL source trees you will use to /mnt/hda3/usr/src.

Make sure /mnt/hda3 & ALL the source code is owned by root:

    chown -R 0.0 /mnt/hda3

You can delete the source trees after they are compiled & installed.

**INSTALLS ARE DONE FROM THE TOP LEVEL OF EACH SOURCE TREE**

First, install linux kernel & headers.  

    These commands will make a monolithic kernel.  At menuconfig 
    shut off modules.  I have no other advice for configuring a 
    kernel as it is very system specific.  Start with something 
    simple, or copy the "config" file from the parent system & use
    that - with modules turned off.  A basic monolithic config file
    is included in /misc (monolith.min).

    linux (monolithic)

	make mrproper
	make menuconfig
	make dep
	make clean
	make bzImage
	cp -p System.map /mnt/hda3/boot
	cp -p arch/i386/boot/bzImage /mnt/hda3/boot/hda3linuz
	cp -a include/linux /mnt/hda3/usr/include
	mkdir /mnt/hda3/usr/include/asm
	cp -a include/asm/* /mnt/hda3/usr/include/asm

Next, install glibc & linuxthreads (copy linuxthreads into the 
source tree of glibc). #[1]

	./configure --prefix=/usr --enable-add-ons --enable-shared \
	--with-headers=/mnt/hda3/usr/include --without-gd \
	--enable-kernel=current
	make
	make install_root=/mnt/hda3 install
	cp -p nss/nsswitch.conf /mnt/hda3/etc
	cd /mnt/hda3/etc
	ln -f -s ../usr/share/zoneinfo/Zulu localtime #[4]

**NOW MODIFY THE SYSTEM SO DYNAMIC LIBRARIES WORK RIGHT**

Modify /etc/ld.so.conf to include /mnt/hda3's lib directories:

    echo /mnt/hda3/lib > /etc/ld.so.conf
    echo /mnt/hda3/usr/lib > /etc/ld.so.conf

Run: ldconfig -v

Set CFLAGS (we do this to include our new includes, and allow the
	    compiler to use it's own includes):

    export CFLAGS='-nostdinc -I/mnt/hda3/usr/include \
    -I/usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.1/include'

    Use whatever your gcc base & version are called.

Install the following using these commands:

    ncurses

	./configure --prefix=/usr --exec-prefix=/ --with-shared
	make
	make DESTDIR=/mnt/hda3 install
	cd /mnt/hda3/lib
	chmod 0755 *.5.3

    bash

	./configure --prefix=/usr --exec-prefix=/ --with-curses
	make
	make DESTDIR=/mnt/hda3 install
	cd /mnt/hda3/bin
	ln -f -s bash sh

    coreutils

	./configure --prefix=/usr --exec-prefix=/
	make
	make DESTDIR=/mnt/hda3 install
	cd /mnt/hda3/usr/bin
	ln -f -s ../../bin/install
	cd ../../bin
	ln -f -s test [

    e2fsprogs

	./configure --prefix=/usr --exec-prefix=/
	make
	make DESTDIR=/mnt/hda3 install

    procps

	make
	make SKIP=/mnt/hda3/usr/bin/uptime DESTDIR=/mnt/hda3 install

    sed

	./configure --prefix=/usr --exec-prefix=/
	make
	make DESTDIR=/mnt/hda3 install

    util-linux

	./configure
	make
	make HAVE_SHADOW=no HAVE_SYSVINIT_UTILS=no \
	HAVE_SYSVINIT=no HAVE_SLN=yes DESTDIR=/mnt/hda3 install
	cd /mnt/hda3/sbin
	ln -f -s agetty getty;ln -f -s simpleinit init

Configure the software by writing the following files on /mnt/hda3:

    fstab #[3]

	cat > /mnt/hda3/etc/fstab << 'eof'
	/dev/hda3	/		ext2	defaults 	1 1
	/dev/hdXX	swap 		swap	defaults 	0 0
	none		/proc 		proc 	defaults 	0 0
	/dev/hdX	/mnt/cd0	iso9660	noauto,ro,users 0 0
	/dev/fd0	/mnt/fd0	auto	noauto,users	0 0
	eof

    group

	cat > /mnt/hda3/etc/group << 'eof'
	root::0:
	users::100:
	eof

    hosts

	cat > /mnt/hda3/etc/hosts << 'eof'
	127.0.0.1 localhost.localdomain localhost
	eof

    inittab

	cat > /mnt/hda3/etc/inittab << 'eof'
	bootprog=
	fileprefix=/sbin/rc.d/
	PATH=/bin:/sbin:/usr/bin:/usr/sbin
	INIT_PATH=/sbin/rc.d

	tty1:linux:/sbin/getty 9600 tty1
	tty2:linux:/sbin/getty 9600 tty2
	tty3:linux:/sbin/getty 9600 tty3
	tty4:linux:/sbin/getty 9600 tty4

	finalprog=
	eof

    menu.lst #[5]

	cat > /mnt/hda3/boot/grub/menu.lst << 'eof'
	default 0
	timeout 30

	title hda3
	kernel (hd0,2)/boot/hda3linuz root=/dev/hda3
	eof

    passwd

	cat > /mnt/hda3/etc/passwd << 'eof'
	root::0:0:root:/root:/bin/bash
	user::101:100:name:/home/user:/bin/bash
	eof

    profile

	cat > /mnt/hda3/etc/profile << 'eof'
	export PS1='\u:\w\$ '
	eof

Install Init Script:

    rc

	cat > /mnt/hda3/sbin/rc.d/rc << 'eof'
	#!/bin/sh
	if [ $1 != 'start' ];then exit 0;fi
	/sbin/fsck -A -C -V
	if [ $? -gt 2 ];then /sbin/init single;fi
	/sbin/swapon -a -v
	mount -n -v -o rw,remount /
	rm -f -r /tmp;mkdir -m 1777 /tmp
	> /etc/mtab
	mount -f -o rw,remount /
	mount -a -v
	rm -f -r /var/run/utmp;touch /var/run/utmp; \
	chmod 0644 /var/run/utmp
	hostname localhost
	date
	eof

	chmod 0755 /mnt/hda3/sbin/rc.d/rc

Install grub & modify it to boot the new system. #[5]

**BE CAREFUL NOT TO OVER-WRITE THE PARENT SYSTEM bzImage**

    Add "title" & "kernel" info from /mnt/hda3/boot/grub/menu.lst
    to /boot/grub/menu.lst:

	echo title hda3 > /boot/grub/menu.lst
	echo kernel '(hd0,2)'/boot/hda3linuz root=/dev/hda3 \
	> /boot/grub/menu.lst

    And run the following:

	cp -p /mnt/hda3/boot/hda3linuz /boot
	grub-install --root-directory=/mnt/hda3 /dev/hda
	grub-install /dev/hda	

Reboot into the new system.  Select "hda3" in the grub menu.
Login as root.  Change root's password by typing "passwd root". 
Change ownership of /home/user by typing "chown 101.100 /home/user".
Change user's password by typing "passwd user".

Exit and login as user.

DONE
___________________________________________________________________
Footnotes:

#[1]	If you wish to install glibc-2.3 or greater, you must
    compile with gcc-3.2 or greater.  You must also have a new
    binutils on the parent system.  Otherwise use glibc-2.2.5.

#[2]	FHS states that certain directories (i.e. /usr) should
    reside on seperate partitions.  For simplicity, this has 
    not been included in this example.  Feel free to set up your 
    system as you see fit.

#[3]	hdX & hdXX refer to any disk or partition you want to use.
    Change these to be compatible with your system.

#[4]	Use the zoneinfo correct for you.  If your system clock
    is set to local time, use Zulu.

#[5]	Assumes you are using grub with a configuration file on the
    parent system.  If you use lilo, see lilo.info in /misc.
___________________________________________________________________
References:

    Filesystem Hierarchy Standard

	http://www.pathname.com/fhs

    Glibc 2 HOWTO

	http://www.tldp.org/HOWTO/Glibc2-HOWTO.html

    How To Build a Minimal Linux System From Source Code

	http://www.netspace.net.au/~gok/power2bash

    LFS Museum

	http://archive.linuxfromscratch.org/lfs-museum

    Information Within the Source Directories of the Installed & 
    Dependent Software.

A Minimal Linux System Part 2
By Steven A Kewish MD			Copyright January 2003
____________________________________________________________________
Footnotes are labeled with #[N] where N is the reference number.

This is the second stage of the minimal system.  The purpose of
this is add some functionality.  We will not only be adding more 
packages, we'll also modify some of the software already installed so
it all run correctly.  Our goals are to make the system able to surf 
the internet, download and install pre-compiled binaries, and use a 
keyboard other than a us101.

Again hda3 is used in this example to describe both the device &
partition/ mount point.  Choose whatever works best for you.

Obtain the latest, unless otherwise indicated, source code for the 
following:

PACKAGE			USEFUL SITE

binutils		http://gnu.org/software/binutils
communicator (binaries)	http://netscape.com/download/archive
file			http://gnu.org/software/file
gawk			http://gnu.org/software/gawk
grep			http://gnu.org/software/grep
gzip			http://gnu.org/software/gzip
ppp			http://samba.org/ppp
tar			http://gnu.org/software/tar
XFree86 (binaries)	http://xfree86.org

**AS SUPER USER (MAKE SURE /sbin & /usr/sbin ARE IN YOUR PATH)**

Modify some of the basic files already present on /mnt/hda3:

    group
	
	echo daemon::3: > /mnt/hda3/etc/group
	echo tty::5: > /mnt/hda3/etc/group
	
	chmod 0.5 /dev/tty*
	
    ld.so.conf

	echo /usr/X11R6/lib > /mnt/hda3/etc/ld.so.conf

    profile

	echo export MOZILLA_HOME=/opt/netscape \
	> /mnt/hda3/etc/profile #[1]
	echo export PATH='$PATH':/usr/X11R6/bin:/opt/netscape \ 
	> /mnt/hda3/etc/profile

Unpack & copy ALL source trees you will use to /mnt/hda3/usr/src.

Make sure ALL source code is owned by root:

    chown -R 0.0 /mnt/hda3/usr/src
    
You can delete the source trees after they are compiled & installed.    

Insure the following is still added to the end of /etc/ld.so.conf:

    /mnt/hda3/lib
    /mnt/hda3/usr/lib

Run: ldconfig -v

Set CFLAGS (we do this to include our new includes, and allow the
	    compiler to use it's own includes)

    export CFLAGS='-nostdinc -I/mnt/hda3/usr/include \
    -I/usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.1/include'

    (Use whatever your gcc base & version are called)

**INSTALLS ARE DONE FROM THE TOP LEVEL OF EACH SOURCE TREE**

Install the following using these commands:

    binutils
    
	./configure --prefix=/usr --enable-shared
	make
	make prefix=/mnt/hda3/usr tooldir=/mnt/hda3/usr install
	cp -p ./include/libiberty.h /mnt/hda3/usr/include
    
    file

    	./configure --prefix=/usr --datadir=/usr/share/misc
	make
	make DESTDIR=/mnt/hda3 install
    
    gawk
    
	./configure --prefix=/usr
	make
	make DESTDIR=/mnt/hda3 install
	cd /mnt/hda3/usr/bin
	ln -sf gawk awk
	
    grep
    
	./configure --prefix=/usr
	make
	make prefix=/mnt/hda3/usr install

    gzip
    
	./configure --prefix=/mnt/hda3/usr --exec-prefix=/mnt/hda3
	make
	make install
    
    ppp #[2]
    
	./configure
	make
	make DESTDIR=/mnt/hda3 install
	
	chmod 4755 /mnt/hda3/usr/sbin/pppd
	mknod /mnt/hda3/dev/ppp c 108 0
	
    tar
    
	./configure --prefix=/usr --exec-prefix=/ \
	--libexecdir=/usr/libexec
	make
	make DESTDIR=/mnt/hda3 install

Configure ppp  #[2] #[3]

    resolv.conf
    
	cat > /mnt/hda3/etc/resolv.conf << 'eof'
	domain your_isp_domain
	nameserver ###.##.#.#
	nameserver ###.##.#.#
	eof

    chat-isp
    
	cat > /mnt/hda3/etc/ppp/chat-isp << 'eof'
	ABORT 'BUSY'
	ABORT 'ERROR'
	ABORT 'NO ANSWER'
	ABORT 'NO CARRIER'
	ABORT 'NO DIALTONE'
	'' at
	OK atdt###-####
	CONNECT ''
	eof

    pap-secrets #[4]
    
	echo your_login_name	*	your_password	* \
	> /mnt/hda3/etc/ppp/pap-secrets
	
	chmod 0600 /mnt/hda3/etc/ppp/pap-secrets

    isp #[5]
    
	mkdir /mnt/hda3/etc/ppp/peers
	cat > /mnt/hda3/etc/ppp/peers/isp << 'eof' 
	ttyS1 115200 crtscts
	connect '/usr/sbin/chat -v -f /etc/ppp/chat-isp'
	name your_login_name
	defaultroute
	noauth
	eof
	
	chmod 0644 /mnt/hda3/etc/ppp/peers/isp

    dialup
    
	cat > /mnt/hda3/usr/sbin/dialup << 'eof'
	#!/bin/sh
	/usr/sbin/pppd call isp &> /var/log/ppp-err
	eof
	
	touch /mnt/hda3/var/log/ppp-err
	chmod 0666 /mnt/hda3/var/log/ppp-err
	chmod 0755 /mnt/hda3/sbin/dialup
	
    hangup

	cat > /mnt/hda3/usr/sbin/hangup << 'eof'
	#!/bin/sh
	kill `cat /var/run/ppp*.pid`
	eof
	
	chmod 0755 /mnt/hda3/sbin/hangup
	
netscape
    
    Requires a copy of libstdc++-libc6.1-1.so.2
    Copy this from the parent system to mnt/hda3/usr/lib
    If you don't have it, I've included a copy in /misc.

Reboot into the new system and login as root.

    Install the following:
    
	xf86 (binaries)
    
	    cd /usr/src/xf86
	    sh Xinstall.sh
	
        netscape communicator (binaries)
    
	    cd /usr/src/comm*
	    ./ns-install
	    
    Configure xf86 by running:
    
	xf86config

Exit and login as user.

    To start xf86, run "startx".
    
	I've included a basic .twmrc & .xinitrc file  (in /misc)to 
	help make "X" look a little better.  If you wish to use 
	these, copy them into  /home/user, and change their 
	ownership to 101.100.

    To connect to your ISP, run /usr/sbin/dialup (/usr/sbin/hangup
    to disconnect).

    To start netscape, run "netscape".

DONE
___________________________________________________________________
Footnotes:

#[1]	/opt/netscape is the default location communicator installs
    itself.  If you put it in another location, change the 
    MOZILLA_HOME variable to point to it, and change the PATH 
    variable so netscape is included.

#[2]	Support for ppp must be compiled into the kernel for ppp to 
    work.  For a simple system this would also include support for 
    async serial lines.    

#[3] 	There are numerous pieces of information needed to set up
    dial-in networking.  Check your ISP contract for this or ask 
    your isp provider for the needed info.
    
#[4] 	The spaces in the pap-secrets file are tabs. i.e:

    your_login_name[tab]*[tab]your_password[tab]*
    
#[5]	I use an external modem attached to the second serial port 
    in this example.
____________________________________________________________________
References:
    
    PPP HOWTO
    
	http://www.tldp.org/HOWTO/PPP-HOWTO
	
    See Also References in "A minimal Linux System Part 1".

A Minimal Linux System Part 3
By Steven A Kewish MD			Copyright January 2003
___________________________________________________________________
Footnotes are labeled with #[N] where N is the reference number.

This is the third stage of the minimal system.  The purpose of
this is to add more functionality.  Our goal is to make the 
system able to compile from source code.  We'll also be adding 
some software to round-out the system.

Again hda3 is used in this example to describe both the device &
partition/mount point.  Choose whatever works best for you.

Obtain the latest, unless otherwise indicated, source code for the 
following:

PACKAGE			USEFUL SITE

diffutils		http://gnu.org/software/diffutils
findutils		http://gnu.org/software/findutils #[1]
gcc			http://gnu.org/software/gcc #[2]
gettext			http://gnu.org/software/gettext
groff			http://gnu.org/software/groff
grub			http://gnu.org/software/grub
make			http://gnu.org/software/make
patch			http://gnu.org/software/patch
texinfo			http://gnu.org/software/texinfo

**AS SUPER USER (MAKE SURE /sbin & /usr/sbin ARE IN YOUR PATH)**

Unpack & copy ALL source trees you will use to /mnt/hda3/usr/src

Make sure ALL source code is owned by root

    chown -R 0.0 /mnt/hda3/usr/src
    
You can delete the source trees after they are compiled & installed.

Insure the following is still added to the end of /etc/ld.so.conf

    /mnt/hda3/lib
    /mnt/hda3/usr/lib

Run: ldconfig -v

Set CFLAGS (we do this to include our new includes, and allow the
	    compiler to use it's own includes)

    export CFLAGS='-nostdinc -I/mnt/hda3/usr/include \
    -I/usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.1/include'

    (Use whatever your gcc base & version are called)

**INSTALLS ARE DONE FROM THE TOP LEVEL OF EACH SOURCE TREE**

Install the following using these commands:

    diffutils

	./configure --prefix=/usr
	make
	make DESTDIR=/mnt/hda3 install    

    findutils #[1]
    
	./configure --prefix=/usr
	make
	make localstatedir=/mnt/hda3/var/lib/misc \
	prefix=/mnt/hda3/usr install

    gettext
    
	./configure --prefix=/usr
	make
	make DESTDIR=/mnt/hda3 install

    groff
    
	./configure --prefix=/usr
	make
	make prefix=/mnt/hda3/usr install
	cd mnt/hda3/usr/bin
	ln -f -s soelim zsoelim
	ln -f -s eqn geqn
	ln -f -s tbl gtbl

    make
    
    	./configure --prefix=/usr
	make
	make DESTDIR=/mnt/hda3 install
	
    patch

	./configure --prefix=/usr
	make
	make prefix=/mnt/hda3/usr install
	
    texinfo
    
	./configure --prefix=/usr
	make
	make DESTDIR=/mnt/hda3 install
    
    gcc #[2]
    
	./configure --prefix=/usr --enable-shared \
	--enable-languages=c,c++ --enable-threads=posix \
	--enable-__cxa_atexit
	make bootstrap-lean
	make prefix=/mnt/hda3/usr install
	cd /mnt/hda3/lib
	ln -f -s ../usr/bin/cpp
	cd ../usr/lib
	ln -f -s ../bin/cpp
	cd ../bin
	ln -f -s gcc cc
	
Reboot into the new system and login as root.

    Install the following:
    
	grub
	
	    ./configure --prefix=/usr
	    make
	    make install
	    
    Make this partition the default boot partition.
    
	Run: grub-install /dev/hda #[3]
	
Exit and login as user.
	
Once this is installed, the system is done and can support itself.  
As you can see it is a fairly lean system, but I have yet to find 
a package it couldn't install.  Some packages (i.e. kbd), however,
may need additional support packages (i.e. bison) which would need 
to be installed prior to compilation.  See the source code of the 
desired software for further info.

DONE
____________________________________________________________________
Footnotes:

#[1] 	Findutils needs a patch for a varity of reasons.  It can be
    obtained at:

ftp.planetmirror.org/pub/lfs/lfs-packages/cvs/findutils-4.1.patch

#[2] 	If you are installing gcc-3.2 and compiling with gcc-3.2 &
    glibc-2.3, you'll need a patch which can be obtained at:

http://www.haible.de/bruno/gcc-3.2-glibc-2.3-compat.diff

#[3]	To allow this partition & the grub loader on it to boot 
    other systems, a few things must be done.
	
	First: Copy each systems kernel image into this systems 
	    /boot directory.
    
	Second: Add an entry into /boot/grub/menu.lst for each 
	    system.  An example entry for hda1 would be:
    
	    echo title hda1 > /boot/grub/menu.lst
	    echo kernel '(hd0,0)'/boot/image_name root=/dev/hda1 \
	    > /boot/grub/menu.lst
	
	Third: Re-run grub-install.
    
	    grub-install /dev/hda
____________________________________________________________________
References:

    gcc FAQ
    
	http://www.gnu.org/software/gcc/faq
	
    GNU GRUB Manual
    
	http://gnu.org/manual/grub
	
    See Also References in "A Minimal Linux System Part 1 and 
    Part 2".

Previous by date: 29 Jan 2003 20:58:22 -0000 re:Moving from "draft available" to "complete", Greg Ferguson
Next by date: 29 Jan 2003 20:58:22 -0000 Re: A new project: Xbox-Linux HOW-TO, Tabatha Persad
Previous in thread:
Next in thread: 29 Jan 2003 20:58:22 -0000 Some work I've been doing, SAK


  ©The Linux Documentation Project, 2014. Listserver maintained by dr Serge Victor on ibiblio.org servers. See current spam statz.