old-www/LDP/Pocket-Linux-Guide/html/x1950.html

781 lines
12 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML
><HEAD
><TITLE
>Construction</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="Pocket Linux Guide"
HREF="index.html"><LINK
REL="UP"
TITLE="Hosting Applications"
HREF="a.html"><LINK
REL="PREVIOUS"
TITLE="Design"
HREF="x1841.html"><LINK
REL="NEXT"
TITLE="Implementation"
HREF="x2058.html"></HEAD
><BODY
CLASS="sect1"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Pocket Linux Guide</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="x1841.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Appendix A. Hosting Applications</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="x2058.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="sect1"
><H1
CLASS="sect1"
><A
NAME="AEN1950"
></A
>A.3. Construction</H1
><DIV
CLASS="sect2"
><H2
CLASS="sect2"
><A
NAME="AEN1952"
></A
>A.3.1. Create an enhanced boot disk</H2
><DIV
CLASS="sect3"
><H3
CLASS="sect3"
><A
NAME="AEN1954"
></A
>A.3.1.1. Build a new kernel</H3
><P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>bash# cd /usr/src/linux
bash# make menuconfig</PRE
></FONT
></TD
></TR
></TABLE
></P
><P
>Be sure to configure support for the following:</P
><P
></P
><UL
><LI
><P
>386 processor</P
></LI
><LI
><P
>Floppy disk</P
></LI
><LI
><P
>RAM disk</P
></LI
><LI
><P
>Second extended (ext2) filesystem</P
></LI
><LI
><P
>Virtual console</P
></LI
><LI
><P
>Audio hardware</P
></LI
><LI
><P
>CD-ROM hardware</P
></LI
><LI
><P
>ISO-9660 and Joliet filesystems</P
></LI
></UL
><P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>bash# make dep
bash# make clean
bash# make bzImage</PRE
></FONT
></TD
></TR
></TABLE
></P
></DIV
><DIV
CLASS="sect3"
><H3
CLASS="sect3"
><A
NAME="AEN1978"
></A
>A.3.1.2. Copy the kernel to diskette</H3
><P
>Place the boot disk in drive fd0</P
><P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>bash# mount /dev/fd0 /mnt
bash# cp /usr/src/linux/arch/i386/boot/bzImage /mnt/boot/vmlinuz</PRE
></FONT
></TD
></TR
></TABLE
></P
></DIV
><DIV
CLASS="sect3"
><H3
CLASS="sect3"
><A
NAME="AEN1983"
></A
>A.3.1.3. Unmount the boot disk</H3
><P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>bash# cd /
bash# umount /mnt</PRE
></FONT
></TD
></TR
></TABLE
></P
></DIV
></DIV
><DIV
CLASS="sect2"
><H2
CLASS="sect2"
><A
NAME="AEN1987"
></A
>A.3.2. Create an enhanced root disk</H2
><DIV
CLASS="sect3"
><H3
CLASS="sect3"
><A
NAME="AEN1989"
></A
>A.3.2.1. Create additional device files</H3
><DIV
CLASS="sect4"
><H4
CLASS="sect4"
><A
NAME="AEN1991"
></A
>A.3.2.1.1. IDE CD-ROM</H4
><P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>bash# mknod -m640 ~/staging/dev/hdc b 22 0
bash# mknod -m640 ~/staging/dev/hdd b 22 64</PRE
></FONT
></TD
></TR
></TABLE
></P
><P
>Optionally create additional IDE devices.</P
></DIV
><DIV
CLASS="sect4"
><H4
CLASS="sect4"
><A
NAME="AEN1996"
></A
>A.3.2.1.2. Ramdisk</H4
><P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>bash# mknod -m 640 ~/staging/dev/ram1 b 1 1
bash# mknod -m 640 ~/staging/dev/ram2 b 1 2
bash# mknod -m 640 ~/staging/dev/ram3 b 1 3
bash# mknod -m 640 ~/staging/dev/ram4 b 1 4
bash# mknod -m 640 ~/staging/dev/ram5 b 1 5
bash# mknod -m 640 ~/staging/dev/ram6 b 1 6
bash# mknod -m 640 ~/staging/dev/ram7 b 1 7</PRE
></FONT
></TD
></TR
></TABLE
></P
></DIV
><DIV
CLASS="sect4"
><H4
CLASS="sect4"
><A
NAME="AEN2000"
></A
>A.3.2.1.3. Audio</H4
><P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>bash# mknod -m664 ~/staging/dev/dsp c 14 3
bash# mknod -m664 ~/staging/dev/mixer c 14 0</PRE
></FONT
></TD
></TR
></TABLE
></P
></DIV
></DIV
><DIV
CLASS="sect3"
><H3
CLASS="sect3"
><A
NAME="AEN2004"
></A
>A.3.2.2. Install the gunzip binary</H3
><P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>bash# cd /usr/src/gzip-1.2.4a
bash# export CC="gcc -mcpu=i386"
bash# ./configure --host=i386-pc-linux-gnu
bash# make
bash# strip gzip
bash# cp gzip ~/staging/bin
bash# ln -s gzip ~/staging/bin/gunzip</PRE
></FONT
></TD
></TR
></TABLE
></P
><P
>Don't forget to verify library requirements, check the ownership
and check permissions on the gzip binary.</P
></DIV
><DIV
CLASS="sect3"
><H3
CLASS="sect3"
><A
NAME="AEN2009"
></A
>A.3.2.3. Write a startup script to mount a compressed floppy</H3
><P
>Use a text editor to create the following script and save it as
<TT
CLASS="filename"
>~/staging/etc/init.d/usr_image</TT
></P
><P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>#!/bin/sh
#
# usr_image - load compressed images from floppy into ramdisk and
# mount on /usr.
#
echo -n "Is there a compressed diskette to load for /usr [y/N]? "
read REPLY
if [ "$REPLY" = "y" ] || [ "$REPLY" = "Y" ]; then
echo -n "Please insert the /usr floppy into fd0 and press &#60;ENTER&#62;."
read REPLY
echo "Clearing /dev/ram1."
dd if=/dev/zero of=/dev/ram1 bs=1k count=4096
echo "Loading compressed image from /dev/fd0 into /dev/ram1..."
(dd if=/dev/fd0 bs=1k | gunzip -cq) &#62;/dev/ram1 2&#62;/dev/null
fsck -fp /dev/ram1
if [ $? -gt 1 ]; then
echo "Filesystem errors on /dev/ram1! Manual intervention required."
else
echo "Mounting /usr."
mount /dev/ram1 /usr
fi
fi
#
# end of usr_image</PRE
></FONT
></TD
></TR
></TABLE
></P
><P
>Configure the script to run right after root is mounted.</P
><P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>bash# ln -s ../init.d/usr_image ~/staging/etc/rcS.d/S21usr_image</PRE
></FONT
></TD
></TR
></TABLE
></P
></DIV
><DIV
CLASS="sect3"
><H3
CLASS="sect3"
><A
NAME="AEN2018"
></A
>A.3.2.4. Create a compressed root disk</H3
><P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>bash# cd /
bash# dd if=/dev/zero of=/dev/ram7 bs=1k count=4096
bash# mke2fs -m0 /dev/ram7
bash# mount /dev/ram7 /mnt
bash# cp -dpR ~/staging/* /mnt
bash# umount /dev/ram7
bash# dd if=/dev/ram7 of=~/phase8-image bs=1k
bash# gzip -9 ~/phase8-image</PRE
></FONT
></TD
></TR
></TABLE
></P
><P
>Insert the diskette labeled "root disk" into drive fd0.</P
><P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>bash# dd if=~/phase8-image.gz of=/dev/fd0 bs=1k</PRE
></FONT
></TD
></TR
></TABLE
></P
></DIV
></DIV
><DIV
CLASS="sect2"
><H2
CLASS="sect2"
><A
NAME="AEN2025"
></A
>A.3.3. Create a compressed /usr disk for mp3blaster</H2
><P
>The compressed /usr diskette will be created in using the same
process that is used to create the compressed root disk. We will copy
files to a staging area, copy the staging area to ramdisk, compress the
ramdisk and write it to diskette.</P
><DIV
CLASS="sect3"
><H3
CLASS="sect3"
><A
NAME="AEN2028"
></A
>A.3.3.1. Create a staging area</H3
><P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>bash# mkdir ~/usr-staging
bash# cd ~/usr-staging
bash# mkdir bin lib
bash# mkdir -p share/terminfo/l</PRE
></FONT
></TD
></TR
></TABLE
></P
></DIV
><DIV
CLASS="sect3"
><H3
CLASS="sect3"
><A
NAME="AEN2032"
></A
>A.3.3.2. Install the mp3blaster program</H3
><P
>Download the latest version of mp3blaster source code from its
home at <A
HREF="http://www.stack.nl/~brama/mp3blaster/"
TARGET="_top"
>http://www.stack.nl/~brama/mp3blaster/</A
>.</P
><P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>bash# cd ~/usr/src/mp3blaster-3.2.0
bash# ./configure
bash# make
bash# cp src/mp3blaster ~/usr-staging/bin</PRE
></FONT
></TD
></TR
></TABLE
></P
></DIV
><DIV
CLASS="sect3"
><H3
CLASS="sect3"
><A
NAME="AEN2038"
></A
>A.3.3.3. Copy additional libraries and terminfo</H3
><P
>Use <B
CLASS="command"
>ldd</B
> to find out which libraries are
needed for mp3blaster.</P
><DIV
CLASS="note"
><P
></P
><TABLE
CLASS="note"
WIDTH="100%"
BORDER="0"
><TR
><TD
WIDTH="25"
ALIGN="CENTER"
VALIGN="TOP"
><IMG
SRC="../images/note.gif"
HSPACE="5"
ALT="Note"></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P
>The following is an example from the author's development
system. It is possible that different systems may yield slightly
different results in terms of library requirements.</P
></TD
></TR
></TABLE
></DIV
><P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>bash# cd ~/usr-staging/lib
bash# ldd ~/usr-staging/bin/mp3blaster
bash# cp /usr/lib/ncurses.so.5.0 .
bash# cp /usr/lib/stdc++.so.3 .
bash# cp /lib/libm.so.6 .
bash# cp /usr/lib/libgcc_s.so.1 .
bash# cd ~/usr-staging/share/terminfo/l
bash# cp /usr/share/terminfo/l/linux .</PRE
></FONT
></TD
></TR
></TABLE
></P
></DIV
><DIV
CLASS="sect3"
><H3
CLASS="sect3"
><A
NAME="AEN2046"
></A
>A.3.3.4. Make a compressed image and copy it to diskette</H3
><P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>bash# cd /
bash# dd if=/dev/zero of=/dev/ram7 bs=1k count=4096
bash# mke2fs -m0 /dev/ram7
bash# mount /dev/ram7 /mnt
bash# cp -dpR ~/usr-staging/* /mnt
bash# umount /dev/ram7
bash# dd if=/dev/ram7 of=~/mp3blaster-image bs=1k
bash# gzip -9 ~/mp3blaster-image</PRE
></FONT
></TD
></TR
></TABLE
></P
><P
>Insert the diskette labeled "mp3blaster" into drive fd0.</P
><P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>bash# dd if=~/mp3blaster-image.gz of=/dev/fd0 bs=1k</PRE
></FONT
></TD
></TR
></TABLE
></P
></DIV
></DIV
><DIV
CLASS="sect2"
><H2
CLASS="sect2"
><A
NAME="AEN2053"
></A
>A.3.4. Create a data diskette for testing</H2
><P
>Go to the Internet site <A
HREF="http://www.paul.sladen.org"
TARGET="_top"
>http://www.paul.sladen.org</A
> and
download the mp3 file of Linus Torvalds pronouncing "Linux." The direct
link is: <A
HREF="http://www.paul.sladen.org/pronunciation/torvalds-says-linux.mp3"
TARGET="_top"
>http://www.paul.sladen.org/pronunciation/torvalds-says-linux.mp3</A
>.
Create a Second Extended (ext2) filesystem on a floppy and copy the mp3
file onto the diskette.</P
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="x1841.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="x2058.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Design</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="a.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Implementation</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>