Upload
hailos
View
234
Download
0
Embed Size (px)
Citation preview
8/12/2019 Disk Basics Kanetkar
1/31
13 Disk Basics
The Disk Structure
The Boot Sector
The Root DirectoryLong Filenames
The Data Space
The File Allocation Table
How Fixed Disks Dier
!ne Last Thing about Disks
"ompact Disc
#rimary $olume Descriptor
The Directory Structure
The #ath Table
%xercise
447
8/12/2019 Disk Basics Kanetkar
2/31
192 Let Us C
y ar the most widely used storage mediums are the loppy
disks and ixed disks &hard disks'( Floppy disks and hard
disks come in )arious si*es and capacities but they all
work basically in the same way+inormation is magnetically
encoded on their surace in patterns( These patterns are determined
by the disk dri)e and the sotware that controls the dri)e(
B
Although the type o storage de)ice is important, it is the way the
stored inormation is laid out and managed that concerns
programmers most( -n this chapter thereore we would ocus our
attention on how inormation is organi*ed and stored on the disk(
The Disk Structure
As most o us know, the disk dri)es in D!S and .indows are
organi*ed as *ero/based dri)es( That is, dri)e A is dri)e number 0,
dri)e B is dri)e number 1, dri)e " is dri)e number 2, etc( The hard
disk dri)e can be urther partitioned into logical partitions( %ach
dri)e consists o our logical parts+Boot Sector, File AllocationTable &FAT', Directory and Data space( ! these, the Boot Sector
contains inormation about how the disk is organi*ed( That is, how
many sides does it contain, how many tracks are there on each
side, how many sectors are there per track, how many bytes are
there per sector, etc( The iles and the directories are stored in the
Data Space( The Directory contains inormation about the iles like
its attributes, name, si*e, etc( The FAT contains inormation about
where the iles and directories are stored in the data space( Figure
13(1 shows the our logical parts o a 1(44 5B disk(
8/12/2019 Disk Basics Kanetkar
3/31
Chapter 13: Disk Basics 193
Figure 13(1
.hen a ile6directory is created on the disk, instead o allocating a
sector or it, a group o sectors is allocated( This group o sectors
is oten known as a cluster(How many sectors together orm one
cluster depends upon the capacity o the disk( As the capacity goes
on increasing, so also does the maximum cluster number(
Accordingly, we ha)e 12/bit, 17/bit or 32/bit FAT( -n a 12/bit
FAT each entry is o 12 bits( Since each entry in FAT represents a
cluster number, the maximum cluster number possible in a 12/bit
FAT is 212&4087'( Similarly, in case o a 17/bit FAT the maximum
cluster number is 217 &79937'( Also, or a 32/bit FAT the
maximum cluster number is 22:&27:439497( !nly 2: o the 32 bits
are used in this FAT'( All FAT systems are not supported by all)ersions o D!S and .indows( For example, the 32/bit FAT
system is supported only in .in 89 !SR2 )ersion or later( There
are dierences in the organi*ation o contents o Boot Sector, FAT
and Directory in FAT126FAT17 system on one hand and FAT32
on the other( Some o these dierences are discussed below(
Side 0, Track 1Side 0, Track 0
10
9
2
34
1
7;
:
8
11
1213 14 19
17
1;
1:
F1F1
F1F1
F1
F1F1
F1
F2F2
F2
F1 F2
F2
F2F2F2
BS
DS
2
3
1
17
1;
1:
D
F2
D
10
947
;
:
8
11
1213 14 19
DDD
DDD
D
DD
D
D
DSD
DS
DSDS
BS / Boot Sector F1 / First copy o FATF2 / Second copy o FAT D / Root directory structureDS / Data space
8/12/2019 Disk Basics Kanetkar
4/31
194 Let Us C
The Boot Sector
The boot sector contains two parts< =Boot #arameters> and =Disk
Bootstrap #rogram>( The Boot #arameters are useul while
perorming read6write operations on the disk( Figures 13(2 and
13(3 shows the break up o the boot parameters or the 12/bit and
the17/bit FAT systems along with their typical )alues(
As you can obser)e rom Figures 13(2 and 13(3, the boot
parameters basically contain inormation indicating how the disk
has been organi*ed( Apart rom the irst 11 bytes in the list o boot
parameters, the rest orm the =B-!S #arameter Block> &B#B'(
The entry =5aximum root directory entries> indicates how many
maximum iles can we create in the root directory o the disk( -
one o these entries is a sub/directory name then there can be
se)eral more iles and sub/sub/directories within it( The =5edia
descriptor> byte indicates how the operating system reers to a
particular type o disk internally( For example, a 1(44 5B disk has
a media descriptor F0, whereas, a hard disk has a media descriptorF:(
Description Length Typical Values
?ump instruction 3 %B3"80
!%5 name : 5S.-@4(1
Bytes per sector 2 912
Sectors per cluster 1 1
Reser)ed sectors 2 1
@umber o FAT copies 1 2
5ax( Root directory entries 2 224
Total sectors 2 2::0
Continued
8/12/2019 Disk Basics Kanetkar
5/31
Chapter 13: Disk Basics 195
continued
5edia descriptor 1 F0
Sectors per FAT 2 8
Sectors per track 2 1:
@o( ! sides 2 2
Hidden sectors 4 0
Huge sectors 4 0
B-!S dri)e number 1 0
Reser)ed sectors 1 0
Boot signature 1 41
$olume -D 4 348;;:922
$olume label 11 -"-T
File system type : FAT12
Figure 13(2
Description Length Typical Values
?ump instruction 3 %B3"80
!%5 name : 5S.-@4(1
Bytes per sector 2 912
Sectors per cluster 1 74
Reser)ed sectors 2 1
@umber o FAT copies 1 2
5ax( Root directory entries 2 912Total sectors 2 0
5edia descriptor 1 F:
Sectors per FAT 2 297
8/12/2019 Disk Basics Kanetkar
6/31
196 Let Us C
Continued
continued
Sectors per track 2 73
@o( o sides 2 299
Hidden sectors 4 73
Huge sectors 4 4182802B-!S dri)e number 1 12:
Reser)ed sectors 1 1
Boot signature 1 41
$olume -D 4 40:47;;9;4
$olume label 11 -"-T
File system type : FAT17
Figure 13(3
%arlier, the B#B comprised o entries only up to the entry =Hidden
sectors> in Figure 13(2( For example, it didn>t contain the =$olume
label> o the disk( This used to get stored as a directory entry in the
directory sectors( Howe)er, now the B#B has been extended to
include entries like =$olume label, =$olume -D>, =File system
type>, etc( The B#B is now called =%xtended B#B>( .hether the
boot sector contains B#B or %xtended B#B is indicated by the
)alue o the entry =Boot signature>( - it contains a )alue 28h then
the disk has an %xtended B#B(
The =$olume -D> entry is the serial number that is recorded on the
disk while ormatting it( This is the same number that is shown
when we run the =Dir> command on the disk(
A 1(44 5B disk supports a 12/bit FAT system( The total number
o sectors on this disk is 2::0( This )alue is stored in the entry
=Total Sectors>( There is another entry in the boot parameters
called =Huge Sectors>( For a 12/bit FAT System, this entry has a
8/12/2019 Disk Basics Kanetkar
7/31
Chapter 13: Disk Basics 197)alue 0.For bigger capacity hard disks the )alue o total number
o sectors would be much more than what can be accommodated
in the 2/byte entry called =Total Sectors>( Hence or such disks this
entry contains a )alue 0 and the total number o sectors )alue is
stored in the entry =Huge Sectors>(
Let us now take a look at the 32/bit FAT system>s boot sector
contents( These are shown in Figure 13(4(
Description Length Typical Values
?ump instruction 3 %B9:80
!%5 name : 5S.-@4(1
Bytes per sector 2 912
Sectors per cluster 1 :
Reser)ed sectors 2 91
@umber o FAT copies 1 2
Root directory entries 2 0Total sectors 2 0
5edia descriptor 1 F:
Sectors per FAT 2 0
Sectors per track 2 73
@o( o sides 2 299
Hidden sectors 2 73
High word o hidden sectors 4 73
Huge sectors 4 4182802
High word o huge sectors 2 4182802
Sectors per FAT 2 4089
High word o sectors per FAT 2 4089
Dri)e description lag 2 0
File system )ersion 2 0
8/12/2019 Disk Basics Kanetkar
8/31
19 Let Us C
continued
continued
Root directory starting cluster 2 2
High word o root directory
starting cluster
2 2
File system inormation sector 2 1
Back up boot sector 2 7
Reser)ed 7 0
B-!S dri)e number 1 12:
Reser)ed 1 0
Boot signature 1 41
$olume -D 4 748:29317
$olume label 11 -"-T
File system type : FAT32
Figure 13(4
There are signiicant changes in the contents o the boo t sector o
a 32/bit FAT system( The entries =@umber o hidden sectors> and
=Huge sectors> ha)e now been made 4/byte entries( The irst two
bytes contain the low word o the )alue, whereas, the next two
bytes contain the high word )alue( The actual )alue o the entry
can be obtained by using bitwise operators that would be discussed
in "hapter 1:(
The number o sectors per FAT in a 32/bit ile system is likely toexceed what can be accommodated in two bytes( Hence the entry
=Sectors per FAT> or a disk with a 32/bit ile system would
typically ha)e a )alue 0( The )alue o =Sectors per FAT> is now
stored as a 4/byte entity, with the similar arrangement o low word
and high word as discussed earlier(
8/12/2019 Disk Basics Kanetkar
9/31
Chapter 13: Disk Basics 199The boot sector o a 32/bit FAT system also has new entries like
=Dri)e description lag>, =File system )ersion> =Starting cluster
number o the root directory>, =Sector number o the ile system
inormation sector>, and the sector number o the =Backup boot
sector>(
The =Dri)e description lag> is a two/byte entity( Bit : o this lag
indicates whether or not the inormation written to the acti)e FAT
will be written to all copies o the FAT( The low our bits o this
entry contains the 0/based FAT number o the acti)e FAT( These
bits are meaningul only i bit : is set(
-n the entry =File system )ersion number> the high byte contains
the maor )ersion number, whereas, the low byte contains the
minor )ersion number(
The entry =File system inormation sector> contains a )alue
indicating the sector number where the ile system inormation is
present( This ile system inormation consists o the ields shown
in Figure 13(9(
Description Length
File system signature 4
Total number o ree clusters 4
Sector number o the next ree cluster 4
Reser)ed 7
Figure 13(9
The entry =File inormation sector> contains a )alue !FFFFh i
there is no such sector( The entry =Backup boot sector> contains a
)alue 0FFFFh is there is no backup boot sector( !therwise this
)alue is any non/*ero )alue less than the reser)ed sector count(
8/12/2019 Disk Basics Kanetkar
10/31
2!! Let Us C
The "oot Directory
The root directory o a 1(44 5B disk containing a 12/bit FAT
system occupies 14 sectors( For other FAT systems this number
may )ary( The directory sectors contain 32/byte entries or )arious
iles6sub/directories present in the root directory( Since each entryis o 32 bytes, one directory sector can accommodate 17 such
entries( As there are 14 directory sectors on a 1(44 5B disk, there
can be a maximum o 224 entries &17 14' in the root directory(
This )alue is stored in one o the boot parameters(
%ach 32/byte entry contains either a ilename or a sub/directory
name( - it is a ile entry then it contains inormation about ile>s
name, its si*e, attributes, starting location on the disk, etc( This
inormation is organi*ed as shown is Figure 13(7(
Description Length
Filename :
%xtension 3
Attributes 1
Reser)ed 1
@umber o 10 msec inter)als in 2 seconds 1
"reation time 2
"reation date 2
Last access date 2
High word o starting cluster number 2
Last modiication time 2
Last modiication date 2
Starting cluster o ile6directory 2
File si*e 4
8/12/2019 Disk Basics Kanetkar
11/31
Chapter 13: Disk Basics 2!1
Figure 13(7
@ote the ollowing points(
&a' File name can be less than or eCual to : characters( - it is
less than : characters long then it is padded with blanks
on the right( Since .indows 89 we are permitted to use
long ile names( How these are accommodated is a 32/byte entry is discussed in the next section(
&b' %xtension or the amily name can be maximum 3
characters long( - it less than 3 characters it is padded
with blanks( .hile a ilename must ha)e at least one
character, the extension can be all blanks(
&c' -n the attribute byte each bit represents either the type o
the ile or whether the entry is a sub/directory entry( The
meaning o each bit is gi)en in Figure 13(;(
Figure 13(;
- bit 0 is set to 1 then the ile can only be read, it cannot be
modiied or deleted(
#eaningBit nu$%ers
Read !nly
; 7 9 4 3 2 1 0
( ( ( ( ( ( ( 1
( ( ( ( ( ( 1 (
( ( ( ( ( 1 ( (
( ( ( ( 1 ( ( (
( ( ( 1 ( ( ( (
( ( 1 ( ( ( ( (
( 1 ( ( ( ( ( (
1 ( ( ( ( ( ( (
Hidden
System
$olume label entry
Sub/directory entry
Archi)e bit
nused
nused
8/12/2019 Disk Basics Kanetkar
12/31
2!2 Let Us C
- bit 1 is 1 then the ile is hidden and will not be shown in the
directory( $ice )ersa, i bit 1 is 0, then the ile will be shown
in the directory as a normal ile(
- bit 2 is 1, it means the ile is an operating system ile( Bit 4
identiies the entry as a sub/directory name(
Bit 9 is called an archi)e bit( -t helps a)oid taking backups o
iles that ha)e already been backed up( !S sets the archi)e bitto 1 whene)er a ile is created or modiied( !n backing up this
ile using the BA"E# command, its archi)e bit is set to 0(
Suppose we do not modiy this ile beore we take the next
backup( So its archi)e bit would remain 0( - we now take a
backup, this ile won>t be backed up &sa)ing precious time'
since its archi)e bit is still 0( Howe)er, i we modiy the ile
beore the next backup, its archi)e bit would be set to 1 and
would now Cualiy or backing up(
&d' Following the attribute byte, there is 1 unused byte set
aside or possible uture use( All six bytes are usually setto 0(
&e' %ach directory entry maintains three dates+date o
creation, date o modiication and date o last access(
There are also entries showing time o creation or last
modiication( All these entries occupy 2 bytes each(
Suppose the date o creation o a ile is 10612688 and time
o creation is 10
8/12/2019 Disk Basics Kanetkar
13/31
Chapter 13: Disk Basics 2!3&' The starting cluster number indicates the place where the
ile begins in the data space o the disk( This ield
occupies 2 bytes in the 32/byte directory entry( -n a 32/
bit FAT system the starting cluster number is likely to be
bigger than what can be accommodated in a 2/byte entry(
Hence or 32/byte FAT system the starting cluster
number entry is broken up into two parts o two bytes
each( !ne part is stored in the =Starting cluster number>
ield( The other part is stored in the 2/byte ield
immediately ollowing the ield =Last access date>( This
ield contains the high word o the starting cluster
number(
&g' The ile si*e ield contains the exact ile si*e in bytes(
Long &ilena$es
Since the ad)ent o .indows 89 the barrier o :(3 based ilenames
has been lited( Hence now we can use ilenames like =This is my
seminar ile>( This is all right rom the point o )iew o
con)enience, but how do we accommodate such long ilenames in
a 32/byte entry .hile storing long ilenames, the name is
distributed o)er multiple 32/bytes entries( The last o these entries
contains a short ilename &alias'( For example, i the long ilename
is =AB"D%FGH-?EL5@!#RST$.IJK123497;:80(TIT>,
then out o the se)eral 32/byte entries that would be reCuired to
accommodate such a name the last entry would contain
=AB"D%F1(TIT>( Let us now understand what is present in
other entries except the last( The breakup o these entries is shown
in Figure 13(:(
Description Length
SeCuence byte 1
nicode characters o name 10
8/12/2019 Disk Basics Kanetkar
14/31
Alias or longilename
32/byte entry
2!4 Let Us C
Attributes 1
Long entry type 1
"hecksum or matching short name 1
5ore nicode characters o name 12
Reser)ed 2
5ore nicode characters o name 4
Figure 13(:
As can be seen rom Figure 13(: e)ery 32/byte entry reCuired or a
long ilename can accommodate 13 characters & &10 M 12 M 4' 6 2 '(
These characters are stored as nicode characters &in nicode
each character occupies two bytes' and not as AS"-- characters(
Thus, to accommodate ilename =AB"D%FGH-?EL5@!#
RST$.IJK123497;:80(TIT> we would need 40613, i(e( 4
entries &one more entry would be reCuired or a short ile name
&alias o the ilename'( The contents o these entries are shown in
Figure 13(8(
T FFFF FFFF
12349 7;:80' TI
@!#R ST$.I JK
AB"D% FGH-?E L5
AB"D%F1 TIT
8/12/2019 Disk Basics Kanetkar
15/31
Chapter 13: Disk Basics 2!5Figure 13(8
.hile displaying the directory containing a long ilename how
would the !S come to know o)er how many 32/bytes entries is the
ilename distributed This is simple to determine( All the entries
belonging to a long ilename would ha)e in their attribute byte a
)alue Fh( Also, all the entries belonging to this ilename would
ha)e the same check sum( -n our case, the seCuence byte o the
our directory entries reCuired or the ilename would ha)e the
)alues D, 3, 2 and 1 respecti)ely( @ote that the irst o these )alues
is obtained by bitwise !Ring it with 74(
The Data Space
All iles and sub/directories are stored in this area( -t occupies the
last and largest part o each disk( !S allocates space to iles one
cluster at a time( Remember that a cluster is nothing but a group o
sectors that !S allocates to a ile at a time( How many sectors,
orm a cluster depends upon how the disk has been ormatted(
As a ile is being created, or an existing ile is extended, the ile>s
allocated space grows( .hen more space is needed, !S allocates
another cluster or the ile(
nder ideal conditions a ile is stored under one contiguous block
o space( Howe)er, a ile might be broken into se)eral non/
contiguous blocks( This happens i inormation is added to an
existing ile or a new ile is stored in the space let by an erased
ile( So don>t be surprised i one ile is scattered throughout the
disk( This ile ragmentation slows down the access to the ile>s
contents to some degree(
The &ile (llocation Ta%le
The File Allocation Table &FAT' maps the usage o the data space
o the disk( -t contains inormation about the space used by each
8/12/2019 Disk Basics Kanetkar
16/31
2!6 Let Us C
indi)idual ile, the unused disk space and the space that is
unusable due to deects in the disk( Since FAT contains )ital
inormation, two copies o FAT are usually stored on the disk( -n
case one gets destroyed, the other can be used( A typical FAT
entry can contain any o the ollowingt mark an unused, reser)ed or
deecti)e cluster, then the cluster corresponding to the FAT entry
is part o a ile, and the )alue in the FAT entry would indicate the
next cluster in the ile(
This means that the space that belongs to a gi)en ile is mapped by
a chain o FAT entries( %ach FAT entry points to the next entry in
the chain( The irst cluster number in the chain is the starting
cluster number in the ile>s directory entry( .hen a ile is created
or extended, a cluster is allocated to the ile by searching the FAT
or unused clusters and adding them to the chain( $ice )ersa, when
a ile is deleted, the cluster that has been allocated to the ile is
reed by clearing corresponding FAT entries &by setting them to
0'( The FAT chain or a ile ends with an entry FFFFh in the FAT(
Figure 13(10 shows a FAT chain or a ile called -"-T(#RG(
8/12/2019 Disk Basics Kanetkar
17/31
Chapter 13: Disk Basics 2!7
Figure 13(10
This ile occupies cluster number 3, 9, 7 and : on the disk( Hence
the starting cluster number in the directory entry or the ile is 3(
Suppose this ile is to be loaded into memory then !S would irst
load starting cluster number+3>s contents into memory( To indout the next cluster belonging to this ile !S looks at entry number
3 in FAT where it inds a )alue 9( Thereore, now it loads the
contents o cluster number 9 into memory( !nce again !S looks at
the FAT and inds in entry number 9 a )alue 7, hence it loads the
contents o cluster 7 into memory( This process goes on till the !S
inds an entry FFFFh in FAT, which indicates that there are no
more clusters belonging to the ile( Hence the process stops(
@ow that we ha)e understood how the FAT chain is tra)ersed,
let>s dig a little deeper into the FAT( The entries present in FAT
are 12, 17 or 32 bits long depending on the storage capacity o the
disk( Though a 12/bit FAT can handle 4087 clusters only 40;:
clusters are a)ailable or use since some )alues are reser)ed(
Similarly, or a 17/bit FAT out o the possible 79937 clusters that
it can handle only 7991: are a)ailable or use(
32)%yte *irectory entry
-"-T #RG 0003
starting cluster no(
0 1 2 3 4 9 7 ; : 8 10 11
0000 0009 0000 0007 000: 0000 FFFF 0000
&(T +hain
8/12/2019 Disk Basics Kanetkar
18/31
2! Let Us C
-n a 12/bit FAT three bytes orm two entries( The irst two entries
&0 and 1' in the FAT are reser)ed or use by the !S( This means
that irst 3 bytes in a 12/bit FAT, irst 4 bytes in 17/bit FAT and
irst : bytes in a 32/bit FAT are not used or storing cluster
numbers( !ut o these 3 &or 4, or :' bytes, the irst byte is the
media descriptor byte and the balance contain the )alue FFh(
These balance bytes remain unused( The media descriptor byte
speciies the type o the disk( -t typically has a )alue FDh, F8h,
F0h, F:h or a 370 EB loppy disk, 1(2 5B loppy disk, 1(44 5B
loppy disk and a hard disk respecti)ely( The contents o a FAT
entry are interpreted as shown in Figure13(11(
Values #eaning
12)%it 16)%it 32)%it
000h 0000h 0000000h "luster a)ailable
FF0hNFF7h FFFFhNFFFF7h
FFFFFFFhNFFFFFF7h
Reser)ed cluster
FF;h FFF;h FFFFFF;h Bad cluster i not part
o chain
FF:hNFFFh FFF:hN
FFFFh
FFFFFF:hN
FFFFFFFh
Last cluster o ile
xxx xxxx xxxxxxx @ext cluster in ile
Figure 13(11
8/12/2019 Disk Basics Kanetkar
19/31
Chapter 13: Disk Basics 2!9As we saw earlier, two identical copies o FAT are maintained on
the disk( All copies are updated simultaneously whene)er iles are
modiied( - access to a FAT ails due to a read error, the !S tries
the other copy( Thus, i one copy o the FAT becomes unreadable
due to wear or a sotware accident, the other copy may still make it
possible to sal)age the iles6directories on the disk(
,o- &i.e* Disks Di//er#hysically, there is more than one platter in a ixed disk( Still, data
is organi*ed on ixed disks by track &cylinder', head, and sector
number, ust as it is on loppy disks(
Since hard disks are typically o high capacity the number o iles
stored on it are )ery high( - all these iles were stored in the root
directory then to manage these iles would become Cuite tedious(
Thereore, the iles on a hard disk are usually split into )arious
sub/directories( For example, in the root directory there could be a
sub/directory containing all "MM programs, another sub/directorycontaining all " programs, still another containing all 5S/.ord
iles, and so on( .ithin a sub/directory there can be still more sub/
directories( %ach sub/directory is linked to its parent directory,
which can be a root directory or another sub/directory, thus
orming a tree like structure, as shown in Figure 13(12
"MM programssub/directory
" programssub/directory
5S/.ord
sub/directory
Letterssub/directory
Documentssub/directory
Root directory
8/12/2019 Disk Basics Kanetkar
20/31
21! Let Us C
Figure 13(12
A sub/directory is stored in the disk>s data space, ust like any
other ile( The entries in the sub/directory are identical to those in
the root directory, except that a sub/directory is not limited in si*e(
Like an ordinary ile, a sub/directory can grow without bounds as
long as there is disk space a)ailable( Sub/directories can be created
with any type o disk( Howe)er, since sub/directories take up
precious data space, they are primarily intended or use with high/
capacity hard disksO their use with loppy disks are usually
a)oided(
Since the storage capacity o a ixed disk is relati)ely large, some
users preer to split the disk into logical parts and then store
dierent !perating Systems in dierent logical parts( This is
called partitioning o ixed disk( As many as our partitions are
allowed on a hard disk( %ach partition>s data can be kept
completely separate rom the data in the other partitions( %ach
partition can contain its own boot sector and operating system(
nlike loppy diskettes, side 0, track 0, sector 1 o the ixed disk
contains a partition table and a master boot program( The partition
table is 74 bytes long( -t contains inormation about where each
partition is located on the disk( The partition table also indicates
which is the bootable partition( - the hard disk is di)ided into two
partitions+one or D!S6.indows and another or Linux6nix(
The D!S 6 .indows partition is di)ided into Boot Sector, FAT,
Directory and Data Space, whereas, the nix partition is di)ided
into our logical parts, namely, Boot Block, Super Block, -node
Table and Data Blocks( Depending upon which partition has been
marked as bootable in the partition table that partition Boot Sectorcontents are used to boot under that partitions operating system(
0ne Last Thing a%out Disks
8/12/2019 Disk Basics Kanetkar
21/31
Chapter 13: Disk Basics 211?ust to make our lie that much more diicult, the way R!5/
B-!S reers indi)idual sector on a disk is dierent than the way
D!S6.indows reers it( The R!5/B-!S unctions reer sectors
by their three dimensional locations &side number, track number
and sector number', whereas, D!S6.indows reers them by their
seCuential logical sector numbers(
.hile using B-!S ser)ices remember that,
Tracks are numbered rom outermost track, increasing
towards the innermost track, starting with 0(
Sides are also numbered rom 0 onwards(
Sectors are numbered rom 1 onwards(
Thus any location on the disk can be reerred to by a uniCue
combination o side, track and sector number(
D!S6.indows howe)er doesn>t recogni*e sides, tracks and
sectors( -nstead, they see a disk as a linear seCuence o logical
sectors( The seCuence o logical sectors begins with the irst sector
on the disk+side 0, track 0, sector 1 &boot sector' isD!S6.indows logical sector 0( Similarly, side 0, track 0, sector 2
is D!S6.indows logical sector 1 and so on( @ote that, the last
sector in side 0, track 0 is ollowed by irst sector in side 1, track 0
and so on(
"on)ersion o a sector number rom B-!S to D!S6.indows or
)ice )ersa can be done using ollowing ormulae(
DOS/Win sector number = ( BIOS sector no - 1 ) + ( BIOS side * sectors / track )
+ ( BIOS track * sectors per track *sides per disk )
BIOS sector = ( 1 + DOS/Win sector number ) %( sectors per track )
8/12/2019 Disk Basics Kanetkar
22/31
212 Let Us C
BIOS track = ( DOS/Win sector no / ( sectors per track* sides per disk )BIOS side = ( DOS/Win sector no / sectors per track ) %( sides per disk )
+o$pact Disc
Almost e)ery concei)able orm o data is making its way to a i)e/
inch disk called compact Disc, "D in short( !ne "D is capable ostoring data eCui)alent to almost 900 loppy diskettes( A "D can
also be used to store data, photographs, music, mo)ies, etc(
There exit dierent types o "Ds( They are