1 |
neysx 05/08/18 12:59:17 |
2 |
|
3 |
Added: xml/htdocs/doc/en/articles maximum-swappage.xml |
4 |
partition-planning-tips.xml partitioning-p1.xml |
5 |
partitioning-p2.xml |
6 |
Log: |
7 |
New GuideXMLified articles from #100709, #102652 & #102666 |
8 |
|
9 |
Revision Changes Path |
10 |
1.1 xml/htdocs/doc/en/articles/maximum-swappage.xml |
11 |
|
12 |
file : http://www.gentoo.org/cgi-bin/viewcvs.cgi/xml/htdocs/doc/en/articles/maximum-swappage.xml?rev=1.1&content-type=text/x-cvsweb-markup&cvsroot=gentoo |
13 |
plain: http://www.gentoo.org/cgi-bin/viewcvs.cgi/xml/htdocs/doc/en/articles/maximum-swappage.xml?rev=1.1&content-type=text/plain&cvsroot=gentoo |
14 |
|
15 |
Index: maximum-swappage.xml |
16 |
=================================================================== |
17 |
<?xml version="1.0" encoding="UTF-8"?> |
18 |
<!DOCTYPE guide SYSTEM "/dtd/guide.dtd"> |
19 |
<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/articles/maximum-swappage.xml,v 1.1 2005/08/18 12:59:17 neysx Exp $ --> |
20 |
|
21 |
<guide link="/doc/en/articles/maximum-swappage.xml" lang="en"> |
22 |
<title>Maximum swappage</title> |
23 |
|
24 |
<author title="Author"> |
25 |
<mail link="drobbins@g.o">Daniel Robbins</mail> |
26 |
</author> |
27 |
<author title="Editor"> |
28 |
<mail link="jackdark@×××××.com">Joshua Saddler</mail> |
29 |
</author> |
30 |
|
31 |
<abstract> |
32 |
Learn how to improve the swap performance on your Linux server by several |
33 |
orders of magnitude. Author Daniel Robbins takes you through this quick tip on |
34 |
getting the most from your server. |
35 |
</abstract> |
36 |
|
37 |
<!-- The original version of this article was first published on IBM |
38 |
developerWorks, and is property of Westtech Information Services. This |
39 |
document is an updated version of the original article, and contains |
40 |
various improvements made by the Gentoo Linux Documentation team --> |
41 |
|
42 |
<version>1.0</version> |
43 |
<date>2005-08-15</date> |
44 |
|
45 |
<chapter> |
46 |
<title>Getting the most out of swap</title> |
47 |
<section> |
48 |
<body> |
49 |
|
50 |
<note> |
51 |
The original version of this article was first published on IBM developerWorks, |
52 |
and is property of Westtech Information Services. This document is an updated |
53 |
version of the original article, and contains various improvements made by the |
54 |
Gentoo Linux Documentation team. |
55 |
</note> |
56 |
|
57 |
<p> |
58 |
When you set up a brand new Linux server, do you create a single 128 MB swap |
59 |
partition? If so, did you know that you are severely limiting swap performance? |
60 |
Would you like to increase swap performance by several orders of magnitude, and |
61 |
to create swap partitions larger than 1 GB? It's possible, requiring no kernel |
62 |
patches or special hardware, just pure geek know-how! |
63 |
</p> |
64 |
|
65 |
<p> |
66 |
Some of you may not really care about swap. After all, Linux systems are |
67 |
typically very memory efficient, and swap is often barely touched. While often |
68 |
true on desktop systems, servers are another story. Because servers may handle |
69 |
unexpected stresses, such as runaway processes, denial of service attacks, or |
70 |
even the Slashdot effect, they need to have adequate high-speed swap so that |
71 |
they do not grind to a halt and possibly crash when all physical memory (and |
72 |
then some) is exhausted. |
73 |
</p> |
74 |
|
75 |
<p> |
76 |
Still not convinced that this is a big deal? I'll show you how easy it is to |
77 |
bring down a server by launching a massive amount of new processes. |
78 |
</p> |
79 |
|
80 |
<warn> |
81 |
Please, if you try this, do it only on a non-production server that you |
82 |
actually administer! |
83 |
</warn> |
84 |
|
85 |
<p> |
86 |
Let's say you have two customized <c>grep</c> commands in |
87 |
<path>/usr/bin</path>, called <c>bobgrep</c> and <c>jimgrep</c>. Now, let's |
88 |
assume that <c>bobgrep</c> is simply a shell script that calls the ELF |
89 |
executable <c>jimgrep</c>, as follows: |
90 |
</p> |
91 |
|
92 |
<pre caption="The bobgrep script"> |
93 |
#!/bin/bash |
94 |
jimgrep -r $* |
95 |
</pre> |
96 |
|
97 |
<p> |
98 |
Everything looks good so far, but what happens if <c>jimgre</c>p gets |
99 |
accidentally replaced with a symbolic link to <c>bobgrep?</c> Well, in that |
100 |
case, calling <c>bobgrep</c> or <c>jimgrep</c> will cause an infinite loop, |
101 |
causing hundreds of bash processes to be spawned in mere seconds. This actually |
102 |
happened to me once, and believe me, it hurt! |
103 |
</p> |
104 |
|
105 |
<p> |
106 |
If a server doesn't have adequate swap, a situation like this can cause the |
107 |
machine to lock up in much less than a minute. How do we fix the problem? One |
108 |
way is to increase the swap size beyond 128 MB. Fortunately for us, there is |
109 |
absolutely no 128 MB limit on swap under Linux 2.2.x+ and later kernels, as |
110 |
there was in the past. The current limits are approximately 2 GB on x86, |
111 |
PowerPC, and MC680x0 systems, 512 MB on MIPS systems, 128 GB on Alpha, and a |
112 |
whopping 3 terabytes on UltraSparc platforms! |
113 |
</p> |
114 |
|
115 |
<pre caption="Swap partition size limits under modern Linux kernels"> |
116 |
x86 2 Gigabytes |
117 |
PowerPC 2 Gigabytes |
118 |
Motorola 680x0 2 Gigabytes |
119 |
Sparc 1 Gigabyte |
120 |
MIPS 512 Megabytes |
121 |
Alpha 128 Gigabytes |
122 |
UltraSparc 3 Terabytes |
123 |
</pre> |
124 |
|
125 |
<p> |
126 |
While it's nice to be able to increase swap partition size to beyond 128 MB, |
127 |
how about increasing performance? Ideally, it would be nice if we could set up |
128 |
swap partitions in a RAID 0 stripe, so that reads and writes are equally |
129 |
distributed between all partitions. If these partitions are on separate drives |
130 |
and/or controllers, this will multiply swap file performance, allowing your |
131 |
servers to handle temporary memory usage "spikes" without getting dramatically |
132 |
bogged down. |
133 |
</p> |
134 |
|
135 |
<p> |
136 |
Amazingly, all modern Linux kernels, by default (with no special kernel options |
137 |
or patches) allow you to parallelize swap, just like a RAID 0 stripe. By using |
138 |
the <c>pri</c> option in <path>/etc/fstab</path> to set multiple swap |
139 |
partitions to the same priority, we tell Linux to use them in parallel: |
140 |
</p> |
141 |
|
142 |
<pre caption="Set multiple swap partitions to the same priority"> |
143 |
/dev/sda2 none swap sw,pri=3 0 0 |
144 |
/dev/sdb2 none swap sw,pri=3 0 0 |
145 |
/dev/sdc2 none swap sw,pri=3 0 0 |
146 |
/dev/sdd2 none swap sw,pri=1 0 0 |
147 |
</pre> |
148 |
|
149 |
<p> |
150 |
In the above example, Linux will use swap partitions sda2, sdb2, and sdc2 in |
151 |
parallel. Since these partitions are on different drives, and possibly even |
152 |
different SCSI controllers, read and write throughput will nearly triple. The |
153 |
fourth swap partition, sdd2, will be used only after the first three partitions |
154 |
have been exhausted. |
155 |
</p> |
156 |
|
157 |
<p> |
158 |
The <c>pri</c> option is really easy to use. The priority must be a number |
159 |
between 0 and 32767, with 32767 being the highest priority. The swap partitions |
160 |
will be used from highest priority to lowest priority, meaning that a partition |
161 |
with a priority of x will only be used only if all partitions with a priority |
162 |
greater than x are already full. If several partitions have the same priority, |
163 |
Linux will automatically parallelize access between them. This allows you to |
164 |
not only parallelize swap, but also prioritize access so that the partitions on |
165 |
the fastest drives (or regions of the drives) are used first. So, you can set |
166 |
up an emergency swap partition on an old, slower drive that will be used only |
167 |
if all high-speed swap is exhausted first. |
168 |
</p> |
169 |
|
170 |
<p> |
171 |
Now it's time to put some of this swapping knowledge into action. To loosely |
172 |
quote Mr. Miyagi of Karate Kid fame: "Swap on, swap off, geek-san!" |
173 |
</p> |
174 |
|
175 |
</body> |
176 |
</section> |
177 |
<section> |
178 |
<title>Resources</title> |
179 |
<body> |
180 |
|
181 |
<ul> |
182 |
<li> |
183 |
In <uri link="/doc/en/articles/partitioning-p1.xml">Partitioning in action: |
184 |
Moving /home</uri>, I show you step-by-step how to move <path>/home</path> |
185 |
to a new partition. |
186 |
</li> |
187 |
<li> |
188 |
In <uri link="/doc/en/articles/partitioning-p2.xml">Partitioning in |
189 |
action</uri>, I show you step-by-step how to move <path>/var</path> and |
190 |
<path>/tmp</path> to a new partition. |
191 |
</li> |
192 |
<li> |
193 |
In my second tip, <uri |
194 |
link="/doc/en/articles/partition-planning-tips.xml"> |
195 |
"Partition planning tips"</uri>, I share several ways of effectively |
196 |
organizing your partition layout. |
197 |
</li> |
198 |
<li> |
199 |
The <uri link="http://www.redhat.com/mirrors/LDP/LDP/sag/index.html"> Linux |
200 |
system administrator's guide</uri> mirrored on Red Hat's home page. |
201 |
</li> |
202 |
<li> |
203 |
A good high-level <uri link="http://www.gwdg.de/gs-2.0/chapter2_6.html"> |
204 |
overview of Linux system administration</uri>. |
205 |
</li> |
206 |
<li> |
207 |
For more information on optimizing file system performance, take a look at |
208 |
Linas Vepstas' <uri link="http://www.tldp.org">Linux Software RAID |
209 |
HOWTO</uri>. Since the most recent software RAID code has been merged into |
210 |
the 2.3 series kernels, it is a viable option for further enhancing Linux |
211 |
disk performance. |
212 |
</li> |
213 |
</ul> |
214 |
|
215 |
</body> |
216 |
|
217 |
|
218 |
|
219 |
1.1 xml/htdocs/doc/en/articles/partition-planning-tips.xml |
220 |
|
221 |
file : http://www.gentoo.org/cgi-bin/viewcvs.cgi/xml/htdocs/doc/en/articles/partition-planning-tips.xml?rev=1.1&content-type=text/x-cvsweb-markup&cvsroot=gentoo |
222 |
plain: http://www.gentoo.org/cgi-bin/viewcvs.cgi/xml/htdocs/doc/en/articles/partition-planning-tips.xml?rev=1.1&content-type=text/plain&cvsroot=gentoo |
223 |
|
224 |
Index: partition-planning-tips.xml |
225 |
=================================================================== |
226 |
<?xml version="1.0" encoding="UTF-8"?> |
227 |
<!DOCTYPE guide SYSTEM "/dtd/guide.dtd"> |
228 |
<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/articles/partition-planning-tips.xml,v 1.1 2005/08/18 12:59:17 neysx Exp $ --> |
229 |
|
230 |
<guide link="/doc/en/articles/partition-planning-tips.xml" lang="en"> |
231 |
<title>Partition planning tips</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 |
Organizing your partitions correctly can be fun and rewarding. This collection |
242 |
of tips will help you to use those sectors wisely. |
243 |
</abstract> |
244 |
|
245 |
<!-- The original version of this article was first published on IBM |
246 |
developerWorks, and is property of Westtech Information Services. This |
247 |
document is an updated version of the original article, and contains |
248 |
various improvements made by the Gentoo Linux Documentation team --> |
249 |
|
250 |
<version>1.0</version> |
251 |
<date>2005-08-15</date> |
252 |
|
253 |
<chapter> |
254 |
<title>How to keep things organized on disk</title> |
255 |
<section> |
256 |
<body> |
257 |
|
258 |
<note> |
259 |
The original version of this article was first published on IBM developerWorks, |
260 |
and is property of Westtech Information Services. This document is an updated |
261 |
version of the original article, and contains various improvements made by the |
262 |
Gentoo Linux Documentation team. |
263 |
</note> |
264 |
|
265 |
<p> |
266 |
Have you noticed how many new filesystems are now available for Linux these |
267 |
days? Not only ReiserFS, but also SGI's XFS and IBM's own JFS (in source form) |
268 |
are now available for Linux. What an incredible selection! And, of course, we |
269 |
also have the Coda filesystem as well as good old ext2. As usual, choice is an |
270 |
excellent thing. In this collection of tips, we'll be looking at another area |
271 |
where we have lots of freedom -- how to organize partitions on disk. Regardless |
272 |
of which new-fangled filesystem you are using, good partition layout is |
273 |
essential. Here are three tips that will help to keep things organized. |
274 |
</p> |
275 |
|
276 |
</body> |
277 |
</section> |
278 |
<section> |
279 |
<title>Don't partition the entire drive</title> |
280 |
<body> |
281 |
|
282 |
<p> |
283 |
These days, new machines often have 20 or 34 gigabytes of storage on a single |
284 |
drive. These drives are great, but they create a new problem: how exactly do |
285 |
you partition these things? Many of us can only conceive of filling up 12 GB, |
286 |
and that's if we actually tried to fill things up. |
287 |
</p> |
288 |
|
289 |
<p> |
290 |
Instead of partitioning the entire drive during installation, you may want to |
291 |
consider partitioning only the portion of the drive that you know you will |
292 |
actually use. Later, when you've figured out how to use the 22 GB of free space |
293 |
sitting at the end of your drive, you'll have a better idea of how to partition |
294 |
it. Then, you can fire up <c>fdisk</c> or <c>cfdisk</c> and create a partition |
295 |
that meets your exact needs. For now, create partitions that are large enough |
296 |
to hold your current files, plus allow for future growth. Don't worry, the free |
297 |
space at the end of your drive will still be there when you need it. |
298 |
</p> |
299 |
|
300 |
</body> |
301 |
</section> |
302 |
<section> |
303 |
<title>Partition for backups</title> |
304 |
<body> |
305 |
|
306 |
<p> |
307 |
My second organizational tip will help your backups go more smoothly. If you |
308 |
are going to regularly back up a portion of your file system tree, it's a very |
309 |
good idea to place this data on a separate partition. Why? Because many copying |
310 |
and archiving tools have a special option for not crossing partition boundaries |
311 |
(such as <c>cp</c>'s <c>-x</c> option), which will make it easy to select only |
312 |
the files you want. Also, you can select a size for this partition so that it |
313 |
is close to capacity of your backup media. That way, you'll never have to worry |
314 |
about filling up a tape, and you can monitor how close you are to filling up |
315 |
your backup media by using the <c>df</c> command to see how much space is left |
316 |
on that particular partition. Then, you can track your storage and backup needs |
317 |
and plan accordingly. |
318 |
</p> |
319 |
|
320 |
</body> |
321 |
</section> |
322 |
<section> |
323 |
<title>Partition to reduce fragmentation</title> |
324 |
<body> |
325 |
|
326 |
<p> |
327 |
At the beginning of this article, I mentioned all the fancy new journaled |
328 |
filesystems now available for Linux. Amid all the excitement, it's easy to |
329 |
forget our old friend, the ext2 filesystem. ext2 does have some drawbacks; it |
330 |
is not extremely robust, for example. However, one thing it does excel at |
331 |
(especially when compared to Microsoft's NTFS) is keeping fragmentation to a |
332 |
minimum. If you don't know, file fragmentation occurs when there is not enough |
333 |
contiguous space on a filesystem to store an entire file. The result? The file |
334 |
is broken into non-contiguous "fragments," which are stored on disk. When this |
335 |
file is accessed, the hard drive's head needs to jump all over the place to |
336 |
read in the entire file. This slows down I/O, adding additional seeks to the |
337 |
reading process. |
338 |
</p> |
339 |
|
340 |
<p> |
341 |
OK, you may ask, what's the big deal? After all, ext2 filesystems take a long |
342 |
time to exhibit signs of fragmentation. However, I would argue that |
343 |
fragmentation is still a big problem, because although ext2 does not get |
344 |
fragmented easily, fragmentation is a one-way, cumulative process. That is, |
345 |
while ext2 fragments slowly, it cannot defragment itself. In other words, any |
346 |
often-modified ext2 filesystem will gradually get more and more fragmented, and |
347 |
thus slower. Even worse, there are no production-quality ext2 filesystem |
348 |
defragmenting programs currently available. This means that fragmentation is |
349 |
guaranteed to get worse over time, and the only way to fix it is to wipe the |
350 |
filesystem clean, and restore all the original files from a backup. That's a |
351 |
pretty involved and time-consuming process. So, how can the problem of |
352 |
fragmentation be dramatically reduced and contained? I'll cover all the juicy |
353 |
details in my next tip. See you then! |
354 |
</p> |
355 |
|
356 |
</body> |
357 |
</section> |
358 |
<section> |
359 |
<title>Resources</title> |
360 |
<body> |
361 |
|
362 |
<ul> |
363 |
<li> |
364 |
In <uri link="/doc/en/articles/partitioning-p1.xml">Partitioning in action: |
365 |
Moving /home</uri>, I show you step-by-step how to move <path>/home</path> |
366 |
to a new partition. |
367 |
</li> |
368 |
<li> |
369 |
In <uri link="/doc/en/articles/partitioning-p2.xml">Partitioning in |
370 |
action</uri>, I show you step-by-step how to move <path>/var</path> and |
371 |
<path>/tmp</path> to a new partition. |
372 |
</li> |
373 |
<li> |
374 |
See <uri link="/doc/en/articles/maximum-swappage.xml">Maximum |
375 |
swappage</uri>, another tip by Daniel, where he shows how to dramatically |
376 |
increase swap performance under Linux. |
377 |
</li> |
378 |
<li> |
379 |
Check out the <uri link="http://tldp.org/docs.html#howto">howtos</uri> at |
380 |
the <uri link="http://tldp.org">Linux Documentation Project</uri>. |
381 |
</li> |
382 |
</ul> |
383 |
|
384 |
</body> |
385 |
</section> |
386 |
<section> |
387 |
<title>About the author</title> |
388 |
<body> |
389 |
|
390 |
<p> |
391 |
Daniel Robbins lives in Albuquerque, New Mexico. He was the President/CEO of |
392 |
Gentoo Technologies Inc., the Chief Architect of the Gentoo Project and is a |
393 |
contributing author of several books published by MacMillan: Caldera OpenLinux |
394 |
Unleashed, SuSE Linux Unleashed, and Samba Unleashed. Daniel has been involved |
395 |
with computers in some fashion since the second grade when he was first exposed |
396 |
to the Logo programming language and a potentially lethal dose of Pac Man. This |
397 |
probably explains why he has since served as a Lead Graphic Artist at SONY |
398 |
Electronic Publishing/Psygnosis. Daniel enjoys spending time with his wife Mary |
399 |
and his new baby daughter, Hadassah. You can contact Daniel at |
400 |
<mail>drobbins@g.o</mail>. |
401 |
</p> |
402 |
|
403 |
</body> |
404 |
</section> |
405 |
</chapter> |
406 |
</guide> |
407 |
|
408 |
|
409 |
|
410 |
1.1 xml/htdocs/doc/en/articles/partitioning-p1.xml |
411 |
|
412 |
file : http://www.gentoo.org/cgi-bin/viewcvs.cgi/xml/htdocs/doc/en/articles/partitioning-p1.xml?rev=1.1&content-type=text/x-cvsweb-markup&cvsroot=gentoo |
413 |
plain: http://www.gentoo.org/cgi-bin/viewcvs.cgi/xml/htdocs/doc/en/articles/partitioning-p1.xml?rev=1.1&content-type=text/plain&cvsroot=gentoo |
414 |
|
415 |
Index: partitioning-p1.xml |
416 |
=================================================================== |
417 |
<?xml version="1.0" encoding="UTF-8"?> |
418 |
<!DOCTYPE guide SYSTEM "/dtd/guide.dtd"> |
419 |
<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/articles/partitioning-p1.xml,v 1.1 2005/08/18 12:59:17 neysx Exp $ --> |
420 |
|
421 |
<guide link="/doc/en/articles/partitioning-p1.xml" lang="en"> |
422 |
<title>Partitioning in action, Part 1</title> |
423 |
|
424 |
<author title="Author"> |
425 |
<mail link="drobbins@g.o">Daniel Robbins</mail> |
426 |
</author> |
427 |
<author title="Editor"> |
428 |
<mail link="jackdark@×××××.com">Joshua Saddler</mail> |
429 |
</author> |
430 |
|
431 |
<abstract> |
432 |
In this new series of tips, Daniel Robbins shows you how to change partition |
433 |
layout on a running system. He'll also cover several tricks of the trade to |
434 |
minimize downtime and avoid making costly mistakes. In this particular tip, |
435 |
he'll show you how to move /home to another partition. |
436 |
</abstract> |
437 |
|
438 |
<!-- The original version of this article was first published on IBM |
439 |
developerWorks, and is property of Westtech Information Services. This |
440 |
document is an updated version of the original article, and contains |
441 |
various improvements made by the Gentoo Linux Documentation team --> |
442 |
|
443 |
<version>1.0</version> |
444 |
<date>2005-08-15</date> |
445 |
|
446 |
<chapter> |
447 |
<title>Moving /home</title> |
448 |
<section> |
449 |
<title>Introduction</title> |
450 |
<body> |
451 |
|
452 |
<note> |
453 |
The original version of this article was first published on IBM developerWorks, |
454 |
and is property of Westtech Information Services. This document is an updated |
455 |
version of the original article, and contains various improvements made by the |
456 |
Gentoo Linux Documentation team. |
457 |
</note> |
458 |
|
459 |
<p> |
460 |
The partition <path>/home</path> is one of the most-often-moved partitions. |
461 |
Sometimes, all the space in <path>/home</path> becomes exhausted, and an |
462 |
additional hard drive is required. Other times, <path>/home</path> is set up as |
463 |
part of the root partition, and it may need to be moved to improve performance |
464 |
or facilitate backup. Whatever the case, I'll show you how to move |
465 |
<path>/home</path> safely and efficiently. |
466 |
</p> |
467 |
|
468 |
<warn> |
469 |
The following technique describes how to move a partition(s). Although this |
470 |
technique is designed so that you can "back out" of a failed partition move, it |
471 |
doesn't protect against user error. In other words, any time that you format |
472 |
partitions or copy large numbers of files, there's a possibility that you will |
473 |
type the wrong thing, causing lots of data to be destroyed. For this reason, |
474 |
it's highly recommended that you <e>take appropriate steps to back up all |
475 |
critical files before proceeding</e>. |
476 |
</warn> |
477 |
|
478 |
<p> |
479 |
Now that you're prepared, we're ready to start moving <path>/home</path>. The |
480 |
exact steps you will take depend on whether <path>/home</path> currently |
481 |
resides on its own separate partition, or whether it is located on the root |
482 |
partition. Keep this in mind as we go through the steps (I'll make notes where |
483 |
necessary). Right now, if you are moving <path>/home</path> to a new hard |
484 |
drive, it should be physically installed in your system. |
485 |
</p> |
486 |
|
487 |
<p> |
488 |
If you are moving <path>/home</path> to an existing partition (it doesn't need |
489 |
to be ext2, as long as the target primary or extended partition exists), you |
490 |
can proceed to <uri link="#step2">step 2</uri>. |
491 |
</p> |
492 |
|
493 |
</body> |
494 |
</section> |
495 |
<section> |
496 |
<title>Create a new partition, if necessary</title> |
497 |
<body> |
498 |
|
499 |
<p> |
500 |
If the new partition doesn't exist yet, you'll need to create it using |
501 |
<c>cfdisk</c> (preferred) or <c>fdisk</c>. If the partition doesn't reside on |
502 |
your first drive, remember to specify the name of the device as the first |
503 |
argument to <c>cfdisk</c> or <c>fdisk</c>. After creating the appropriate |
504 |
primary or extended partition, you should reboot so that the partition table |
505 |
can be reread correctly. This is the only time you will need to reboot the |
506 |
system. |
507 |
</p> |
508 |
|
509 |
</body> |
510 |
</section> |
511 |
</chapter> |
512 |
|
513 |
<chapter id="step2"> |
514 |
<title>Create a filesystem on the new partition</title> |
515 |
<section> |
516 |
<body> |
517 |
|
518 |
<p> |
519 |
To create a filesystem on the new partition, first make sure you know the exact |
520 |
device name for the new partition (for example, <path>/dev/sda5</path>). If |
521 |
you're not sure of the exact device name, stop now and double-check! Then type |
522 |
the following, as root: |
523 |
</p> |
524 |
|
525 |
<pre caption="Creating the filesystem"> |
526 |
# <i>mkfs.ext2 /dev/???</i> |
527 |
</pre> |
528 |
|
529 |
<p> |
530 |
In the above and following code samples, <path>???</path> should be replaced |
531 |
with the target partition name. After executing this command, the target |
532 |
partition will contain an empty ext2 filesystem. |
533 |
</p> |
534 |
|
535 |
</body> |
536 |
</section> |
537 |
</chapter> |
538 |
|
539 |
<chapter> |
540 |
<title>Mount the new filesystem in /mnt</title> |
541 |
<section> |
542 |
<body> |
543 |
|
544 |
<p> |
545 |
Create a directory called <path>/mnt/newpart</path>, and then mount the new |
546 |
partition there: |
547 |
</p> |
548 |
|
549 |
<pre caption="Mounting the partition"> |
550 |
# <i>mount /dev/??? /mnt/newpart</i> |
551 |
</pre> |
552 |
|
553 |
</body> |
554 |
</section> |
555 |
</chapter> |
556 |
|
557 |
<chapter> |
558 |
<title>Drop to single-user mode</title> |
559 |
<section> |
560 |
<body> |
561 |
|
562 |
<p> |
563 |
I delayed this step as long as possible to maximize system availability, but we |
564 |
now must drop into single-user mode, and copy files from <path>/home</path> to |
565 |
<path>/mnt/newpart</path>. You shouldn't have any files open in |
566 |
<path>/home</path>, and entering single-user mode eliminates this possibility: |
567 |
</p> |
568 |
|
569 |
<pre caption="Entering single user mode"> |
570 |
# <i>init 1</i> |
571 |
</pre> |
572 |
|
573 |
<p> |
574 |
If prompted, enter the root password to perform system maintenance. You should |
575 |
now have a root shell. |
576 |
</p> |
577 |
|
578 |
</body> |
579 |
</section> |
580 |
</chapter> |
581 |
|
582 |
<chapter> |
583 |
<title>Change directories to /home and copy files</title> |
584 |
<section> |
585 |
<body> |
586 |
|
587 |
<p> |
588 |
Type the following: |
589 |
</p> |
590 |
|
591 |
<pre caption="Copying files"> |
592 |
# <i>cd /home</i> |
593 |
# <i>cp -ax * /mnt/newpart</i> |
594 |
</pre> |
595 |
|
596 |
<p> |
597 |
The <c>cp -ax</c> command recursively copies the contents of <path>/home</path> |
598 |
to <path>/mnt/newpart</path>, preserving all file attributes, and not crossing |
599 |
any mount points. After this command finishes, <path>/mnt/newpart</path> will |
600 |
contain an exact copy of all the files and directories currently in |
601 |
<path>/home</path>. If the old <path>/home</path> was on its own separate |
602 |
partition (listed on a separate line in <path>/etc/fstab</path>), go to <uri |
603 |
link="#step6a">step 6a</uri>. Otherwise, proceed to <uri link="#step6b">step |
604 |
6b</uri>. |
605 |
</p> |
606 |
|
607 |
</body> |
608 |
</section> |
609 |
</chapter> |
610 |
|
611 |
<chapter> |
612 |
<title>Use the new partition</title> |
613 |
<section id="step6a"> |
614 |
<title>6a: /home on its own partition</title> |
615 |
<body> |
616 |
|
617 |
|
618 |
|
619 |
1.1 xml/htdocs/doc/en/articles/partitioning-p2.xml |
620 |
|
621 |
file : http://www.gentoo.org/cgi-bin/viewcvs.cgi/xml/htdocs/doc/en/articles/partitioning-p2.xml?rev=1.1&content-type=text/x-cvsweb-markup&cvsroot=gentoo |
622 |
plain: http://www.gentoo.org/cgi-bin/viewcvs.cgi/xml/htdocs/doc/en/articles/partitioning-p2.xml?rev=1.1&content-type=text/plain&cvsroot=gentoo |
623 |
|
624 |
Index: partitioning-p2.xml |
625 |
=================================================================== |
626 |
<?xml version="1.0" encoding="UTF-8"?> |
627 |
<!DOCTYPE guide SYSTEM "/dtd/guide.dtd"> |
628 |
<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/articles/partitioning-p2.xml,v 1.1 2005/08/18 12:59:17 neysx Exp $ --> |
629 |
|
630 |
<guide link="/doc/en/articles/partitioning-p2.xml" lang="en"> |
631 |
<title>Partitioning in action, Part 2</title> |
632 |
|
633 |
<author title="Author"> |
634 |
<mail link="drobbins@g.o">Daniel Robbins</mail> |
635 |
</author> |
636 |
<author title="Editor"> |
637 |
<mail link="jackdark@×××××.com">Joshua Saddler</mail> |
638 |
</author> |
639 |
|
640 |
<abstract> |
641 |
In this second tip on changing partition layout on a running system, Daniel |
642 |
Robbins shows you how to move /tmp and /var to their own shared partition. He |
643 |
also covers several tricks of the trade to minimize downtime and avoid making |
644 |
costly mistakes. |
645 |
</abstract> |
646 |
|
647 |
<!-- The original version of this article was first published on IBM |
648 |
developerWorks, and is property of Westtech Information Services. This |
649 |
document is an updated version of the original article, and contains |
650 |
various improvements made by the Gentoo Linux Documentation team --> |
651 |
|
652 |
<version>1.0</version> |
653 |
<date>2005-08-15</date> |
654 |
|
655 |
<chapter> |
656 |
<title>Consolidating data</title> |
657 |
<section> |
658 |
<title>Introduction</title> |
659 |
<body> |
660 |
|
661 |
<note> |
662 |
The original version of this article was first published on IBM developerWorks, |
663 |
and is property of Westtech Information Services. This document is an updated |
664 |
version of the original article, and contains various improvements made by the |
665 |
Gentoo Linux Documentation team. |
666 |
</note> |
667 |
|
668 |
<p> |
669 |
In my <uri link="/doc/en/articles/partitioning-p1.xml">last tip</uri>, we |
670 |
successfully moved <path>/home</path> to a new partition. Now, it's time to |
671 |
learn how to consolidate often-modified files onto a new partition. Why would |
672 |
we want to do this? Here's an example. Often-modified files contribute heavily |
673 |
to fragmentation. One of the best ways to contain fragmentation is to store |
674 |
often-modified files on their own partition. That way, the other partitions are |
675 |
unaffected by the fragmentation caused by the heavily modified files. In |
676 |
concept, this is easy to understand, but how do you actually go about doing it? |
677 |
</p> |
678 |
|
679 |
<p> |
680 |
First, you must create a new partition for the specific purpose of storing |
681 |
frequently modified files. You might want to locate this partition on a |
682 |
separate disk to enhance performance. Then, I'll walk you through the steps |
683 |
required to move both <path>/tmp</path> and <path>/var</path> to this new |
684 |
partition. |
685 |
</p> |
686 |
|
687 |
<warn> |
688 |
The following technique describes how to move a partition(s). Although this |
689 |
technique is designed so that you can "back out" of a failed partition move, it |
690 |
doesn't protect against user error. In other words, any time that you format |
691 |
partitions or copy large numbers of files, there's a possibility that you will |
692 |
type the wrong thing, causing lots of data to be destroyed. For this reason, |
693 |
it's highly recommended that you <e>take appropriate steps to back up all |
694 |
critical files before proceeding</e>. |
695 |
</warn> |
696 |
|
697 |
</body> |
698 |
</section> |
699 |
<section> |
700 |
<title>Create a filesystem on the new partition</title> |
701 |
<body> |
702 |
|
703 |
<p> |
704 |
The first step of this process is to create a new partition that's big enough |
705 |
to hold <path>/var</path> and <path>/tmp</path>, with a little extra space left |
706 |
over. You'll need either an additional drive, or a spare (unused) partition |
707 |
that will house the often-modified files. If you do need to use <c>fdisk</c> or |
708 |
<c>cfdisk</c> to create the partition, you'll need to reboot once. Then, it's |
709 |
time to format the new partition as follows (it's OK to be in multiuser mode |
710 |
while you do this; I'll let you know when to switch to single-user): |
711 |
</p> |
712 |
|
713 |
<pre caption="Creating the filesystem"> |
714 |
# <i>mkfs.ext2 /dev/???</i> |
715 |
</pre> |
716 |
|
717 |
</body> |
718 |
</section> |
719 |
</chapter> |
720 |
|
721 |
<chapter> |
722 |
<title>Mount it to /mnt/rwstorage</title> |
723 |
<section> |
724 |
<body> |
725 |
|
726 |
<p> |
727 |
As in my previous tip, <path>???</path> should be replaced with the device name |
728 |
for the new, empty partition that you are creating. Accidentally typing the |
729 |
wrong name will destroy data on an existing partition, so be careful! After |
730 |
typing this command, you'll have a brand-new ext2 filesystem on the new |
731 |
partition. We're almost ready to mount it, but first, let's make a new mount |
732 |
point. |
733 |
</p> |
734 |
|
735 |
<pre caption="Creating the mount point"> |
736 |
# <i>mkdir /mnt/rwstorage</i> |
737 |
</pre> |
738 |
|
739 |
<p> |
740 |
I chose the name <path>rwstorage</path> to remind us that this particular |
741 |
partition is going to be specifically used to house files that are read from |
742 |
and written to frequently. To mount the partition, type: |
743 |
</p> |
744 |
|
745 |
<pre caption="Mounting the partition"> |
746 |
# <i>mount /dev/??? /mnt/rwstorage</i> |
747 |
</pre> |
748 |
|
749 |
</body> |
750 |
</section> |
751 |
</chapter> |
752 |
|
753 |
<chapter> |
754 |
<title>Creating a new /tmp</title> |
755 |
<section> |
756 |
<body> |
757 |
|
758 |
<p> |
759 |
The partition is now mounted and we're ready to create our new |
760 |
<path>/tmp</path> directory: |
761 |
</p> |
762 |
|
763 |
<pre caption="Creating the new /tmp"> |
764 |
# <i>cd /mnt/rwstorage</i> |
765 |
# <i>mkdir tmp</i> |
766 |
# <i>chmod 1777 tmp</i> |
767 |
</pre> |
768 |
|
769 |
</body> |
770 |
</section> |
771 |
</chapter> |
772 |
|
773 |
<chapter> |
774 |
<title>Drop to single-user mode</title> |
775 |
<section> |
776 |
<body> |
777 |
|
778 |
<p> |
779 |
Our new directory at <path>/mnt/rwstorage/tmp</path> has the right permissions |
780 |
for a temporary directory. Now, drop to single-user mode, since we must copy |
781 |
over <path>/var</path>. As usual, we've delayed our drop to single-user mode to |
782 |
the last possible moment. Right now, we don't want any programs reading or |
783 |
writing files in <path>/var</path>, so we have to stop all daemons, disconnect |
784 |
all users, and do some quick maintenance by typing: |
785 |
</p> |
786 |
|
787 |
<pre caption="Entering single-user mode"> |
788 |
# <i>init 1</i> |
789 |
</pre> |
790 |
|
791 |
<p> |
792 |
If you're prompted to enter a password to perform system maintanance, do so. |
793 |
You should now have a root shell, and all unnecessary daemons will be stopped. |
794 |
Create a new location for our <path>/var</path> files by typing: |
795 |
</p> |
796 |
|
797 |
<pre caption="Creating the new directory"> |
798 |
# <i>cd /mnt/rwstorage</i> |
799 |
# <i>mkdir var</i> |
800 |
</pre> |
801 |
|
802 |
</body> |
803 |
</section> |
804 |
</chapter> |
805 |
|
806 |
<chapter> |
807 |
<title>Copy /var</title> |
808 |
<section> |
809 |
<body> |
810 |
|
811 |
<p> |
812 |
Default permissions on our new <path>/mnt/newstorage/var</path> directory |
813 |
should be correct, so now we're ready to copy all of our original |
814 |
<path>/var</path> data over to the new partition: |
815 |
</p> |
816 |
|
817 |
<pre caption="Copying the data"> |
818 |
# <i>cd /var </i> |
819 |
# <i>cp -ax * /mnt/rwstorage/var</i> |
820 |
</pre> |
821 |
|
822 |
</body> |
823 |
</section> |
824 |
</chapter> |
825 |
|
826 |
|
827 |
|
828 |
-- |
829 |
gentoo-doc-cvs@g.o mailing list |