old-www/HOWTO/Disk-on-Chip-HOWTO/steps.html

1005 lines
16 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML
><HEAD
><TITLE
>Using M-Systems DiskOnChip 2000 TSOP as an additional storage drive in Linux</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="Booting Linux from DiskOnChip HOWTO"
HREF="index.html"><LINK
REL="PREVIOUS"
TITLE="Assumptions"
HREF="assumptions.html"><LINK
REL="NEXT"
TITLE="Install Linux and LILO on DiskOnChip"
HREF="install.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"
>Booting Linux from DiskOnChip HOWTO</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="assumptions.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="install.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="sect1"
><H1
CLASS="sect1"
><A
NAME="steps"
></A
>4. Using M-Systems DiskOnChip 2000 TSOP as an additional storage drive in Linux</H1
><P
>The following are the steps performed for this purpose.</P
><DIV
CLASS="sect2"
><H2
CLASS="sect2"
><A
NAME="step1"
></A
>4.1. Step 1: Patch the Kernel</H2
><P
>Download a fresh copy of Kernel 2.4.18 from <A
HREF="http://www.kernel.org/pub/linux/kernel/v2.4"
TARGET="_top"
>http://www.kernel.org/pub/linux/kernel/v2.4</A
>.</P
><P
>The kernel that is downloaded from the site does not have support for the M-Systems driver so we need to add this functionality. This is done by adding a patch to the kernel.</P
><P
>The steps to conduct patching are as follows:</P
><P
></P
><OL
TYPE="1"
><LI
><P
>Untar the kernel source file and the M-systems TrueFFS Linux driver version 5.14. If the source code is in <TT
CLASS="filename"
>.tar.gz</TT
> format, use</P
><P
><B
CLASS="command"
>tar <TT
CLASS="option"
>-xvzf</TT
> <TT
CLASS="filename"
>linux-2.4.18.tar.gz</TT
></B
> </P
><P
>If the source code is in <TT
CLASS="filename"
>.tar.bz2</TT
> format, use</P
><P
><B
CLASS="command"
>bunzip2 <TT
CLASS="filename"
>linux-2.4.18.tar.bz2</TT
></B
> </P
><P
>After using <B
CLASS="command"
>bunzip2</B
>, you will get a file named <TT
CLASS="filename"
>linux-2.4.18.tar</TT
>. Untar it using the command</P
><P
><B
CLASS="command"
>tar <TT
CLASS="option"
>-xvf</TT
> <TT
CLASS="filename"
>linux-2.4.18.tar</TT
></B
> </P
><P
>Unarchiving the driver is done using the command</P
><P
><B
CLASS="command"
>tar <TT
CLASS="option"
>-xvzf</TT
> <TT
CLASS="filename"
>linux_binary.5_1_4.tgz</TT
></B
> </P
><P
>This results in the creation of two directories: <TT
CLASS="filename"
>linux</TT
> and <TT
CLASS="filename"
>linux_binary.5_1_4</TT
>.</P
></LI
><LI
><P
>The TrueFFS Linux driver package contains three different folders:</P
><P
></P
><UL
><LI
><P
><TT
CLASS="filename"
>Documentation</TT
>: this contains a PDF document describing the various functions of TrueFFS.</P
></LI
><LI
><P
><TT
CLASS="filename"
>dformat_5_1_4_37</TT
>: this contains a utility <B
CLASS="command"
>dformat</B
>, which is used to update the firmware on the DiskOnChip (DOC) and to create low level partitions on the DOC.</P
></LI
><LI
><P
><TT
CLASS="filename"
>doc-linux-5_1_4_20</TT
>: this contains patches, <TT
CLASS="filename"
>initrd</TT
> scripts and other utilities.</P
></LI
></UL
></LI
><LI
><P
>Now apply the patch to the kernel. We will use the <TT
CLASS="filename"
>linux-2_4_7-patch</TT
> file that is present in <TT
CLASS="filename"
>linux_binary.5_1_4/doc-linux-5_1_4_20/driver</TT
>. The following commands are used for this purpose:</P
><P
><B
CLASS="command"
>cd <TT
CLASS="filename"
>linux_binary.5_1_4/doc-linux-5_1_4_20/driver</TT
></B
> </P
><P
><B
CLASS="command"
>patch <TT
CLASS="option"
>-p1 -d</TT
> <TT
CLASS="filename"
>/usr/src/linux</TT
> &#60; <TT
CLASS="filename"
>linux-2_4_7-patch</TT
></B
> </P
><P
>This will create a directory named <TT
CLASS="filename"
>doc</TT
> in the <TT
CLASS="filename"
>linux/drivers/block</TT
> directory.</P
></LI
><LI
><P
>The patch created the <TT
CLASS="filename"
>doc</TT
> directory, but did not copy the source files of the M-Systems driver, which are necessary in order to build the driver, into this directory. So execute the following command:</P
><P
><B
CLASS="command"
>cp <TT
CLASS="filename"
>linux_binary.5_1_4/doc-linux-5_1_4_20/driver/doc/* /usr/src/linux/drivers/block/doc</TT
></B
> </P
></LI
></OL
><DIV
CLASS="warning"
><P
></P
><TABLE
CLASS="warning"
WIDTH="100%"
BORDER="0"
><TR
><TD
WIDTH="25"
ALIGN="CENTER"
VALIGN="TOP"
><IMG
SRC="../images/warning.gif"
HSPACE="5"
ALT="Warning"></TD
><TH
ALIGN="LEFT"
VALIGN="CENTER"
><B
>Kernel version</B
></TH
></TR
><TR
><TD
>&nbsp;</TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P
>The patch will fail for kernels other than 2.4.18 since the source files where the patch is to be applied may be somewhat different in different kernels. The patch has been provided specifically for kernel 2.4.18.</P
></TD
></TR
></TABLE
></DIV
><P
>Before moving on to Step 2, do the following:</P
><P
></P
><UL
><LI
><P
>Login as root.</P
></LI
><LI
><P
>Make sure that <B
CLASS="command"
>gcc</B
> version is 2.95.3 else the build will fail. Use <B
CLASS="command"
>gcc <TT
CLASS="option"
>--version</TT
></B
> to check this. If your <B
CLASS="command"
>gcc</B
> version is different compile gcc-2.95.3. Refer to <A
HREF="http://xlife.zuarvra.net.columns/20020316"
TARGET="_top"
>http://xlife.zuarvra.net.columns/20020316</A
> for this purpose.</P
></LI
></UL
></DIV
><DIV
CLASS="sect2"
><H2
CLASS="sect2"
><A
NAME="step2"
></A
>4.2. Step 2: Compile the Kernel</H2
><P
>Complete the following tasks for compiling the kernel:</P
><P
></P
><OL
TYPE="1"
><LI
><P
><B
CLASS="command"
>cd <TT
CLASS="filename"
>linux</TT
></B
></P
></LI
><LI
><P
><B
CLASS="command"
>make <TT
CLASS="parameter"
><I
>menuconfig</I
></TT
></B
></P
><P
>Check for the following options:</P
><P
></P
><UL
><LI
><P
>In the <SPAN
CLASS="QUOTE"
>"Block devices menu"</SPAN
>, select:</P
><P
></P
><UL
><LI
><P
>M-Systems driver as module i.e. (M)</P
></LI
><LI
><P
>Loopback device support as built-in i.e. (*)</P
></LI
><LI
><P
>RAM disk support as built-in i.e. (*)</P
></LI
><LI
><P
>Initial RAM disk (initrd) support as built .in i.e. (*)</P
></LI
></UL
></LI
><LI
><P
>In the <SPAN
CLASS="QUOTE"
>"Processor type and features menu"</SPAN
>, select <SPAN
CLASS="QUOTE"
>"Disable Symmetric Multiprocessor Support"</SPAN
>.</P
></LI
><LI
><P
>In the <SPAN
CLASS="QUOTE"
>"filesystem menu"</SPAN
>, select:</P
><P
></P
><UL
><LI
><P
>Ext3 journaling file system support as built-in</P
></LI
><LI
><P
>DOS FAT fs support as built-in<SUP
>a</SUP
></P
></LI
><LI
><P
>MSDOS fs support as built-in<SUP
>b</SUP
></P
></LI
><LI
><P
>VFAT (Windows-95) fs support as built-in<SUP
>c</SUP
> </P
></LI
></UL
></LI
></UL
><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
><TH
ALIGN="LEFT"
VALIGN="CENTER"
><B
>File System Menu</B
></TH
></TR
><TR
><TD
>&nbsp;</TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P
>a,b,c options should be activated if you want to mount your MS Windows partition, else they can be left out. It is, however, generally recommended to use them.</P
></TD
></TR
></TABLE
></DIV
><P
>An excellent resource on kernel compilation is the <A
HREF="http://www.digitalhermit.com/linux/Kernel-Build-HOWTO.html"
TARGET="_top"
>Kernel Rebuild Guide</A
>.</P
><P
>The configuration file, <TT
CLASS="filename"
>linux/.config</TT
> should essentially contain the following lines (only a part of the config file has been given):</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="screen"
>&#13;#
# Loadable module support
#
CONFIG_MODULES=y
CONFIG_MODVERSIONS=y
CONFIG_KMOD=y
#
# Processor type and features
#
# CONFIG_SMP is not set
#
# Memory Technology Devices (MTD)
#
# CONFIG_MTD is not set
#
# Block devices
#
# CONFIG_BLK_DEV_FD is not set
# CONFIG_BLK_DEV_XD is not set
# CONFIG_PARIDE is not set
# CONFIG_BLK_CPQ_DA is not set
# CONFIG_BLK_CPQ_CISS_DA is not set
# CONFIG_BLK_DEV_DAC960 is not set
CONFIG_BLK_DEV_LOOP=y
# CONFIG_BLK_DEV_NBD is not set
CONFIG_BLK_DEV_RAM=y
CONFIG_BLK_DEV_RAM_SIZE=4096
CONFIG_BLK_DEV_INITRD=y
CONFIG_BLK_DEV_MSYS_DOC=m
#
# File systems
#
# CONFIG_QUOTA is not set
# CONFIG_AUTOFS_FS is not set
# CONFIG_AUTOFS4_FS is not set
CONFIG_EXT3_FS=y
CONFIG_FAT_FS=y
CONFIG_MSDOS_FS=y
# CONFIG_UMSDOS_FS is not set
CONFIG_VFAT_FS=y
# CONFIG_EFS_FS is not set
# CONFIG_JFFS_FS is not set
# CONFIG_JFFS2_FS is not set
# CONFIG_CRAMFS is not set
CONFIG_TMPFS=y
# CONFIG_RAMFS is not set
CONFIG_ISO9660_FS=y
# CONFIG_JOLIET is not set
# CONFIG_HPFS_FS is not set
CONFIG_PROC_FS=y
# CONFIG_DEVFS_FS is not set
# CONFIG_DEVFS_MOUNT is not set
# CONFIG_DEVFS_DEBUG is not set
CONFIG_DEVPTS_FS=y
# CONFIG_QNX4FS_FS is not set
# CONFIG_QNX4FS_RW is not set
# CONFIG_ROMFS_FS is not set
CONFIG_EXT2_FS=y
</PRE
></FONT
></TD
></TR
></TABLE
></LI
><LI
><P
><B
CLASS="command"
>make <TT
CLASS="parameter"
><I
>dep</I
></TT
></B
></P
></LI
><LI
><P
><B
CLASS="command"
>make <TT
CLASS="parameter"
><I
>bzImage</I
></TT
></B
></P
></LI
><LI
><P
><B
CLASS="command"
>make <TT
CLASS="parameter"
><I
>modules</I
></TT
></B
></P
></LI
><LI
><P
><B
CLASS="command"
>make <TT
CLASS="parameter"
><I
>modules_install</I
></TT
></B
></P
></LI
><LI
><P
>Copy the newly created <TT
CLASS="filename"
>bzImage</TT
> to the <TT
CLASS="filename"
>/bott</TT
> directory and name it <TT
CLASS="filename"
>vmlinuz-2.4.18</TT
>, using this command:</P
><P
><B
CLASS="command"
>cp <TT
CLASS="filename"
>/arch/i386/boot/bzImage /boot/vmlinuz-2.4.18</TT
></B
> </P
></LI
></OL
><P
>Check for <TT
CLASS="filename"
>lib/modules/2.4.18/kernel/drivers/block/doc.o</TT
>. This is the M-Systems driver that we need to access DiskOnChip.</P
></DIV
><DIV
CLASS="sect2"
><H2
CLASS="sect2"
><A
NAME="step3"
></A
>4.3. Step 3: Create Nodes</H2
><P
>Now we will create block devices, which are required to access the DOC
These block devices will use the M-Systems driver that was built in <A
HREF="steps.html#step2"
>Section 4.2</A
> to access the DOC. The script <B
CLASS="command"
>mknod_fl</B
> in <TT
CLASS="filename"
>linux_binary.5_1_4/doc-linux-5_1_4_20/driver</TT
> is used for this purpose.</P
><P
>We need to create the block devices with the major number of 62. For this purpose we will pass the argument 62 while creating the nodes:</P
><P
><B
CLASS="command"
>./mknod_fl <TT
CLASS="parameter"
><I
>62</I
></TT
></B
> </P
><P
>This will create the following devices in <TT
CLASS="filename"
>/dev/msys</TT
> with major number 62:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="screen"
>&#13;fla...fla4
flb...flb4
flc...flc4
fld...fld4
</PRE
></FONT
></TD
></TR
></TABLE
></DIV
><DIV
CLASS="sect2"
><H2
CLASS="sect2"
><A
NAME="step4"
></A
>4.4. Step 4: Reboot with the new kernel</H2
><P
>In order to have the DiskOnChip recognized by Linux OS, we need to insert the DOC driver module into the kernel. Since the currently running kernel doesn.t have support for the M-Systems Driver, we need to boot into new kernel we just compiled in .</P
><P
>For this purpose we need to add the following entries in the <TT
CLASS="filename"
>/boot/grub/menu.lst</TT
> file:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="screen"
>&#13;title Debian GNU/Linux,Kernel 2.4.18
root (hd0,7)
kernel /boot/vmlinuz-2.4.18 root=/dev/hda8
safedefault
boot
</PRE
></FONT
></TD
></TR
></TABLE
><P
>Where (hd0,7) is the partition holding the kernel image <TT
CLASS="filename"
>vmlinuz-2.4.18</TT
> and <TT
CLASS="filename"
>/dev/hda8</TT
> is the partition holding the <EM
>root filesystem</EM
>. These partitions may vary from one system to another. Now reboot and choose the kernel 2.4.18 option (the kernel that has been compiled in Step 2) in the <B
CLASS="command"
>grub</B
> menu to boot into the new kernel.</P
></DIV
><DIV
CLASS="sect2"
><H2
CLASS="sect2"
><A
NAME="step5"
></A
>4.5. Step 5: Insert M-Systems Driver/Module in the new Kernel</H2
><P
>The M-Systems driver by default gets loaded with major number 100, but our newly created nodes (see <A
HREF="steps.html#step3"
>Section 4.3</A
>) have a major number 62. Therefore we need to insert this module with a major number 62. This can be done in either of two ways:</P
><P
></P
><OL
TYPE="1"
><LI
><P
>While inserting the module using <B
CLASS="command"
>insmod</B
> also mention the major number for the module which needs to be assigned to it otherwise it will take the default major number of 100:</P
><P
><B
CLASS="command"
>insmod <TT
CLASS="parameter"
><I
>doc major=62</I
></TT
></B
> </P
></LI
><LI
><P
>Add the following line to <TT
CLASS="filename"
>/etc/modules.conf</TT
>:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="screen"
>options doc major=62</PRE
></FONT
></TD
></TR
></TABLE
><P
>Then use <B
CLASS="command"
>modprobe <TT
CLASS="parameter"
><I
>doc</I
></TT
></B
> to insert the modules.</P
></LI
></OL
><P
>Check for the correct loading of the module using the <B
CLASS="command"
>lsmod</B
> command without options.</P
></DIV
><DIV
CLASS="sect2"
><H2
CLASS="sect2"
><A
NAME="step6"
></A
>4.6. Step 6: Create a filesystem on the DiskOnChip</H2
><P
>Before we can start using DiskOnChip we need to create a filesystem on it. We will create an ext2 filesystem since it is small in size.</P
><P
>This involves a hidden step of making partitions on the DOC using <B
CLASS="command"
>fdisk</B
>. The actual steps are as follows:</P
><P
></P
><OL
TYPE="1"
><LI
><P
><B
CLASS="command"
>fdisk <TT
CLASS="filename"
>/dev/msys/fla</TT
></B
> </P
><P
>This command will ask to create partitions. Create a primary partition number 1 with start cylinder as 1 and final cylinder as 1002.</P
><P
>Check the partition table, which should look like this:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="screen"
>&#13;Device Boot Start End Blocks ID System
/dev/msys/fla1 1 1002 255984 83 Linux
</PRE
></FONT
></TD
></TR
></TABLE
></LI
><LI
><P
>Make the filesystem on <TT
CLASS="filename"
>/dev/msys/fla1</TT
> with the command</P
><P
><B
CLASS="command"
>mke2fs <TT
CLASS="option"
>-c</TT
> <TT
CLASS="filename"
>/dev/msys/fla1</TT
></B
> </P
><P
>Where <TT
CLASS="filename"
>fla1</TT
> is the first primary partition on the DOC. (We have created only one partition in order to avoid unnecessary complexity.)</P
></LI
></OL
></DIV
><DIV
CLASS="sect2"
><H2
CLASS="sect2"
><A
NAME="step7"
></A
>4.7. Step 7: Mount the newly created partition to start accessing DOC</H2
><P
>Create a new mount point for the DiskOnChip in the <TT
CLASS="filename"
>/mnt</TT
> directory:</P
><P
><B
CLASS="command"
>mkdir <TT
CLASS="filename"
>/mnt/doc</TT
></B
> </P
><P
>Mount the DOC partition on the newly created directory:</P
><P
><B
CLASS="command"
>mount <TT
CLASS="option"
>-t</TT
> <TT
CLASS="parameter"
><I
>auto</I
></TT
> <TT
CLASS="filename"
>/dev/msys/fla1 /mnt/doc</TT
></B
> </P
><P
>You will now be able to read and write to the DOC as an additional storage drive.</P
><P
>When you reboot your system, make the DOC available by inserting the driver into the kernel (see <A
HREF="steps.html#step5"
>Section 4.5</A
>) and mounting the device.</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="assumptions.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="install.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Assumptions</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
>&nbsp;</TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Install Linux and LILO on DiskOnChip</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>