517 lines
8.9 KiB
HTML
517 lines
8.9 KiB
HTML
<HTML
|
|
><HEAD
|
|
><TITLE
|
|
> Setting up an Ext2 filesystem</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="Basic verifications"
|
|
HREF="verifications.html"><LINK
|
|
REL="NEXT"
|
|
TITLE=" Setting up a dual partition"
|
|
HREF="mixed.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="verifications.html"
|
|
ACCESSKEY="P"
|
|
>Prev</A
|
|
></TD
|
|
><TD
|
|
WIDTH="80%"
|
|
ALIGN="center"
|
|
VALIGN="bottom"
|
|
></TD
|
|
><TD
|
|
WIDTH="10%"
|
|
ALIGN="right"
|
|
VALIGN="bottom"
|
|
><A
|
|
HREF="mixed.html"
|
|
ACCESSKEY="N"
|
|
>Next</A
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
><HR
|
|
ALIGN="LEFT"
|
|
WIDTH="100%"></DIV
|
|
><DIV
|
|
CLASS="sect1"
|
|
><H1
|
|
CLASS="sect1"
|
|
><A
|
|
NAME="ext2"
|
|
></A
|
|
>8. Setting up an Ext2 filesystem</H1
|
|
><P
|
|
> The procedures described here will give the entire flash memory
|
|
device a single partition endowed with the ext2 filesystem. This
|
|
will make the device more suitable for use between Linux machines.
|
|
Don't do this if the device is supposed to operate between
|
|
Linux and Windows machines.
|
|
</P
|
|
><DIV
|
|
CLASS="important"
|
|
><P
|
|
></P
|
|
><TABLE
|
|
CLASS="important"
|
|
WIDTH="100%"
|
|
BORDER="0"
|
|
><TR
|
|
><TD
|
|
WIDTH="25"
|
|
ALIGN="CENTER"
|
|
VALIGN="TOP"
|
|
><IMG
|
|
SRC="../images/important.gif"
|
|
HSPACE="5"
|
|
ALT="Important"></TD
|
|
><TD
|
|
ALIGN="LEFT"
|
|
VALIGN="TOP"
|
|
><P
|
|
> The device associated with <TT
|
|
CLASS="filename"
|
|
>/dev/sda</TT
|
|
> will be
|
|
re-formatted. Any data present on it will be destroyed. To make
|
|
sure that the device you work with is the one intended, remove
|
|
similar devices from the USB-bus before starting these procedures.
|
|
</P
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
></DIV
|
|
><DIV
|
|
CLASS="sect2"
|
|
><H2
|
|
CLASS="sect2"
|
|
><A
|
|
NAME="partition"
|
|
></A
|
|
>8.1. Partitioning</H2
|
|
><P
|
|
> It is assumed that the flash memory is mapped to <TT
|
|
CLASS="filename"
|
|
> /dev/sda</TT
|
|
>. In this section we treat the situation where
|
|
the whole flash memory device will become devoted to a single ext2
|
|
partition. In the example procedure shown below, a 128MB flash
|
|
memory was formatted for ext2. That is why figures like 131MB and
|
|
888 cylinders appear. The fdisk tool, which is used, simply reads
|
|
that from the device.
|
|
</P
|
|
><P
|
|
>
|
|
All operations are done by root. The single partition will be
|
|
created on <TT
|
|
CLASS="filename"
|
|
> /dev/sda</TT
|
|
>
|
|
(please note: not <TT
|
|
CLASS="filename"
|
|
> /dev/sda1</TT
|
|
> ) The procedure is described in a series of
|
|
steps with comments. The standard prompt of
|
|
<SPAN
|
|
CLASS="application"
|
|
>fdisk</SPAN
|
|
> is <TT
|
|
CLASS="prompt"
|
|
> Command (m for
|
|
help):</TT
|
|
> and you can, at any stage enter
|
|
<TT
|
|
CLASS="userinput"
|
|
><B
|
|
>m</B
|
|
></TT
|
|
> to see the available commands. If you do
|
|
that the result would be
|
|
</P
|
|
><TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="screen"
|
|
> Command action
|
|
a toggle a bootable flag
|
|
b edit bsd disklabel
|
|
c toggle the dos compatibility flag
|
|
d delete a partition
|
|
l list known partition types
|
|
m print this menu
|
|
n add a new partition
|
|
o create a new empty DOS partition table
|
|
p print the partition table
|
|
q quit without saving changes
|
|
s create a new empty Sun disklabel
|
|
t change a partition's system id
|
|
u change display/entry units
|
|
v verify the partition table
|
|
w write table to disk and exit
|
|
x extra functionality (experts only)
|
|
</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
><P
|
|
> Your memory stick must be plugged in, but not mounted. Take care
|
|
that write protect is off.
|
|
</P
|
|
><P
|
|
> Here goes:</P
|
|
><TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="screen"
|
|
> <TT
|
|
CLASS="prompt"
|
|
>#</TT
|
|
><TT
|
|
CLASS="userinput"
|
|
><B
|
|
><B
|
|
CLASS="command"
|
|
> fdisk</B
|
|
> /dev/sda</B
|
|
></TT
|
|
>
|
|
Command (m for help):<TT
|
|
CLASS="userinput"
|
|
><B
|
|
>d</B
|
|
></TT
|
|
> {enter }
|
|
Selected partition 1
|
|
Command (m for help):<TT
|
|
CLASS="userinput"
|
|
><B
|
|
>n</B
|
|
></TT
|
|
> {enter}
|
|
Command action
|
|
e extended
|
|
p primary partition (1-4)
|
|
<TT
|
|
CLASS="userinput"
|
|
><B
|
|
>p</B
|
|
></TT
|
|
> {enter}
|
|
Partition number (1-4):<TT
|
|
CLASS="userinput"
|
|
><B
|
|
>1</B
|
|
></TT
|
|
> {enter}
|
|
First cylinder (1-888, default 1): {press enter}
|
|
Using default value 1
|
|
Last cylinder ... (1-888, default 888): {press enter}
|
|
Using default value 888
|
|
</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
><P
|
|
>
|
|
Now is a good time to verify that all went well by printing out
|
|
the partition details and table.
|
|
</P
|
|
><TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="screen"
|
|
> Command (m for help): <TT
|
|
CLASS="userinput"
|
|
><B
|
|
>p</B
|
|
></TT
|
|
>
|
|
Disk /dev/sda: 131 MB, 131072000 bytes
|
|
9 heads, 32 sectors/track, 888 cylinders
|
|
Units = cylinders of 288 * 512 = 147456 bytes
|
|
|
|
Device Boot Start End Blocks Id System
|
|
|
|
/dev/sda1 1 888 127856 83 Linux
|
|
</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
><P
|
|
> Make sure that the partition is not set up as bootable. There
|
|
should not be an asterisk under the heading "Boot" in the
|
|
partition table. Furthermore, the headings "Id" and "System"
|
|
should be as they are in the printout shown above. That indicates
|
|
that you can format the device in ext2 (next section). These are
|
|
the defaults. If they are not, they can be changed by
|
|
</P
|
|
><TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="screen"
|
|
> Command (m for help): <TT
|
|
CLASS="userinput"
|
|
><B
|
|
>a</B
|
|
></TT
|
|
> [toggle a bootable flag]
|
|
Command (m for help): <TT
|
|
CLASS="userinput"
|
|
><B
|
|
>t</B
|
|
></TT
|
|
> [change a partition's system id]
|
|
</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
><P
|
|
>
|
|
If (or when) the partition table is correct, you can conclude the
|
|
procedure with
|
|
</P
|
|
><TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="screen"
|
|
> Command (m for help): <TT
|
|
CLASS="userinput"
|
|
><B
|
|
>w</B
|
|
></TT
|
|
> [write table to disk and exit]
|
|
</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
><P
|
|
> That's it!</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="sect2"
|
|
><H2
|
|
CLASS="sect2"
|
|
><A
|
|
NAME="making-ext2"
|
|
></A
|
|
>8.2. Making an ext2 device</H2
|
|
><P
|
|
>
|
|
Having completed the partition part, we go straight on to
|
|
"formatting" the device in ext2. For this we use the tool
|
|
mke2fs. This is straightforward.
|
|
</P
|
|
><TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="screen"
|
|
> <TT
|
|
CLASS="prompt"
|
|
>#</TT
|
|
> <TT
|
|
CLASS="userinput"
|
|
><B
|
|
><B
|
|
CLASS="command"
|
|
>mke2fs</B
|
|
> /dev/sda1</B
|
|
></TT
|
|
>
|
|
</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
><P
|
|
> You might like to watch the led on your memory stick flicker
|
|
while this is happening. When it stops, the job is done.
|
|
</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="sect2"
|
|
><H2
|
|
CLASS="sect2"
|
|
><A
|
|
NAME="tests4"
|
|
></A
|
|
>8.3. Tests -- ext2</H2
|
|
><P
|
|
>
|
|
To see if you were successful, essentially repeat the procedures
|
|
described in <A
|
|
HREF="verifications.html#mounting"
|
|
>Section 7.3</A
|
|
> and <A
|
|
HREF="verifications.html#tests"
|
|
>Section 7.4</A
|
|
>
|
|
with two exceptions of detail. In the first place the mount
|
|
command should be
|
|
</P
|
|
><TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="screen"
|
|
> <TT
|
|
CLASS="prompt"
|
|
>#</TT
|
|
> <TT
|
|
CLASS="userinput"
|
|
><B
|
|
><B
|
|
CLASS="command"
|
|
>mount</B
|
|
> -t ext2 /dev/sda1 /mnt/memstick</B
|
|
></TT
|
|
>
|
|
</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
><P
|
|
>
|
|
The second exception is that the permissions on your favourite
|
|
text file should not change anymore.
|
|
</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="verifications.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="mixed.html"
|
|
ACCESSKEY="N"
|
|
>Next</A
|
|
></TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="left"
|
|
VALIGN="top"
|
|
>Basic verifications</TD
|
|
><TD
|
|
WIDTH="34%"
|
|
ALIGN="center"
|
|
VALIGN="top"
|
|
> </TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="right"
|
|
VALIGN="top"
|
|
>Setting up a dual partition</TD
|
|
></TR
|
|
></TABLE
|
|
></DIV
|
|
></BODY
|
|
></HTML
|
|
> |