Gentoo Archives: gentoo-doc-cvs

From: Xavier Neys <neysx@×××××××××××.org>
To: gentoo-doc-cvs@l.g.o
Subject: [gentoo-doc-cvs] cvs commit: afig-ct-ext3-intro.xml
Date: Sun, 21 Aug 2005 22:23:59
Message-Id: 200508212223.j7LMNA5v001078@robin.gentoo.org
1 neysx 05/08/21 22:23:44
2
3 Added: xml/htdocs/doc/en/articles afig-ct-ext3-intro.xml
4 prompt-magic.xml
5 Log:
6 #103211 & #101920, GuideXMLified articles
7
8 Revision Changes Path
9 1.1 xml/htdocs/doc/en/articles/afig-ct-ext3-intro.xml
10
11 file : http://www.gentoo.org/cgi-bin/viewcvs.cgi/xml/htdocs/doc/en/articles/afig-ct-ext3-intro.xml?rev=1.1&content-type=text/x-cvsweb-markup&cvsroot=gentoo
12 plain: http://www.gentoo.org/cgi-bin/viewcvs.cgi/xml/htdocs/doc/en/articles/afig-ct-ext3-intro.xml?rev=1.1&content-type=text/plain&cvsroot=gentoo
13
14 Index: afig-ct-ext3-intro.xml
15 ===================================================================
16 <?xml version='1.0' encoding='UTF-8'?>
17 <!DOCTYPE guide SYSTEM "/dtd/guide.dtd">
18
19 <guide link="/doc/en/articles/afig-p7.xml">
20
21 <title>Advanced Filesystem Implementor's Guide : Introducing ext3</title>
22
23 <author title="Author">
24 <mail link="drobbins@g.o">Daniel Robbins</mail>
25 </author>
26 <author title="Editor">
27 <mail link=" dhaskew@×××××××××.net">David H. Askew</mail>
28 </author>
29
30 <!-- The original version of this article was first published on IBM
31 developerWorks, and is property of Westtech Information Services. This
32 document is an updated version of the original article, and contains
33 various improvements made by the Gentoo Linux Documentation team -->
34
35 <abstract>
36 With the 2.4 release of Linux come a host of new filesystem possibilities,
37 including Reiserfs, XFS, GFS, and others. These filesystems sound cool, but
38 what exactly can they do, what are they good at, and exactly how do you go
39 about safely using them in a production Linux environment? Daniel Robbins
40 answers these questions by showing you how to set up these new advanced
41 filesystems under Linux 2.4. In this installment, Daniel takes a look at ext3,
42 a new improved version of ext2 with journaling capabilities.
43 </abstract>
44
45 <version>1.0</version>
46 <date>2005-08-13</date>
47
48 <chapter>
49 <title>Introduction</title>
50 <section>
51 <body>
52
53 <note>
54 The original version of this article was first published on IBM developerWorks,
55 and is property of Westtech Information Services. This document is an updated
56 version of the original article, and contains various improvements made by the
57 Gentoo Linux Documentation team.
58 </note>
59
60 <p>
61 In the past few installments, we've taken a bit of a detour by looking at
62 non-traditional filesystems such as tmpfs and devfs. Now, it's time to get back
63 to disk-based filesystems, and we do this by taking a look at ext3. The ext3
64 filesystem, designed by Dr. Stephen Tweedie, is built on the framework of the
65 existing ext2 filesystem; in fact, ext3 is very similar to ext2 except for one
66 small (but important) difference -- it supports journaling. Yet even with this
67 small addition, I think you'll find that that ext3 has several surprising and
68 intriguing capabilities. In this article, I'll give you a good understanding
69 of how ext3 compares to the other journaling filesystems currently available.
70 In my next article, we'll get ext3 up and running.
71 </p>
72
73 </body>
74 </section>
75 </chapter>
76
77 <chapter>
78 <title>Understanding Ext3</title>
79 <section>
80 <body>
81
82 <p>
83 So, how does ext3 compare to ReiserFS? In previous articles, I explained how
84 ReiserFS is well suited to handling small files (under 4K), and in certain
85 situations, ReiserFS' small file performance is ten to fifteen times greater
86 than that of ext2 and ext3. However, while ReiserFS has many strengths, it also
87 has weaknesses. In the current implementation of ReiserFS (version 3.6),
88 certain file access patterns can actually result in significantly worse
89 performance than ext2 and ext3, particularly when reading large mail
90 directories. Also, ReiserFS doesn't have a good track record of NFS
91 compatibility and has poor sparse file performance. In contrast, ext3 is a very
92 well-rounded filesystem. It's a lot like ext2; it's not going to give you the
93 blazingly fast small-file performance that ReiserFS gives you, but it's not
94 going to give you any unexpected performance or functionality hiccups either.
95 </p>
96
97 <p>
98 One of the nice things about ext3 is that because it is based on the ext2 code,
99 ext2 and ext3's on-disk format is identical; this means that a cleanly
100 unmounted ext3 filesystem can be remounted as an ext2 filesystem with
101 absolutely no problems. And that's not all. Thanks to the fact that ext2 and
102 ext3 use identical metadata, it's possible to perform in-place ext2 to ext3
103 filesystem upgrades. Yes, you read that right. By upgrading a few key system
104 utilities, installing a modern 2.4 kernel and typing in a single tune2fs
105 command per filesystem, you can convert your existing ext2 servers into
106 journaling ext3 systems. You can even do this while your ext2 filesystems are
107 mounted. The transition is safe, reversible, and incredibly easy, and unlike a
108 conversion to XFS, JFS, or ReiserFS, you don't need to back up and recreate
109 your filesystems from scratch. Now, for a moment, consider the thousands of
110 production ext2 servers in existence that are just minutes away from an ext3
111 upgrade; then, you'll have a good grasp of ext3's importance to the Linux
112 community.
113 </p>
114
115 <p>
116 If I had to describe ext3 in one word, I'd call it "comfortable". It's
117 incredibly easy to ext3-enable an existing ext2 system, and after you do,
118 you're not going to run into any unexpected performance quirks. And there's yet
119 another way that ext3 excels in the comfort department; ext3 happens to be one
120 of the most reliable journaled filesystems available for Linux, as I explain
121 below.
122 </p>
123
124 </body>
125 </section>
126 </chapter>
127
128 <chapter>
129 <title>Ext3 reliability</title>
130
131 <section>
132 <body>
133
134 <p>
135 In addition to being ext2-compatible, ext3 inherits other benefits by sharing
136 ext2's metadata format. For one, ext3 users gain access to a rock-solid fsck
137 tool. You'll recall that one of the points of using a journaling filesystem is
138 to avoid the need for an exhaustive fsck in the first place; however if you do
139 end up getting corrupt metadata, either from a flaky kernel, bad hard drive, or
140 something else, you'll greatly appreciate the fact that ext3 inherits ext2's
141 fsck. In contrast, ReiserFS' fsck is in its infancy, and fixing flaky metadata
142 when it does show up can be a difficult and dangerous process.
143 </p>
144
145 </body>
146 </section>
147
148 <section>
149 <title>Metadata-only journaling</title>
150 <body>
151
152 <p>
153 Interestingly, ext3 handles journaling very differently than ReiserFS and other
154 journaling filesystems do. With ReiserFS, XFS, and JFS, the filesystem driver
155 journals metadata, but makes no provisions for journaling data. With
156 metadata-only journaling, your filesystem metadata is going to be rock solid,
157 and you will probably never need to perform an exhaustive fsck. However,
158 unexpected reboots and system lock-ups can result in significant corruption of
159 recently-modified data. Ext3 uses a couple of innovative solutions to avoid
160 these problems, which we'll look at in a bit.
161 </p>
162
163 <p>
164 But first, it's important to understand exactly how metadata-only journaling
165 could end up biting you. As an example, let's say that you were modifying a
166 file called /tmp/myfile.txt when the machine unexpectedly locked up, forcing a
167 reboot. If you were using a metadata-only journaling filesystem such as
168 ReiserFS, XFS or JFS, your filesystem metadata would be easily repaired, thanks
169 to the metadata journal, and you wouldn't need to sit through a laborious fsck.
170 </p>
171
172 <p>
173 However, there's the distinct possibility that when you load /tmp/myfile.txt
174 into a text editor, your file will not simply be missing recent changes, but
175 will contain a good amount of garbage and may even be completely unreadable.
176 This isn't something that will always happen, but it could happen and often
177 does.
178 </p>
179
180 <p>
181 Here's why. Typical journaled filesystems like ReiserFS, XFS, and JFS take
182 extra special care of metadata, but don't pay too much attention to data. In
183 our above example, the filesystem driver was in the process of modifying
184 several filesystem blocks. The filesystem driver updated the appropriate
185 metadata, but didn't have time to flush the data from its caches to the new
186 blocks on disk. Thus, when you loaded up /tmp/myfile.txt into a text editor,
187 part or all of the file contained garbage -- blocks of data that didn't get
188 initialized in time before the system locked up.
189 </p>
190
191 </body>
192 </section>
193
194 </chapter>
195
196 <chapter>
197 <title>The ext3 approach</title>
198 <section>
199 <body>
200
201 <p>
202 Now that we have a good general understanding of this problem, let's look how
203 ext3 implements journaling. In ext3, the journaling code uses a special API
204 called the Journaling Block Device layer, or JBD. The JBD has been designed for
205 the express purpose of implementing a journal on any kind of block device.
206 Ext3 implements its journaling by "hooking in" to the JBD API. For example, the
207 ext3 filesystem code will inform the JBD of modifications it is performing, and
208 will also request permission from the JBD before modifying certain data on
209 disk. By doing so, the JBD is given the appropriate opportunities to manage the
210 journal on behalf of the ext3 filesystem driver. It's quite a nice
211 arrangement, and because the JBD is being developed as a separate, generic
212 entity, it could be used to add journaling capabilities to other filesystems in
213 the future.
214 </p>
215
216
217
218 1.1 xml/htdocs/doc/en/articles/prompt-magic.xml
219
220 file : http://www.gentoo.org/cgi-bin/viewcvs.cgi/xml/htdocs/doc/en/articles/prompt-magic.xml?rev=1.1&content-type=text/x-cvsweb-markup&cvsroot=gentoo
221 plain: http://www.gentoo.org/cgi-bin/viewcvs.cgi/xml/htdocs/doc/en/articles/prompt-magic.xml?rev=1.1&content-type=text/plain&cvsroot=gentoo
222
223 Index: prompt-magic.xml
224 ===================================================================
225 <?xml version="1.0" encoding="UTF-8"?>
226 <!DOCTYPE guide SYSTEM "/dtd/guide.dtd">
227 <!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/articles/prompt-magic.xml,v 1.1 2005/08/21 22:23:44 neysx Exp $ -->
228
229 <guide link="/doc/en/articles/prompt-magic.xml" lang="en">
230
231 <title>Prompt magic</title>
232
233 <author title="Author">
234 <mail link="drobbins@g.o">Daniel Robbins</mail>
235 </author>
236 <author title="Editor">
237 <mail link="jackdark@×××××.com">Joshua Saddler</mail>
238 </author>
239
240 <abstract>
241 Why stick with the standard boring shell prompt when you can easily make it
242 colorful and more informative? In this tip, Daniel Robbins will show you how to
243 get your shell prompt just the way you like it, as well as how to dynamically
244 update your X terminal's title bar.
245 </abstract>
246
247 <!-- The original version of this article was first published on IBM
248 developerWorks, and is property of Westtech Information Services. This
249 document is an updated version of the original article, and contains
250 various improvements made by the Gentoo Linux Documentation team -->
251
252 <version>1.0</version>
253 <date>2005-08-21</date>
254
255 <chapter>
256 <title>Enhancing the system prompt</title>
257 <section>
258 <body>
259
260 <note>
261 The original version of this article was first published on IBM developerWorks,
262 and is property of Westtech Information Services. This document is an updated
263 version of the original article, and contains various improvements made by the
264 Gentoo Linux Documentation team.
265 </note>
266
267 <p>
268 As Linux/UNIX people, we spend a lot of time working in the shell, and in many
269 cases, this is what we have staring back at us:
270 </p>
271
272 <pre caption="The normal user prompt">
273 bash-2.04$
274 </pre>
275
276 <p>
277 If you happen to be root, you're entitled to the "prestige" version of this
278 beautiful prompt:
279 </p>
280
281 <pre caption="The root prompt">
282 bash-2.04#
283 </pre>
284
285 <p>
286 These prompts are not exactly pretty. It's no wonder that several Linux
287 distributions have upgraded their default prompts that add color and additional
288 information to boot. However, even if you happen to have a modern distribution
289 that comes with a nice, colorful prompt, it may not be perfect. Maybe you'd
290 like to add or change some colors, or add (or remove) information from the
291 prompt itself. It isn't hard to design your own colorized, tricked-out prompt
292 from scratch.
293 </p>
294
295 </body>
296 </section>
297 <section>
298 <title>Prompt basics</title>
299 <body>
300
301 <p>
302 Under bash, you can set your prompt by changing the value of the <c>PS1</c>
303 environment variable, as follows:
304 </p>
305
306 <pre caption="Altering the environment variable">
307 $ <i>export PS1="> "</i>
308 >
309 </pre>
310
311 <p>
312 Changes take effect immediately, and can be made permanent by placing the
313 <c>export</c> definition in your <path>~/.bashrc</path> file. <c>PS1</c> can
314 contain any amount of plain text that you'd like:
315 </p>
316
317 <pre caption="A custom prompt">
318 $ <i>export PS1="This is my super prompt > "</i>
319 This is my super prompt >
320 </pre>
321
322 <p>
323 While this is, um, interesting, it's not exactly useful to have a prompt that
324 contains lots of static text. Most custom prompts contain information like the
325 current username, working directory, or hostname. These tidbits of information
326 can help you to navigate in your shell universe. For example, the following
327 prompt will display your username and hostname:
328 </p>
329
330 <pre caption="A more useful prompt">
331 $ <i>export PS1="\u@\H > "</i>
332 drobbins@freebox >
333 </pre>
334
335 <p>
336 This prompt is especially handy for people who log in to various machines under
337 various differently-named accounts, since it acts as a reminder of what machine
338 you're actually on and what privileges you currently have.
339 </p>
340
341 <p>
342 In the above example, we told bash to insert the username and hostname into the
343 prompt by using special backslash-escaped character sequences that bash
344 replaces with specific values when they appear in the <c>PS1</c> variable. We
345 used the sequences <c>\u</c> (for username) and <c>\H</c> (for the first part
346 of the hostname). Here's a complete list of all special sequences that bash
347 recognizes (you can find this list in the bash man page, in the "PROMPTING"
348 section):
349 </p>
350
351 <table>
352 <tr>
353 <th>Sequence</th>
354 <th>Description</th>
355 </tr>
356 <tr>
357 <ti>\a</ti>
358 <ti>The ASCII bell character (you can also type <c>\007</c>)</ti>
359 </tr>
360 <tr>
361 <ti>\d</ti>
362 <ti>Date in "Wed Sep 06" format</ti>
363 </tr>
364 <tr>
365 <ti>\e</ti>
366 <ti>ASCII escape character (you can also type <c>\033</c>)</ti>
367 </tr>
368 <tr>
369 <ti>\h</ti>
370 <ti>First part of hostname (such as "mybox")</ti>
371 </tr>
372 <tr>
373 <ti>\H</ti>
374 <ti>Full hostname (such as "mybox.mydomain.com")</ti>
375 </tr>
376 <tr>
377 <ti>\j</ti>
378 <ti>
379 The number of processes you've suspended in this shell by hitting <c>^Z</c>
380 </ti>
381 </tr>
382 <tr>
383 <ti>\l</ti>
384 <ti>The name of the shell's terminal device (such as "ttyp4")</ti>
385 </tr>
386 <tr>
387 <ti>\n</ti>
388 <ti>Newline</ti>
389 </tr>
390 <tr>
391 <ti>\r</ti>
392 <ti>Carriage return</ti>
393 </tr>
394 <tr>
395 <ti>\s</ti>
396 <ti>The name of the shell executable (such as "bash")</ti>
397 </tr>
398 <tr>
399 <ti>\t</ti>
400 <ti>Time in 24-hour format (such as "23:01:01")</ti>
401 </tr>
402 <tr>
403 <ti>\T</ti>
404 <ti>Time in 12-hour format (such as "11:01:01")</ti>
405 </tr>
406 <tr>
407 <ti>\@</ti>
408 <ti>Time in 12-hour format with am/pm</ti>
409 </tr>
410 <tr>
411 <ti>\u</ti>
412 <ti>Your username</ti>
413 </tr>
414 <tr>
415 <ti>\v</ti>
416 <ti>Version of bash (such as 2.04)</ti>
417 </tr>
418 <tr>
419 <ti>\V</ti>
420 <ti>Bash version, including patchlevel</ti>
421 </tr>
422 <tr>
423 <ti>\w</ti>
424
425
426
427 --
428 gentoo-doc-cvs@g.o mailing list