old-www/HOWTO/Flash-Memory-HOWTO/linux-2.6.html

887 lines
15 KiB
HTML

<HTML
><HEAD
><TITLE
> The Linux-2.6 kernel</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="USB Flash Memory HOWTO"
HREF="index.html"><LINK
REL="PREVIOUS"
TITLE=" Maintenance"
HREF="maintain.html"><LINK
REL="NEXT"
TITLE=" Formalities"
HREF="formal.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"
>USB Flash Memory HOWTO</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="maintain.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="formal.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="sect1"
><H1
CLASS="sect1"
><A
NAME="linux-2.6"
></A
>12. The Linux-2.6 kernel</H1
><DIV
CLASS="sect2"
><H2
CLASS="sect2"
><A
NAME="What-is-new"
></A
>12.1. What is new?</H2
><P
>
Setting up your system as described above for the Linux-2.4.x
kernels will be perfectly good, but with the Linux-2.6.x kernels
(x = 0, 1, 2, 3 at the time of this writing) much more is possible:
</P
><P
></P
><UL
><LI
><P
>&#13; USB Hotplugging of devices has been improved immensely. This
means that it has become possible to attach and remove a
device from the USB port with full cognisance of the
system. If a device is attached, it will show in the /proc
filesystem. Once it is removed, it will not show anymore.
</P
></LI
><LI
><P
>&#13; The <EM
>sysfs</EM
> system has been
introduced. By using this facility, a very tight grip on
attached devices, their attributes and nodes of attachment
is possible.
</P
></LI
><LI
><P
>&#13; Utilities for handling hotplugging have been improved or
became available. With the aid of these it is possible to
easily distinguish between attached devices irrespective of
the order in which they were attached.
</P
></LI
></UL
></DIV
><DIV
CLASS="sect2"
><H2
CLASS="sect2"
><A
NAME="kernel-options"
></A
>12.2. Kernel options</H2
><P
>&#13; Kernel configuration options are very much the same as described
in <A
HREF="hardware.html#kernel"
>Section 5.2</A
>. The configuration menu
(<TT
CLASS="prompt"
>#</TT
><TT
CLASS="userinput"
><B
><B
CLASS="command"
> make </B
>
menuconfig</B
></TT
>) has been organized differently
and more systematically. Here are the relevant choices:
</P
><DIV
CLASS="sect3"
><H3
CLASS="sect3"
><A
NAME="bus-options"
></A
>12.2.1. Bus options</H3
><P
></P
><UL
COMPACT="COMPACT"
><LI
STYLE="list-style-type: none"
><SPAN
>&#13; Support for hot-pluggable devices (CONFIG_HOTPLUG)
</SPAN
></LI
></UL
></DIV
><DIV
CLASS="sect3"
><H3
CLASS="sect3"
><A
NAME="device-drivers"
></A
>12.2.2. Device drivers</H3
><P
></P
><UL
COMPACT="COMPACT"
><LI
STYLE="list-style-type: disc"
><SPAN
>&#13; <STRONG
> SCSI device support</STRONG
>
</SPAN
></LI
><LI
STYLE="list-style-type: none"
><SPAN
>&#13; SCSI device support (CONFIG_SCSI scsi_mod)
</SPAN
></LI
><LI
STYLE="list-style-type: none"
><SPAN
>
legacy /proc/scsi support (CONFIG_SCSI_PROC_FS)
</SPAN
></LI
><LI
STYLE="list-style-type: none"
><SPAN
>
SCSI disk support (CONFIG_BLK_DEV_SD sd_mod)
</SPAN
></LI
><LI
STYLE="list-style-type: none"
><P
> </P
></LI
><LI
STYLE="list-style-type: disc"
><SPAN
>&#13; <STRONG
> USB support</STRONG
>
</SPAN
></LI
><LI
STYLE="list-style-type: none"
><SPAN
>&#13; Support for USB (CONFIG_USB usbcore)
</SPAN
></LI
><LI
STYLE="list-style-type: none"
><SPAN
>&#13; USB device filesystem (CONFIG_USB_DEVICEFS)
</SPAN
></LI
><LI
STYLE="list-style-type: none"
><SPAN
>&#13; UHCI HCD support (CONFIG_USB_UHCI_HCD uhci_hcd)
</SPAN
></LI
><LI
STYLE="list-style-type: none"
><SPAN
>&#13; USB Mass Storage support (CONFIG_USB_STORAGE usb_storage)
</SPAN
></LI
></UL
></DIV
><DIV
CLASS="sect3"
><H3
CLASS="sect3"
><A
NAME="fss-2.6"
></A
>12.2.3. File systems</H3
><P
></P
><UL
COMPACT="COMPACT"
><LI
STYLE="list-style-type: none"
><SPAN
>
Second extended (CONFIG_EXT2_FS ext2)
</SPAN
></LI
><LI
STYLE="list-style-type: none"
><P
> </P
></LI
><LI
STYLE="list-style-type: disc"
><SPAN
>
<STRONG
> DOS/FAT/NT filesystems</STRONG
>
</SPAN
></LI
><LI
STYLE="list-style-type: none"
><SPAN
>
DOS FAT fs support (CONFIG_FAT_FS fat)
</SPAN
></LI
><LI
STYLE="list-style-type: none"
><SPAN
>
MSDOS fs support (CONFIG_MSDOS_FS msdos)
</SPAN
></LI
><LI
STYLE="list-style-type: none"
><SPAN
>
VFAT (Windows 95) fs support (CONFIG_VFAT_FS vfat)
</SPAN
></LI
><LI
STYLE="list-style-type: none"
><P
> </P
></LI
><LI
STYLE="list-style-type: disc"
><SPAN
>&#13; <STRONG
> Pseudo filesystems</STRONG
>
</SPAN
></LI
><LI
STYLE="list-style-type: none"
><SPAN
>
/proc file system support (CONFIG_PROC_FS)
</SPAN
></LI
></UL
></DIV
></DIV
><DIV
CLASS="sect2"
><H2
CLASS="sect2"
><A
NAME="notes-2.6"
></A
>12.3. Notes</H2
><P
>&#13; It may be in your interest to consult
<A
HREF="http://thomer.com/linux/migrate-to-2.6.html"
TARGET="_top"
>&#13; Migrating to Linux Kernel 2.6</A
>,
but it is not necessary to follow steps that cannot be followed.
</P
></DIV
><DIV
CLASS="sect2"
><H2
CLASS="sect2"
><A
NAME="hotplug"
></A
>12.4. Hotplugging and Naming</H2
><P
>&#13; In <A
HREF="basics.html#scsidev"
>Section 6.2</A
> the situation of two USB
devices plugged in at the same time was discussed. The
difficulty is that it becomes hard for the user to
distinguish the two devices. Progress recently made in the
<A
HREF="http://sourceforge.net/search/"
TARGET="_top"
>Linux Hotplug
Project </A
> (search for hotplug) and implemented in the
2.6-series of kernels, has made it possible to address this
problem efficiently. For implementation some utilities are
needed:
</P
><P
></P
><UL
COMPACT="COMPACT"
><LI
><SPAN
> sysfs -- compiled by default into Linux-2.6.x
</SPAN
></LI
><LI
><SPAN
>&#13; <A
HREF="http://linux-diag.sourceforge.net/Sysfsutils.html"
TARGET="_top"
>&#13; sysfsutils-0.4.0 or later</A
>
</SPAN
></LI
><LI
><SPAN
>
<A
HREF="http://sourceforge.net/projects/linux-hotplug"
TARGET="_top"
>&#13; hotplug-2004_01_05 or later</A
>
</SPAN
></LI
><LI
><SPAN
>&#13; <A
HREF="http://www.kernel.org/pub/linux/utils/kernel/hotplug"
TARGET="_top"
>&#13; udev-016 or later</A
>
</SPAN
></LI
></UL
><DIV
CLASS="sect3"
><H3
CLASS="sect3"
><A
NAME="installation"
></A
>12.4.1. Installation</H3
><DIV
CLASS="formalpara"
><P
><B
>The sysfs filesystem. </B
></P
></DIV
><P
>&#13; The <EM
>sysfs</EM
> filesystem is intrinsic to
the Linux-2.6 kernel series. It is used by
<EM
>udev</EM
> and
<EM
>sysfstools</EM
> to obtain information
about kernel objects (devices, etc.), their attributes
and mutual linkages. Activation is according to the
following procedure:
</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="screen"
>&#13; <TT
CLASS="prompt"
># </TT
><TT
CLASS="userinput"
><B
><B
CLASS="command"
>cd</B
></B
></TT
> /
<TT
CLASS="prompt"
># </TT
><TT
CLASS="userinput"
><B
><B
CLASS="command"
>mkdir</B
></B
></TT
> sys
<TT
CLASS="prompt"
># </TT
><TT
CLASS="userinput"
><B
><B
CLASS="command"
>mount</B
></B
></TT
> -t sysfs none /sys
</PRE
></FONT
></TD
></TR
></TABLE
><P
>
If you do <TT
CLASS="userinput"
><B
><B
CLASS="command"
> ls </B
> -F
/sys</B
></TT
>, a whole directory structure
with entries like <EM
>block/</EM
>,
<EM
>bus/</EM
>, ... will be shown. You were
successful. The mounting should now be made permanent by
adding the following line to
<TT
CLASS="filename"
>/etc/fstab</TT
>:
</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="screen"
>&#13; none /sys sysfs defaults 0 0
</PRE
></FONT
></TD
></TR
></TABLE
><DIV
CLASS="formalpara"
><P
><B
>Sysfsutils. </B
></P
></DIV
><P
>&#13; This is installed in one of the usual ways without having
to make special configuration options. Instructions in
the README file are very clear. You should, however,
first make sure that the entry
<TT
CLASS="filename"
>/usr/local/lib</TT
> is entered in
<TT
CLASS="filename"
>/etc/ld.so.conf</TT
> so that the
<TT
CLASS="filename"
>libsysfs.so</TT
> libraries will be
recognisable by the system. After installation, check
that the utilities <TT
CLASS="filename"
>/usr/local/bin/lsbus</TT
>
and <TT
CLASS="filename"
>/usr/local/bin/systool</TT
> have been
installed. Also check that the libraries mentioned above
have been properly linked in
(<TT
CLASS="userinput"
><B
><B
CLASS="command"
>ldconfig </B
>-p | grep
libsysfs</B
></TT
>).
</P
><DIV
CLASS="formalpara"
><P
><B
>Hotplug. </B
></P
></DIV
><P
>&#13; Next install the <TT
CLASS="filename"
>hotplug</TT
>
scripts. The first thing to do is to check that
hotplugging will work on your system. Do:
<TT
CLASS="userinput"
><B
><B
CLASS="command"
> less </B
>
/proc/sys/kernel/hotplug</B
></TT
>. The
result should be
<TT
CLASS="computeroutput"
>/sbin/hotplug</TT
>. If it is
not so, you should add the line <TT
CLASS="filename"
> echo
"/sbin/hotplug" &#62; /proc/sys/kernel/hotplug</TT
> to
an appropriate initialization script,
e.g. <TT
CLASS="filename"
>/etc/rc.d/rc.local</TT
>. This
command could also be given (as root) before checking
that everything works. Installation is extremely
simple. Do: <TT
CLASS="prompt"
># </TT
><TT
CLASS="userinput"
><B
><B
CLASS="command"
> make
</B
> install</B
></TT
>. Check afterwards that the
script <TT
CLASS="filename"
>/sbin/hotplug</TT
> exists.
</P
><DIV
CLASS="formalpara"
><P
><B
>Udev. </B
></P
></DIV
><P
>&#13; This is the last installation. Study the README file and
follow the instructions necessary to be able to run
<TT
CLASS="userinput"
><B
><B
CLASS="command"
>make </B
>
USE_KLIBC=true</B
></TT
>. If you have
compiled the Linux-2.6.x kernel, this should not be too
difficult. A quick check would be to find out if
<TT
CLASS="filename"
>/sbin/udev</TT
> and
<TT
CLASS="filename"
>/sbin/udevinfo</TT
> exist. There are
other occurences as well, a very important one being
<TT
CLASS="filename"
>/etc/udev/udev.rules</TT
>. If you have a
working setup for memory sticks (as described above) and
a memory stick plugged in you could try
<TT
CLASS="userinput"
><B
><B
CLASS="command"
>ls </B
>/udev</B
></TT
>, you
should see the device (sda, sda1, ...). If it is there,
unplug the device and list again. It should be gone!
</P
></DIV
><DIV
CLASS="sect3"
><H3
CLASS="sect3"
><A
NAME="names"
></A
>12.4.2. Naming memory sticks</H3
><P
>&#13; With the <EM
>udev</EM
> utility in place, it
is possible to identify a memory stick on the basis of
some built-in attribute. One that works, is the
<EM
>vendor</EM
> identity. To find this for an
attached device, do <TT
CLASS="userinput"
><B
><B
CLASS="command"
>systool
</B
> -vb scsi | grep vendor</B
></TT
>. This
should give a list of attached SCSI devices (remember
that your memory stick poses as a SCSI device <A
HREF="basics.html#scsidev"
>Section 6.2</A
>). Let us suppose that you have two
memory sticks plugged in at the same time and found (as I
did) two vendor Id's, namely "UFD" and "STORAGE". Then
add to the file <TT
CLASS="filename"
>/etc/udev/udev.rules</TT
>
the following lines (at the top if you like):
</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="screen"
>&#13; ## Flash Memory 1
BUS="scsi", SYSFS_vendor="UFD*", NAME="namib%n"
## Flash Memory 2
BUS="scsi", SYSFS_vendor="STORAGE*", NAME="kalahari%n"
</PRE
></FONT
></TD
></TR
></TABLE
><P
>&#13; The vendor-identities may have trailing blank spaces, and
therefore the wildcard asterisks have a purpose. Do not
ignore them. Remove and replace the memory sticks, then
do <TT
CLASS="userinput"
><B
><B
CLASS="command"
>ls </B
>
/udev</B
></TT
>. Instead of the impersonal
<TT
CLASS="filename"
>sda</TT
>, <TT
CLASS="filename"
>sda1</TT
>,
etc. there should now be <TT
CLASS="filename"
>kalahari</TT
>,
<TT
CLASS="filename"
>kalahari1</TT
>,
<TT
CLASS="filename"
>namib</TT
> and
<TT
CLASS="filename"
>namib1</TT
>. The devices have been named
according to the "vendor" information in them. Thus we
can identify the device, no matter where it was
mapped. All that remains to be done is to creat
appropriate mount points like
<TT
CLASS="filename"
>/mnt/namib</TT
> and
<TT
CLASS="filename"
>kalahari</TT
> and make entries like
</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="screen"
>&#13; /udev/namib1 /mnt/namib vfat,ext2 user,noauto,rw 0 0
/udev/kalahari1 /mnt/kalahari vfat,ext2 user,noauto,rw 0 0
</PRE
></FONT
></TD
></TR
></TABLE
><P
>&#13; in <TT
CLASS="filename"
>/etc/fstab</TT
> to enable mounting
from other places.
</P
><P
>&#13; This is great fun ... and remember, there are other
deserts on the planet.
</P
></DIV
></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="maintain.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="formal.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Maintenance</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
>&nbsp;</TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Formalities</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>