old-www/HOWTO/Flash-Memory-HOWTO/basics.html

552 lines
9.7 KiB
HTML

<HTML
><HEAD
><TITLE
> Some basic concepts</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=" Hardware and kernel"
HREF="hardware.html"><LINK
REL="NEXT"
TITLE="Basic verifications"
HREF="verifications.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="hardware.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="verifications.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="sect1"
><H1
CLASS="sect1"
><A
NAME="basics"
></A
>6. Some basic concepts</H1
><P
>&#13; In this section we discuss in a very brief manner, some basic
Linux concepts which should contribute to an understanding of the
procedures described below.
</P
><DIV
CLASS="sect2"
><H2
CLASS="sect2"
><A
NAME="proc"
></A
>6.1. The /proc filesystem</H2
><P
>&#13; The /proc filesystem serves as a window through which we can see
the workings of a Linux setup. The objects of most interest for
this document are the directories<TT
CLASS="filename"
>/proc/bus/usb/</TT
> and <TT
CLASS="filename"
>/proc/scsi/</TT
>. These will be used to
verify that the kernel had been set up properly for our purpose
(<A
HREF="verifications.html#proc-probe"
>Section 7.2</A
>).
</P
></DIV
><DIV
CLASS="sect2"
><H2
CLASS="sect2"
><A
NAME="scsidev"
></A
>6.2. SCSI devices</H2
><P
>&#13; Your memory stick will be considered as a USB mass storage device
posing as a removable SCSI disk (sd). SCSI disk devices are
mapped to the <TT
CLASS="filename"
> /dev</TT
>
(devices) directory under <TT
CLASS="filename"
>&#13; /dev/sda</TT
> , <TT
CLASS="filename"
>&#13; /dev/sdb</TT
> , ... When different disk devices are present,
they will be mapped to <TT
CLASS="filename"
>/dev/sda</TT
>,
<TT
CLASS="filename"
>/dev/sdb</TT
>, etc. If, for example, a memory
stick and a digital camera are plugged in, the one would be mapped
to <TT
CLASS="filename"
>/dev/sda</TT
> and the other to
<TT
CLASS="filename"
>/dev/sdb</TT
>. Tests have indicated that the first
device to be detected is mapped to <TT
CLASS="filename"
>sda</TT
> and
represented in the directory <TT
CLASS="filename"
>/proc/scsi/usb-storage-0</TT
>. The second
will be mapped to <TT
CLASS="filename"
>sdb</TT
> and represented in
<TT
CLASS="filename"
>/proc/scsi/usb-storage-0</TT
>.
What will happen when both devices are present at boot-up, is not
known. An overview of the partitions relevant to this document,
the file <TT
CLASS="filename"
>/proc/partitions</TT
> may be consulted.
Look for entries like <TT
CLASS="filename"
>sda, sda1, sdb</TT
>. Under
the Linux-2.6 series of kernels this problem may be very neatly
resolved (<A
HREF="linux-2.6.html"
>Section 12</A
>).
</P
><P
>&#13; In the descriptions further on, it will be assumed that only one
memory stick is present, and therefore mapped to
<TT
CLASS="filename"
>/dev/sda</TT
>.
</P
><P
>&#13; In most distributions these points exist in abundance. You should
check that this is the case in your setup
(<TT
CLASS="userinput"
><B
><B
CLASS="command"
>ls</B
> /dev/sda*</B
></TT
>. If there are none you can create them by
doing (as root, indicated by the hash).
</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"
>mknod</B
> /dev/sda b 8 0</B
></TT
>
<TT
CLASS="prompt"
>#</TT
> <TT
CLASS="userinput"
><B
><B
CLASS="command"
>mknod</B
> /dev/sda1 b 8 1</B
></TT
>
<TT
CLASS="prompt"
>#</TT
> <TT
CLASS="userinput"
><B
><B
CLASS="command"
>mknod</B
> /dev/sda2 b 8 2</B
></TT
>
</PRE
></FONT
></TD
></TR
></TABLE
><P
>&#13; etc, up to <TT
CLASS="filename"
>/dev/sda15</TT
> if necessary. The
device as a whole is mapped to <TT
CLASS="filename"
>/dev/sda</TT
>,
while <TT
CLASS="filename"
>/dev/sdax (x = 1 ... 15)</TT
> represent
the various partitions of the device. We shall describe, later on,
how to create different partitions for different file systems (see
<A
HREF="ext2.html"
>Section 8</A
> and <A
HREF="mixed.html"
>Section 9</A
> ). If you
intend to use your memory stick with a single partition
(filesystem), <TT
CLASS="filename"
>/dev/sda1</TT
> is sufficient.
</P
></DIV
><DIV
CLASS="sect2"
><H2
CLASS="sect2"
><A
NAME="usbfs"
></A
>6.3. The USB device filesystem</H2
><P
>&#13; This dynamically generated filesystem should be mounted at
<TT
CLASS="filename"
>/proc/bus/usb/</TT
>. It is
therefore essential that this mount point exists. Once it is
mounted, there should be more to be seen in <TT
CLASS="filename"
>/proc/bus/usb/</TT
> and in <TT
CLASS="filename"
>/proc/scsi/</TT
> (<A
HREF="verifications.html#mounting"
>Section 7.3</A
>). To find out which USB devices are
present, read the file <TT
CLASS="filename"
>/proc/bus/usb/devices</TT
>
(<B
CLASS="command"
> less /proc/bus/usb/devices</B
>). It takes a
small effort to interpret the writing on the screen, but it is
not difficult. A memory stick is indicated by <EM
>Mass
Storage Device</EM
>.
</P
></DIV
><DIV
CLASS="sect2"
><H2
CLASS="sect2"
><A
NAME="ext2fs"
></A
>6.4. The ext2 filesystem</H2
><P
>&#13; The ext2 (second extended) filesystem still is the most prevalent
in Linux setups. It is most versatile and sophisticated, carrying
with it permissions (read-write-execute, who is permitted to do
what), ownership (user, group, others), a timestamp (when last
modified), etc. Moreover, tools for the proper maintenance of a
device endowed with ext2, exist (<A
HREF="maintain.html"
>Section 11</A
>). If
a flash memory device is to be used exclusively within Linux
setups, it is therefore desirable to format it in ext2 (see <A
HREF="ext2.html"
>Section 8</A
>).
</P
></DIV
><DIV
CLASS="sect2"
><H2
CLASS="sect2"
><A
NAME="vfatfs"
></A
>6.5. The vfat filesystem</H2
><P
>&#13; Enabling vfat in the kernel makes it possible to mount
filesystems created under Dos/Windows to be mounted in a Linux
system. Most memory sticks are formatted for direct use on
Windows and should therefore be considered as vfat-formatted. The
vfat filesystem is less sophisticated than ext2 and will
therefore be more economic as far as memory space is
concerned. It does not carry permissions in the same way as ext2
with the result that an ext2-file saved in vfat will re-appear
with its permissions changed. Nonetheless, if a memory stick is
to be used for the purpose of carrying data between Linux and
Windows machines, it is best to keep it in the vfat format. A
compromise is to partition the memory stick in two parts: one in
vfat and the other in ext2. At least the Linux machine should be
able to handle both. This is described in <A
HREF="mixed.html"
>Section 9</A
>
</P
></DIV
><DIV
CLASS="sect2"
><H2
CLASS="sect2"
><A
NAME="options"
></A
>6.6. Explanation of command options</H2
><P
>&#13; Here is a short list of command options that occur in this
document:
</P
><P
></P
><UL
COMPACT="COMPACT"
><LI
STYLE="list-style-type: none"
><SPAN
>
<TT
CLASS="userinput"
><B
><B
CLASS="command"
>mount</B
> -t ext2 /dev/sda1 /mnt/memstick</B
></TT
>
Mount in filetype ext2, device sda1 at mountpoint /mnt/memstick
</SPAN
></LI
><LI
STYLE="list-style-type: none"
><SPAN
>
<TT
CLASS="userinput"
><B
><B
CLASS="command"
>ls</B
> -l</B
></TT
>
Make a complete list (modes, ownerships, etc.)
</SPAN
></LI
><LI
STYLE="list-style-type: none"
><SPAN
>
<TT
CLASS="userinput"
><B
><B
CLASS="command"
>mkdosfs</B
> -F 32 /dev/sda1</B
></TT
>
Create an ms-dos filesystem, FAT-size 32, on the
partition /dev/sda1
</SPAN
></LI
><LI
STYLE="list-style-type: none"
><SPAN
>
<TT
CLASS="userinput"
><B
><B
CLASS="command"
>ln</B
> -s /dev/sda1 /dev/flash</B
></TT
>
link, symbolically, the existing /dev/sda1 to
the symbolic /dev/flash
</SPAN
></LI
><LI
STYLE="list-style-type: none"
><SPAN
>
<TT
CLASS="userinput"
><B
><B
CLASS="command"
>mkdir</B
> -m 777
/mnt/memstick/superdir</B
></TT
>
create a new directory with mode rwx for user, group and others
</SPAN
></LI
><LI
STYLE="list-style-type: none"
><SPAN
>
<TT
CLASS="userinput"
><B
><B
CLASS="command"
>dumpe2fs</B
> -h /dev/sda1</B
></TT
>
Show the header of the ext2 partition /dev/sda1
</SPAN
></LI
></UL
></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="hardware.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="verifications.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Hardware and kernel</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
>&nbsp;</TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Basic verifications</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>