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
|
<!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>What are filesystems?</TITLE>
<META NAME="description" CONTENT="What are filesystems?">
<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="tex2html849" HREF="node43.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="./next_motif.gif"></A> <A NAME="tex2html847" HREF="node41.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="./up_motif.gif"></A> <A NAME="tex2html841" HREF="node41.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="./previous_motif.gif"></A> <A NAME="tex2html851" HREF="node1.html"><IMG WIDTH=65 HEIGHT=24 ALIGN=BOTTOM ALT="contents" SRC="./contents_motif.gif"></A> <A NAME="tex2html852" HREF="node114.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="./index_motif.gif"></A> <BR>
<B> Next:</B> <A NAME="tex2html850" HREF="node43.html">Filesystems galore</A>
<B>Up:</B> <A NAME="tex2html848" HREF="node41.html">Filesystems</A>
<B> Previous:</B> <A NAME="tex2html842" HREF="node41.html">Filesystems</A>
<BR> <P>
<H2><A NAME="SECTION00581000000000000000">What are filesystems?</A></H2>
<P>
A <b>filesystem</b> is the methods and data structures that an
operating system uses to keep track of files on a disk or partition;
that is, the way the
files are organized on the disk. The word is also used to
refer to a partition or disk that is used to store the files
or the type of the filesystem. Thus, one might say ``I have
two filesystems'' meaning one has two partitions on which one
stores files, or that one is using the ``extended
filesystem'', meaning the type of the filesystem.
<P>
The difference between a disk or partition and the filesystem
it contains is important. A few programs (including,
reasonably enough, programs that create filesystems) operate
directly on the raw sectors of a disk or partition; if there
is an existing file system there it will be destroyed or
seriously corrupted. Most programs operate on a filesystem,
and therefore won't work on a partition that doesn't contain
one (or that contains one of the wrong type).
<P>
Before a partition or disk can be used as a filesystem, it
needs to be initialized, and the bookkeeping data structures need
to be written to the disk. This process is called
<b>making a filesystem</b>.
<P>
Most UNIX filesystem types have a similar general structure,
although the exact details vary quite a bit. The central
concepts are <b>superblock</b>, <b>inode</b>, <b>data block</b>,
<b>directory block</b>, and <b>indirection block</b>. The
superblock contains information about the filesystem as a
whole, such as its size (the exact information here depends
on the filesystem). An inode contains all information about
a file, except its name. The name is stored in the directory,
together with the number of the inode. A directory entry consists
of a filename and the number of the inode which represents the
file. The inode contains the numbers of several data blocks,
which are used to store the data in the file. There is space
only for a few data block numbers in the inode, however, and if more
are needed, more space for pointers to the data blocks is allocated
dynamically. These dynamically allocated blocks are indirect
blocks; the name indicates that in order to find the data block,
one has to find its number in the indirect block first.
<P>
UNIX filesystems usually allow one to create a <b>hole</b>
in a file (this is done with <tt>lseek</tt><A NAME="1557"> </A>; check the manual
page), which means that the filesystem just pretends that at a
particular place in the file there is just zero bytes, but no
actual disk sectors are reserved for that place in the file
(this means that the file will use a bit less disk
space). This happens especially often for small binaries, Linux
shared libraries, some databases, and a few other special cases.
(Holes are
implemented by storing a special value as the address of the
data block in the indirect block or inode. This special address
means that no data block is allocated for that part of the file,
ergo, there is a hole in the file.)
<P>
Holes are moderately useful. On the author's system, a simple
measurement showed a potential for about 4 MB of savings through
holes of about 200 MB total used disk space. That system, however,
contains relatively few programs and no database files. The
measurement tool is described in appendix <A HREF="node111.html#chapmeasureholes">A</A>.
<P>
<HR><A NAME="tex2html849" HREF="node43.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="./next_motif.gif"></A> <A NAME="tex2html847" HREF="node41.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="./up_motif.gif"></A> <A NAME="tex2html841" HREF="node41.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="./previous_motif.gif"></A> <A NAME="tex2html851" HREF="node1.html"><IMG WIDTH=65 HEIGHT=24 ALIGN=BOTTOM ALT="contents" SRC="./contents_motif.gif"></A> <A NAME="tex2html852" HREF="node114.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="./index_motif.gif"></A> <BR>
<B> Next:</B> <A NAME="tex2html850" HREF="node43.html">Filesystems galore</A>
<B>Up:</B> <A NAME="tex2html848" HREF="node41.html">Filesystems</A>
<B> Previous:</B> <A NAME="tex2html842" HREF="node41.html">Filesystems</A>
<P><ADDRESS>
<I>Lars Wirzenius <BR>
Sat Nov 15 02:32:11 EET 1997</I>
</ADDRESS>
</BODY>
</HTML>
|