old-www/HOWTO/Partition-Mass-Storage-Defi.../x35.html

466 lines
11 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML
><HEAD
><TITLE
>Definitions</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="Partitions-Mass-Storage-Definitions-Naming-HOWTO"
HREF="index.html"><LINK
REL="PREVIOUS"
TITLE="Mass Storage Involved Here"
HREF="x24.html"><LINK
REL="NEXT"
TITLE="Drive Naming in Linux"
HREF="x99.html"></HEAD
><BODY
CLASS="section"
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"
>Partitions-Mass-Storage-Definitions-Naming-HOWTO</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="x24.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="x99.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="AEN35"
></A
>4. Definitions</H1
><DIV
CLASS="section"
><H2
CLASS="section"
><A
NAME="AEN37"
></A
>4.1. Warning</H2
><P
>Many definitions about drives are only virtual. That is
they are used, but the hardware is often quite different from
the expected description. Usually this have no odd result,
any mass storage have to be seen as a
<EM
>black box</EM
>.</P
></DIV
><DIV
CLASS="section"
><H2
CLASS="section"
><A
NAME="AEN41"
></A
>4.2. Bytes</H2
><P
>Computers counts with binaries, 1 &#38; 0,
1111100001110... To be able to read this better, humans uses
nibbles (4 bits) often shown as Hexadecimal numbers from 0 to
f (0123456789abcdef). Nibbles are usually grouped by two and
this gives a byte. The most used memory unit is byte and it's
multiples, KiB (Kilo Bytes), MiB (Mega Bytes), GiB
(Gigabytes). The "i" denotes the binary use (0ne Ki is 1024,
not 1000), the uppercase "B" denotes Bytes, not bits.</P
></DIV
><DIV
CLASS="section"
><H2
CLASS="section"
><A
NAME="AEN44"
></A
>4.3. Sectors</H2
><P
>Sometime, the word
<EM
>block</EM
>is used in place of
<EM
>sectors</EM
>.</P
><P
>Mass storage devices (at least the ones we are dealing
with here) store bytes in "Sectors" of 512 Bytes. This is
uneven, because any sector count have to be divided by two to
have the KiB number, so most partitonning software accepts
letters k (KiB), m (MiB), g... as options. Wise ones do not
make any case difference.</P
><P
>Sector size is the available byte count. The true
sector is bigger, as it have to include housekeeping data.
You don't have to worry about that.</P
><P
>Notice that as of 03-22-2006, the IDEMA annouced a new
sector size of 4kiB (4096 Bytes):
<A
HREF="http://www.idema.org/_smartsite/modules/local/data_file/show_file.php?cmd=download&#38;data_file_id=1446"
TARGET="_top"
>http://www.idema.org/_smartsite/modules/local/data_file/show_file.php?cmd=download&#38;data_file_id=1446</A
>-
doc file, can be openned with OpenOffice.org.</P
></DIV
><DIV
CLASS="section"
><H2
CLASS="section"
><A
NAME="AEN53"
></A
>4.4. Heads</H2
><P
>Rotating mass storage devices uses
<EM
>heads</EM
>. True heads are the physical
electromechanical device that writes and read the magnetic
track. Drives being made of rotating plates, the plates have
two sides, so disks can have two head by plate. Having two
plates (frequent) you have four heads.</P
><P
>Heads are writing through very complex system, see
detailed info here:
<A
HREF="http://www.spmtips.com/library/data_storage"
TARGET="_top"
>http://www.spmtips.com/library/data_storage</A
>.</P
></DIV
><DIV
CLASS="section"
><H2
CLASS="section"
><A
NAME="AEN59"
></A
>4.5. Tracks</H2
><P
>Plates are rotating. When a head is still, the plate
rotation and the width of the head are defining a
track.</P
><P
>Heads are moving from the external part of the plate to
the inner part, step by steps. Each step defines a new
track.</P
></DIV
><DIV
CLASS="section"
><H2
CLASS="section"
><A
NAME="AEN63"
></A
>4.6. Cylinders</H2
><P
>Heads are moving together, all at the same time. They
may rotate - on they own center, not the plate center, of
course. They also may have a linear move. You can see an
example of linear moving head in any cdreader, looking at the
move of the laser head. Most disks are as shown by this
wikipedia image
<A
HREF="http://upload.wikimedia.org/wikipedia/commons/thumb/5/5a/Hard_disk_platters_and_head.jpg/200px-Hard_disk_platters_and_head.jpg"
TARGET="_top"
>http://upload.wikimedia.org/wikipedia/commons/thumb/5/5a/Hard_disk_platters_and_head.jpg/200px-Hard_disk_platters_and_head.jpg</A
>.</P
><P
>When you think of all the tracks defined by each head
at the same time, you have a cylinder. So on a rotating
drive, all the tracks of the same cylinder are read or
written at the same time. The actual data is spread on all
the plates. The way the data is actually written is up to the
drive manufacturer, not the user.</P
></DIV
><DIV
CLASS="section"
><H2
CLASS="section"
><A
NAME="AEN68"
></A
>4.7. Disks</H2
><P
>Small disks are used directly as a hole bunch of
sectors. Basic programs can access data directly on sectors.
Many do (like dd or any partitionning programm).</P
><P
>But we live in a world of extremely high capacity mass
storage. Terabytes is normal nowaday (2009), when a complete
Linux system can live on a floppy (1440 bytes). So there is a
need of making several parts from a mass storage device,
though the partitions.</P
></DIV
><DIV
CLASS="section"
><H2
CLASS="section"
><A
NAME="AEN72"
></A
>4.8. Partitions</H2
><P
>Partitioning is a means to divide a single drive into
many logical drives. A partition is a contiguous set of
sectors. To lessen the heads travel, partitions can be
"aligned" on the cylinder size, that is use an integer number
of cylinder. This is not always done, but should as it have
many other advantages for recovery.</P
></DIV
><DIV
CLASS="section"
><H2
CLASS="section"
><A
NAME="AEN75"
></A
>4.9. Partition Table</H2
><P
>As you can have many partitions, you need to have a
partition table. This partition table is stored in the very
beginning of the drive. It's very unlikely that you will have
to change this table directly writing bytes with an
hexadecimal editor, so we wont say more on the position of
the table.</P
><P
>There are many Operating Systems all around that all
share similar hardware and as many partition systems. We will
look only at what one can find in a PC, even if it's not easy
to define that nowaday. Say, for us, a PC is any computer
able to run Linux (I know, it's not always true).</P
><P
>Each of these partition kinds are noted in the table by
a special flag called "type" ("t" in fdisk). Most known are
type 83 for Linux partitions and 82 for Linux swap (hex
numbers).</P
><P
>Notice that most Operating Systems can share partition
tables. At least, if a disk is hardware compatible with
several systems, these systems should be able to see what the
others have done, not to erase a drive by accident. I can't
say for sure that its true in the real life.</P
></DIV
><DIV
CLASS="section"
><H2
CLASS="section"
><A
NAME="AEN81"
></A
>4.10. File Systems</H2
><P
>Partitions can be accessed directly as sectors, as any
part of the disk, but are usually filled with a
<STRONG
>file system</STRONG
>. File system
and partitions are related only because a file system is in a
partition, but that's all. You can have a disk without
partition but with a file system or have partitions without
file system (the swap partition beeing the most well known).
For details on file systems,
<A
HREF="http://en.wikipedia.org/wiki/File_system"
TARGET="_top"
>see
Wikipedia</A
>.</P
><P
>In summary, file systems allow storing data in files
with human readable names and to sort the files in a friendly
way, for example as directories, subdirectories, text,
images...</P
></DIV
><DIV
CLASS="section"
><H2
CLASS="section"
><A
NAME="AEN87"
></A
>4.11. Files and Nodes</H2
><P
>Nearly all what you can find on a mass storage
partition, beside sectors, from an user point of view, is a
file. But computers are curious geeks and you can treat files
like disks if you want. Using the "loop" system, default in
most Linux kernels, one can partition the inside of the file,
create file systems on it and mount it. This is specially
handy for experiments.</P
><P
>Some of these files are
<EM
>devices</EM
>or
<EM
>nodes</EM
>. Partitions are not files and are
accessed via special nodes we will see later. These nodes are
not created by touch but by
<EM
>mknode</EM
>. Use with caution. Nodes need a
type (
<EM
>c</EM
>for "character" or "b" for
<EM
>block</EM
>) and major and minor numbers. For
what we need, major numbers are disk numbers and minor
numbers are partition numbers. The list is visible in
/proc/partitions</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="screen"
>&#13; cat /proc/partitions
major minor #blocks name
8 0 488386584 sda
8 1 52436128 sda1
8 2 1 sda2
8 5 2104483 sda5
8 6 20972826 sda6
8 7 52436128 sda7
8 8 360434308 sda8
</PRE
></FONT
></TD
></TR
></TABLE
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="screen"
>&#13; #mknod b 8 9 /dev/sda9
</PRE
></FONT
></TD
></TR
></TABLE
><P
>Creates a /dev/sda9 node of no nuse, given this don't
create partition, only the node. In a usual Linux
distribution, nodes are dynamically created at boot time, so
nobody should have to do so. However, sometime the automatic
system fails.</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="x24.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="x99.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Mass Storage Involved Here</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
>&nbsp;</TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Drive Naming in Linux</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>