767 lines
11 KiB
HTML
767 lines
11 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="A Simple Prototype"
|
|
HREF="phase1.html"><LINK
|
|
REL="PREVIOUS"
|
|
TITLE="Design"
|
|
HREF="x150.html"><LINK
|
|
REL="NEXT"
|
|
TITLE="Implementation"
|
|
HREF="x311.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="x150.html"
|
|
ACCESSKEY="P"
|
|
>Prev</A
|
|
></TD
|
|
><TD
|
|
WIDTH="80%"
|
|
ALIGN="center"
|
|
VALIGN="bottom"
|
|
>Chapter 2. A Simple Prototype</TD
|
|
><TD
|
|
WIDTH="10%"
|
|
ALIGN="right"
|
|
VALIGN="bottom"
|
|
><A
|
|
HREF="x311.html"
|
|
ACCESSKEY="N"
|
|
>Next</A
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
><HR
|
|
ALIGN="LEFT"
|
|
WIDTH="100%"></DIV
|
|
><DIV
|
|
CLASS="sect1"
|
|
><H1
|
|
CLASS="sect1"
|
|
><A
|
|
NAME="AEN185"
|
|
></A
|
|
>2.3. Construction</H1
|
|
><P
|
|
>In this section, we will be building the actual boot disk and root
|
|
disk floppies. Lines preceded by <TT
|
|
CLASS="prompt"
|
|
>bash#</TT
|
|
> indicate a shell
|
|
command and lines starting with <TT
|
|
CLASS="prompt"
|
|
>grub></TT
|
|
> indicate a
|
|
command typed within the grub shell.</P
|
|
><DIV
|
|
CLASS="sect2"
|
|
><H2
|
|
CLASS="sect2"
|
|
><A
|
|
NAME="AEN190"
|
|
></A
|
|
>2.3.1. Prepare the boot disk media</H2
|
|
><P
|
|
>Insert a blank diskette labeled "boot disk".</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
|
|
>It may be necessary to erase the "blank" diskette if it comes
|
|
factory pre-formatted for another, non-Linux operating system. This
|
|
can be done using the command <B
|
|
CLASS="command"
|
|
>dd if=/dev/zero of=/dev/fd0
|
|
bs=1k count=1440</B
|
|
></P
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
></DIV
|
|
><P
|
|
><TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="programlisting"
|
|
><TT
|
|
CLASS="prompt"
|
|
>bash#</TT
|
|
> mke2fs -m0 /dev/fd0
|
|
<TT
|
|
CLASS="prompt"
|
|
>bash#</TT
|
|
> mount /dev/fd0 /mnt</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
></P
|
|
></DIV
|
|
><DIV
|
|
CLASS="sect2"
|
|
><H2
|
|
CLASS="sect2"
|
|
><A
|
|
NAME="AEN200"
|
|
></A
|
|
>2.3.2. Build the GRUB bootloader</H2
|
|
><P
|
|
>Get the GRUB source code from <A
|
|
HREF="ftp://alpha.gnu.org/gnu/grub/"
|
|
TARGET="_top"
|
|
>ftp://alpha.gnu.org/gnu/grub/</A
|
|
>
|
|
and unpack it into the <TT
|
|
CLASS="filename"
|
|
>/usr/src</TT
|
|
> directory.</P
|
|
><P
|
|
>Configure and build the GRUB source code for an i386 processor by
|
|
using the following commands:</P
|
|
><TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="programlisting"
|
|
>bash# cd /usr/src/grub-0.95
|
|
bash# export CC="gcc -mcpu=i386"
|
|
bash# ./configure --host=i386-pc-linux-gnu --without-curses
|
|
bash# make</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
></DIV
|
|
><DIV
|
|
CLASS="sect2"
|
|
><H2
|
|
CLASS="sect2"
|
|
><A
|
|
NAME="AEN207"
|
|
></A
|
|
>2.3.3. Copy the bootloader files to diskette</H2
|
|
><P
|
|
>Normally, after compiling source code, one would use the command
|
|
<B
|
|
CLASS="command"
|
|
>make install</B
|
|
> to copy the finished files to their
|
|
proper destinations in the filesystem. However, using <B
|
|
CLASS="command"
|
|
>make
|
|
install</B
|
|
> does not work well with small media like the floppy
|
|
disks we are using. The problem is that there are many files in a
|
|
package besides the actual binaries that get the job done. For example,
|
|
there are often man or info pages that provide documentation. These
|
|
extra files can take up more space than we can spare on the diskette. We
|
|
can work around this limitation by copying essential files manually
|
|
rather than using <B
|
|
CLASS="command"
|
|
>make install</B
|
|
>.</P
|
|
><P
|
|
>For GRUB to boot we will need to copy the stage1 and stage2
|
|
bootloader files to the <TT
|
|
CLASS="filename"
|
|
>/boot/grub</TT
|
|
> directory on the
|
|
boot floppy.</P
|
|
><TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="programlisting"
|
|
><TT
|
|
CLASS="prompt"
|
|
>bash#</TT
|
|
> mkdir -p /mnt/boot/grub
|
|
<TT
|
|
CLASS="prompt"
|
|
>bash#</TT
|
|
> cp /usr/src/grub-0.95/stage1/stage1 /mnt/boot/grub
|
|
<TT
|
|
CLASS="prompt"
|
|
>bash#</TT
|
|
> cp /usr/src/grub-0.95/stage2/stage2 /mnt/boot/grub</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
></DIV
|
|
><DIV
|
|
CLASS="sect2"
|
|
><H2
|
|
CLASS="sect2"
|
|
><A
|
|
NAME="AEN219"
|
|
></A
|
|
>2.3.4. Finish bootloader installation</H2
|
|
><P
|
|
>Once the bootloader's files are copied to the boot disk we can
|
|
enter the grub shell to finish the installation.</P
|
|
><TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="programlisting"
|
|
><TT
|
|
CLASS="prompt"
|
|
>bash#</TT
|
|
> /usr/src/grub-0.95/grub/grub
|
|
<TT
|
|
CLASS="prompt"
|
|
>grub></TT
|
|
> root (fd0)
|
|
<TT
|
|
CLASS="prompt"
|
|
>grub></TT
|
|
> setup (fd0)
|
|
<TT
|
|
CLASS="prompt"
|
|
>grub></TT
|
|
> quit</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
></DIV
|
|
><DIV
|
|
CLASS="sect2"
|
|
><H2
|
|
CLASS="sect2"
|
|
><A
|
|
NAME="AEN227"
|
|
></A
|
|
>2.3.5. Build the Linux kernel</H2
|
|
><P
|
|
>The steps for building the kernel were tested using Linux kernel
|
|
version 2.4.26 and should work any 2.4.x or 2.6.x kernel. The latest
|
|
version of the kernel source code may be downloaded from <A
|
|
HREF="http://www.kernel.org/"
|
|
TARGET="_top"
|
|
>http://www.kernel.org/</A
|
|
> or one of
|
|
its mirrors.</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 instructions below are very brief and are intended for
|
|
someone who has previous experience building custom kernels. A more
|
|
detailed explanation of the kernel building process can be found in
|
|
the <A
|
|
HREF="http://www.digitalhermit.com/linux/Kernel-Build-HOWTO.html"
|
|
TARGET="_top"
|
|
>Kernel
|
|
Rebuild Guide</A
|
|
> by Kwan Lowe.</P
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
></DIV
|
|
><P
|
|
><TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="programlisting"
|
|
><TT
|
|
CLASS="prompt"
|
|
>bash#</TT
|
|
> cd /usr/src/linux
|
|
<TT
|
|
CLASS="prompt"
|
|
>bash#</TT
|
|
> 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
|
|
>Console on virtual terminal (2.4.x kernels only)</P
|
|
></LI
|
|
><LI
|
|
><P
|
|
>ELF binaries</P
|
|
></LI
|
|
><LI
|
|
><P
|
|
>Floppy disk</P
|
|
></LI
|
|
><LI
|
|
><P
|
|
>proc filesystem</P
|
|
></LI
|
|
><LI
|
|
><P
|
|
>RAM disk with a default size of 4096K</P
|
|
></LI
|
|
><LI
|
|
><P
|
|
>Second extended (ext2) filesystem</P
|
|
></LI
|
|
><LI
|
|
><P
|
|
>VGA console</P
|
|
></LI
|
|
></UL
|
|
><P
|
|
><TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="programlisting"
|
|
><TT
|
|
CLASS="prompt"
|
|
>bash#</TT
|
|
> make dep
|
|
<TT
|
|
CLASS="prompt"
|
|
>bash#</TT
|
|
> make clean
|
|
<TT
|
|
CLASS="prompt"
|
|
>bash#</TT
|
|
> make bzImage</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
></P
|
|
></DIV
|
|
><DIV
|
|
CLASS="sect2"
|
|
><H2
|
|
CLASS="sect2"
|
|
><A
|
|
NAME="AEN261"
|
|
></A
|
|
>2.3.6. Copy the kernel to diskette</H2
|
|
><P
|
|
><TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="programlisting"
|
|
><TT
|
|
CLASS="prompt"
|
|
>bash#</TT
|
|
> cp /usr/src/linux/arch/i386/boot/bzImage /mnt/boot/vmlinuz</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
></P
|
|
></DIV
|
|
><DIV
|
|
CLASS="sect2"
|
|
><H2
|
|
CLASS="sect2"
|
|
><A
|
|
NAME="AEN266"
|
|
></A
|
|
>2.3.7. Unmount the boot disk</H2
|
|
><P
|
|
><TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="programlisting"
|
|
><TT
|
|
CLASS="prompt"
|
|
>bash#</TT
|
|
> cd /
|
|
<TT
|
|
CLASS="prompt"
|
|
>bash#</TT
|
|
> umount /mnt</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
></P
|
|
></DIV
|
|
><DIV
|
|
CLASS="sect2"
|
|
><H2
|
|
CLASS="sect2"
|
|
><A
|
|
NAME="AEN272"
|
|
></A
|
|
>2.3.8. Prepare the root disk media</H2
|
|
><P
|
|
>Insert a blank diskette labeled "root disk".</P
|
|
><P
|
|
><TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="programlisting"
|
|
><TT
|
|
CLASS="prompt"
|
|
>bash#</TT
|
|
> mke2fs -m0 /dev/fd0
|
|
<TT
|
|
CLASS="prompt"
|
|
>bash#</TT
|
|
> mount /dev/fd0 /mnt</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
></P
|
|
></DIV
|
|
><DIV
|
|
CLASS="sect2"
|
|
><H2
|
|
CLASS="sect2"
|
|
><A
|
|
NAME="AEN279"
|
|
></A
|
|
>2.3.9. Build BASH</H2
|
|
><P
|
|
>Get the bash-3.0 source code package from <A
|
|
HREF="ftp://ftp.gnu.org/gnu/bash/"
|
|
TARGET="_top"
|
|
>ftp://ftp.gnu.org/gnu/bash/</A
|
|
>
|
|
and untar it into the <TT
|
|
CLASS="filename"
|
|
>/usr/src</TT
|
|
> directory.</P
|
|
><P
|
|
>Build BASH for an i386 CPU with the following commands:</P
|
|
><P
|
|
><TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="programlisting"
|
|
><TT
|
|
CLASS="prompt"
|
|
>bash#</TT
|
|
> cd /usr/src/bash-3.0
|
|
<TT
|
|
CLASS="prompt"
|
|
>bash#</TT
|
|
> export CC="gcc -mcpu=i386"
|
|
<TT
|
|
CLASS="prompt"
|
|
>bash#</TT
|
|
> ./configure --enable-static-link \
|
|
--enable-minimal-config --host=i386-pc-linux-gnu
|
|
<TT
|
|
CLASS="prompt"
|
|
>bash#</TT
|
|
> make
|
|
<TT
|
|
CLASS="prompt"
|
|
>bash#</TT
|
|
> strip bash</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
></P
|
|
></DIV
|
|
><DIV
|
|
CLASS="sect2"
|
|
><H2
|
|
CLASS="sect2"
|
|
><A
|
|
NAME="AEN292"
|
|
></A
|
|
>2.3.10. Copy BASH to the root disk</H2
|
|
><P
|
|
><TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="programlisting"
|
|
><TT
|
|
CLASS="prompt"
|
|
>bash#</TT
|
|
> mkdir /mnt/bin
|
|
<TT
|
|
CLASS="prompt"
|
|
>bash#</TT
|
|
> cp bash /mnt/bin/bash
|
|
<TT
|
|
CLASS="prompt"
|
|
>bash#</TT
|
|
> ln -s bash /mnt/bin/sh</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
></P
|
|
></DIV
|
|
><DIV
|
|
CLASS="sect2"
|
|
><H2
|
|
CLASS="sect2"
|
|
><A
|
|
NAME="AEN299"
|
|
></A
|
|
>2.3.11. Create device files that BASH needs</H2
|
|
><P
|
|
><TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="programlisting"
|
|
><TT
|
|
CLASS="prompt"
|
|
>bash#</TT
|
|
> mkdir /mnt/dev
|
|
<TT
|
|
CLASS="prompt"
|
|
>bash#</TT
|
|
> mknod /mnt/dev/console c 5 1</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
></P
|
|
></DIV
|
|
><DIV
|
|
CLASS="sect2"
|
|
><H2
|
|
CLASS="sect2"
|
|
><A
|
|
NAME="AEN305"
|
|
></A
|
|
>2.3.12. Unmount the root disk</H2
|
|
><P
|
|
><TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="programlisting"
|
|
><TT
|
|
CLASS="prompt"
|
|
>bash#</TT
|
|
> cd /
|
|
<TT
|
|
CLASS="prompt"
|
|
>bash#</TT
|
|
> umount /mnt
|
|
</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
></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="x150.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="x311.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="phase1.html"
|
|
ACCESSKEY="U"
|
|
>Up</A
|
|
></TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="right"
|
|
VALIGN="top"
|
|
>Implementation</TD
|
|
></TR
|
|
></TABLE
|
|
></DIV
|
|
></BODY
|
|
></HTML
|
|
> |