1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<!--Converted with LaTeX2HTML 96.1-h (September 30, 1996) by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University of Leeds -->
<HTML>
<HEAD>
<TITLE>Hard disks</TITLE>
<META NAME="description" CONTENT="Hard disks">
<META NAME="keywords" CONTENT="sag">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<LINK REL=STYLESHEET HREF="sag.css">
</HEAD>
<BODY LANG="EN" >
<A NAME="tex2html692" HREF="node31.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="./next_motif.gif"></A> <A NAME="tex2html690" HREF="node28.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="./up_motif.gif"></A> <A NAME="tex2html684" HREF="node29.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="./previous_motif.gif"></A> <A NAME="tex2html694" HREF="node1.html"><IMG WIDTH=65 HEIGHT=24 ALIGN=BOTTOM ALT="contents" SRC="./contents_motif.gif"></A> <A NAME="tex2html695" HREF="node114.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="./index_motif.gif"></A> <BR>
<B> Next:</B> <A NAME="tex2html693" HREF="node31.html">Floppies</A>
<B>Up:</B> <A NAME="tex2html691" HREF="node28.html">Using Disks and Other </A>
<B> Previous:</B> <A NAME="tex2html685" HREF="node29.html">Two kinds of devices</A>
<BR> <P>
<H1><A NAME="SECTION00520000000000000000">Hard disks</A></H1>
<P>
This subsection introduces terminology related to hard disks.
If you already know the terms and concepts, you can skip this
subsection.
<P>
See figure <A HREF="node30.html#fighdschematic">4.1</A> for a schematic picture of the
important parts in a hard disk. A hard disk consists of one or
more circular <b>platters</b>,<A NAME="tex2html11" HREF="footnode.html#1028"><IMG ALIGN=BOTTOM ALT="gif" SRC="./foot_motif.gif"></A> of which either or both <b>surfaces</b> are coated with a
magnetic substance used for recording the data. For each
surface, there is a <b>read-write head</b> that examines or
alters the recorded data. The platters rotate on a common axis;
a typical rotation speed is 3600 rotations per minute,
although high-performance hard disks have higher speeds. The
heads move along the radius of the platters; this movement
combined with the rotation of the platters allows the head to
access all parts of the surfaces.
<P>
The processor (CPU) and the actual disk communicate through
a <b>disk controller</b>. This relieves the rest of the computer
from knowing how to use the drive, since the controllers for
different types of disks can be made to use the same interface towards
the rest of the computer. Therefore, the computer can say just
``hey disk, gimme what I want'', instead of a long and complex
series of electric signals to move the head to the proper location
and waiting for the correct position to come under the head
and doing all the
other unpleasant stuff necessary. (In reality, the interface
to the controller is still complex, but much less so than it would
otherwise be.) The controller can also do some other stuff,
such as caching, or automatic bad sector replacement.
<P>
The above is usually all one needs to understand about the
hardware. There is also a bunch of other stuff, such as the
motor that rotates the platters and moves the heads, and the
electronics that control the operation of the mechanical
parts, but that is mostly not relevant for understanding the
working principle of a hard disk.
<P>
The surfaces are usually divided into concentric rings, called
<b>tracks</b>, and these in turn are divided into <b>sectors</b>.
This division is used to specify locations
on the hard disk and to allocate disk space to files. To find
a given place on the hard disk, one might say ``surface 3,
track 5, sector 7''. Usually the number of sectors is the
same for all tracks, but some hard disks put more sectors in
outer tracks (all sectors are of the same physical size, so
more of them fit in the longer outer tracks). Typically, a
sector will hold 512 bytes of data. The disk itself can't
handle smaller amounts of data than one sector.
<P>
<P><A NAME="1038"> </A><A NAME="fighdschematic"> </A><IMG WIDTH=367 HEIGHT=410 ALIGN=BOTTOM ALT="figure1034" SRC="img4.gif"><BR>
<STRONG>Figure 4.1:</STRONG> A schematic picture of a hard disk.<BR>
<P>
<P>
Each surface is divided into tracks (and sectors) in the same
way. This means that when the head for one surface is on a
track, the heads for the other surfaces are also on the
corresponding tracks. All the corresponding tracks taken
together are called a <b>cylinder</b>. It takes time to move
the heads from one track (cylinder) to another, so by placing
the data that is often accessed together (say, a file) so that
it is within one cylinder, it is not necessary to move the
heads to read all of it. This improves performance. It is
not always possible to place files like this; files that are
stored in several places on the disk are called <b>fragmented</b>.
<P>
The number of surfaces (or heads, which is the same thing),
cylinders, and sectors vary a lot; the specification of the
number of each is called the <b>geometry</b> of a hard disk. The
geometry is usually stored in a special, battery-powered memory
location called the <b>CMOS RAM</b>, from where the operating
system can fetch it during bootup or driver initialization.
<P>
Unfortunately, the BIOS<A NAME="tex2html12" HREF="footnode.html#1045"><IMG ALIGN=BOTTOM ALT="gif" SRC="./foot_motif.gif"></A> has a design limitation, which makes it
impossible to specify a track number that is larger than 1024 in
the CMOS RAM,
which is too little for a large hard disk. To overcome this,
the hard disk controller lies about the geometry, and
<b>translates the addresses</b> given by the computer into something
that fits reality. For example, a hard disk might have 8 heads,
2048 tracks, and 35 sectors per track<A NAME="tex2html13" HREF="footnode.html#1047"><IMG ALIGN=BOTTOM ALT="gif" SRC="./foot_motif.gif"></A>. Its controller could lie to the
computer and claim that it has 16 heads, 1024 tracks, and 35
sectors per track, thus not exceeding the limit on tracks, and
translates the address that the computer gives it by halving the
head number, and doubling the track number. The math can be
more complicated in reality, because the numbers are not as nice
as here (but again, the details are not relevant for
understanding the principle). This translation distorts the
operating system's view of how the disk is organized, thus making it
impractical to use the all-data-on-one-cylinder trick to boost
performance.
<P>
The translation is only a problem for IDE disks. SCSI disks
use a sequential sector number (i.e., the controller translates
a sequential sector number to a head, cylinder, and sector
triplet), and a completely different method for the CPU to talk
with the controller, so they are insulated from the problem.
Note, however, that the computer might not know the real geometry
of an SCSI disk either.
<P>
Since Linux often will not know the real geometry of a disk,
its filesystems don't even try to keep files within a single cylinder.
Instead, it tries to assign sequentially numbered sectors to
files, which almost always gives similar performance. The issue
is further complicated by on-controller caches, and automatic
prefetches done by the controller.
<P>
Each hard disk is represented by a separate device file.
There can (usually) be only two or four IDE hard disks.
These are known as <tt>/dev/hda</tt><A NAME="1460"> </A>, <tt>/dev/hdb</tt><A NAME="1462"> </A>,
<tt>/dev/hdc</tt><A NAME="1464"> </A>, and <tt>/dev/hdd</tt><A NAME="1466"> </A>, respectively. SCSI
hard disks are known as <tt>/dev/sda</tt><A NAME="1468"> </A>, <tt>/dev/sdb</tt><A NAME="1470"> </A>, and
so on. Similar naming conventions exist for other hard
disk types; see [<A HREF="node113.html#device-list">Anv</A>] for more information.
Note that the device files for the hard disks give access
to the entire disk, with no regard to partitions (which
will be discussed below), and it's easy to mess up the
partitions or the data in them if you aren't careful.
The disks' device files are usually used only to get
access to the master boot record (which will also be
discussed below).
<P>
<HR><A NAME="tex2html692" HREF="node31.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="./next_motif.gif"></A> <A NAME="tex2html690" HREF="node28.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="./up_motif.gif"></A> <A NAME="tex2html684" HREF="node29.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="./previous_motif.gif"></A> <A NAME="tex2html694" HREF="node1.html"><IMG WIDTH=65 HEIGHT=24 ALIGN=BOTTOM ALT="contents" SRC="./contents_motif.gif"></A> <A NAME="tex2html695" HREF="node114.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="./index_motif.gif"></A> <BR>
<B> Next:</B> <A NAME="tex2html693" HREF="node31.html">Floppies</A>
<B>Up:</B> <A NAME="tex2html691" HREF="node28.html">Using Disks and Other </A>
<B> Previous:</B> <A NAME="tex2html685" HREF="node29.html">Two kinds of devices</A>
<P><ADDRESS>
<I>Lars Wirzenius <BR>
Sat Nov 15 02:32:11 EET 1997</I>
</ADDRESS>
</BODY>
</HTML>
|