1 |
<?xml version='1.0' encoding='UTF-8'?> |
2 |
<!DOCTYPE sections SYSTEM "/dtd/book.dtd"> |
3 |
|
4 |
<!-- The content of this document is licensed under the CC-BY-SA license --> |
5 |
<!-- See http://creativecommons.org/licenses/by-sa/1.0 --> |
6 |
|
7 |
<!-- $Header: /home/cvsroot/gentoo/xml/htdocs/doc/en/handbook/hb-install-ppc-disk.xml,v 1.2 2004/04/02 22:15:29 neysx Exp $ --> |
8 |
|
9 |
<sections> |
10 |
<section> |
11 |
<title>Introduction to Block Devices</title> |
12 |
<subsection> |
13 |
<title>Block Devices</title> |
14 |
<body> |
15 |
|
16 |
<p> |
17 |
We'll take a good look at disk-oriented aspects of Gentoo Linux |
18 |
and Linux in general, including Linux filesystems, partitions and block devices. |
19 |
Then, once you're familiar with the ins and outs of disks and filesystems, |
20 |
you'll be guided through the process of setting up partitions and filesystems |
21 |
for your Gentoo Linux installation. |
22 |
</p> |
23 |
|
24 |
<p> |
25 |
To begin, we'll introduce <e>block devices</e>. The most famous block device is |
26 |
probably the one that represents the first IDE drive in a Linux system, namely |
27 |
<path>/dev/hda</path>. If your system uses SCSI drives, then your first hard |
28 |
drive would be <path>/dev/sda</path>. |
29 |
</p> |
30 |
|
31 |
<p> |
32 |
The block devices above represent an abstract interface to the disk. User |
33 |
programs can use these block devices to interact with your disk without worrying |
34 |
about whether your drives are IDE, SCSI or something else. The program can |
35 |
simply address the storage on the disk as a bunch of contiguous, |
36 |
randomly-accessible 512-byte blocks. |
37 |
</p> |
38 |
|
39 |
</body> |
40 |
</subsection> |
41 |
<subsection> |
42 |
<title>Partitions and Slices</title> |
43 |
<body> |
44 |
|
45 |
<p> |
46 |
Although it is theoretically possible to use a full disk to house your Linux |
47 |
system, this is almost never done in practice. Instead, full disk block devices |
48 |
are split up in smaller, more manageable block devices. On most systems, |
49 |
these are called <e>partitions</e>. Other architectures use a similar technique, |
50 |
called <e>slices</e>. |
51 |
</p> |
52 |
|
53 |
</body> |
54 |
</subsection> |
55 |
</section> |
56 |
<section> |
57 |
<title>Designing a Partitioning Scheme</title> |
58 |
<subsection> |
59 |
<title>Default Partitioning Scheme</title> |
60 |
<body> |
61 |
|
62 |
<p> |
63 |
If you are not interested in drawing up a partitioning scheme for your system, |
64 |
you can use the partitioning scheme we use throughout this book: |
65 |
</p> |
66 |
|
67 |
<table> |
68 |
<tr> |
69 |
<th>Partition NewWorld</th> |
70 |
<th>Partition OldWorld</th> |
71 |
<th>Filesystem</th> |
72 |
<th>Size</th> |
73 |
<th>Description</th> |
74 |
</tr> |
75 |
<tr> |
76 |
<ti><path>/dev/hda1</path></ti> |
77 |
<ti>(Not needed)</ti> |
78 |
<ti>(bootstrap)</ti> |
79 |
<ti>800k</ti> |
80 |
<ti>Apple_Bootstrap</ti> |
81 |
</tr> |
82 |
<tr> |
83 |
<ti><path>/dev/hda2</path></ti> |
84 |
<ti><path>/dev/hda1</path></ti> |
85 |
<ti>(swap)</ti> |
86 |
<ti>512M</ti> |
87 |
<ti>Swap partition</ti> |
88 |
</tr> |
89 |
<tr> |
90 |
<ti><path>/dev/hda3</path></ti> |
91 |
<ti><path>/dev/hda2</path></ti> |
92 |
<ti>ext3</ti> |
93 |
<ti>Rest of the disk</ti> |
94 |
<ti>Root partition</ti> |
95 |
</tr> |
96 |
</table> |
97 |
|
98 |
<p> |
99 |
If you are interested in knowing how big a partition should be, or even how |
100 |
many partitions you need, read on. Otherwise continue now with |
101 |
<uri link="#fdisk">Using fdisk to Partition your Disk</uri>. |
102 |
</p> |
103 |
|
104 |
</body> |
105 |
</subsection> |
106 |
<subsection> |
107 |
<title>How Many and How Big?</title> |
108 |
<body> |
109 |
|
110 |
<p> |
111 |
The number of partitions is highly dependent on your environment. For instance, |
112 |
if you have lots of users, you will most likely want to have your |
113 |
<path>/home</path> separate as it increases security and makes backups easier. |
114 |
If you are installing Gentoo to perform as a mailserver, your |
115 |
<path>/var</path> should be separate as all mails are stored inside |
116 |
<path>/var</path>. A good choice of filesystem will then maximise your |
117 |
performance. Gameservers will have a separate <path>/opt</path> as most gaming |
118 |
servers are installed there. The reason is similar for <path>/home</path>: |
119 |
security and backups. |
120 |
</p> |
121 |
|
122 |
<p> |
123 |
As you can see, it very much depends on what you want to achieve. Separate |
124 |
partitions or volumes have the following advantages: |
125 |
</p> |
126 |
|
127 |
<ul> |
128 |
<li> |
129 |
You can choose the most performant filesystem for each partition or volume |
130 |
</li> |
131 |
<li> |
132 |
Your entire system cannot run out of free space if one defunct tool is |
133 |
continuously writing files to a partition or volume |
134 |
</li> |
135 |
<li> |
136 |
If necessary, file system checks are reduced in time, as multiple checks can |
137 |
be done in parallel (although this advantage is more with multiple disks than |
138 |
it is with multiple partitions) |
139 |
</li> |
140 |
<li> |
141 |
Security can be enhanced by mounting some partitions or volumes read-only, |
142 |
nosuid (setuid bits are ignored), noexec (executable bits are ignored) etc. |
143 |
</li> |
144 |
</ul> |
145 |
|
146 |
<p> |
147 |
However, multiple partitions have one big disadvantage: if not configured |
148 |
properly, you might result in having a system with lots |
149 |
of free space on one partition and none on another. |
150 |
</p> |
151 |
|
152 |
</body> |
153 |
</subsection> |
154 |
</section> |
155 |
<section id="fdisk"> |
156 |
<title>Using mac-fdisk on PPC to Partition your Disk</title> |
157 |
<body> |
158 |
|
159 |
<p> |
160 |
At this point, create your partitions using <c>mac-fdisk</c>: |
161 |
</p> |
162 |
|
163 |
<pre caption="Starting mac-fdisk"> |
164 |
# <i>mac-fdisk /dev/hda</i> |
165 |
</pre> |
166 |
|
167 |
<p> |
168 |
First delete the partitions you have cleared previously to make room for your |
169 |
Linux partitions. Use <c>d</c> in <c>mac-fdisk</c> to delete those partition(s). |
170 |
It will ask for the partition number to delete. |
171 |
</p> |
172 |
|
173 |
<p> |
174 |
Second, create an <e>Apple_Bootstrap</e> partition by using <c>b</c>. It will |
175 |
ask for what block you want to start. If you previously selected <c>3</c> as |
176 |
partition number, enter <c>3p</c>. |
177 |
</p> |
178 |
|
179 |
<note> |
180 |
This partition is <e>not</e> a "boot" partition. It is not used by Linux at all; |
181 |
you don't have to place any filesystem on it and you should never mount it. PPC |
182 |
users don't need a boot partition. |
183 |
</note> |
184 |
|
185 |
<p> |
186 |
Now create a swap partition by pressing <c>c</c>. Again <c>mac-fdisk</c> will |
187 |
ask for what block you want to start this partition from. As we used <c>3</c> |
188 |
before to create the Apple_Bootstrap partition, you now have to enter |
189 |
<c>4p</c>. When you're asked for the size, enter <c>512M</c> (or whatever size |
190 |
you want -- 512 is recommended though). When asked for a name, enter <c>swap</c> |
191 |
(mandatory). |
192 |
</p> |
193 |
|
194 |
<p> |
195 |
To create the root partition, enter <c>c</c>, followed by <c>5p</c> to select |
196 |
from what block the root partition should start. When asked for the size, enter |
197 |
<c>5p</c> again. <c>mac-fdisk</c> will interpret this as "Use all available |
198 |
space". When asked for the name, enter <c>root</c> (mandatory). |
199 |
</p> |
200 |
|
201 |
<p> |
202 |
To finish up, write the partition to the disk using <c>w</c> and <c>q</c> to |
203 |
quit <c>mac-fdisk</c>. |
204 |
</p> |
205 |
|
206 |
<p> |
207 |
Now that your partitions are created, you can now continue with <uri |
208 |
link="#filesystems">Creating Filesystems</uri>. |
209 |
</p> |
210 |
|
211 |
</body> |
212 |
</section> |
213 |
<section id="filesystems"> |
214 |
<title>Creating Filesystems</title> |
215 |
<subsection> |
216 |
<title>Introduction</title> |
217 |
<body> |
218 |
|
219 |
<p> |
220 |
Now that your partitions are created, it is time to place a filesystem on them. |
221 |
If you don't care about what filesystem to choose and are happy with what we use |
222 |
as default in this handbook, continue with <uri |
223 |
link="#filesystems-apply">Applying a Filesystem to a Partition</uri>. |
224 |
Otherwise read on to learn about the available filesystems... |
225 |
</p> |
226 |
|
227 |
</body> |
228 |
</subsection> |
229 |
<subsection> |
230 |
<title>Filesystems?</title> |
231 |
<body> |
232 |
|
233 |
<p> |
234 |
Several filesystems are available. Ext2 and ext3 are found stable on the |
235 |
PPC architecture, reiserfs and xfs are in experimental stage. jfs is |
236 |
unsupported. |
237 |
</p> |
238 |
|
239 |
<p> |
240 |
<b>ext2</b> is the tried and true Linux filesystem but doesn't have metadata |
241 |
journaling, which means that routine ext2 filesystem checks at startup time can |
242 |
be quite time-consuming. There is now quite a selection of newer-generation |
243 |
journaled filesystems that can be checked for consistency very quickly and are |
244 |
thus generally preferred over their non-journaled counterparts. Journaled |
245 |
filesystems prevent long delays when you boot your system and your filesystem |
246 |
happens to be in an inconsistent state. |
247 |
</p> |
248 |
|
249 |
<p> |
250 |
<b>ext3</b> is the journaled version of the ext2 filesystem, providing metadata |
251 |
journaling for fast recovery in addition to other enhanced journaling modes like |
252 |
full data and ordered data journaling. ext3 is a very good and reliable |
253 |
filesystem. It has an additional hashed b-tree indexing option that enables |
254 |
high performance in almost all situations. In short, ext3 is an excellent |
255 |
filesystem. |
256 |
</p> |
257 |
|
258 |
<p> |
259 |
<b>ReiserFS</b> is a B*-tree based filesystem that has very good overall |
260 |
performance and greatly outperforms both ext2 and ext3 when dealing with small |
261 |
files (files less than 4k), often by a factor of 10x-15x. ReiserFS also scales |
262 |
extremely well and has metadata journaling. As of kernel 2.4.18+, ReiserFS is |
263 |
solid and usable as both general-purpose filesystem and for extreme cases such |
264 |
as the creation of large filesystems, the use of many small files, very large |
265 |
files and directories containing tens of thousands of files. |
266 |
</p> |
267 |
|
268 |
<p> |
269 |
<b>XFS</b> is a filesystem with metadata journaling that is fully supported |
270 |
under Gentoo Linux's xfs-sources kernel. It comes with a robust feature-set and |
271 |
is optimized for scalability. We only recommend using this filesystem on Linux |
272 |
systems with high-end SCSI and/or fibre channel storage and a uninterruptible |
273 |
power supply. Because XFS aggressively caches in-transit data in RAM, improperly |
274 |
designed programs (those that don't take proper precautions when writing files |
275 |
to disk and there are quite a few of them) can lose a good deal of data if the |
276 |
system goes down unexpectedly. |
277 |
</p> |
278 |
|
279 |
<p> |
280 |
<b>JFS</b> is IBM's high-performance journaling filesystem. It has recently |
281 |
become production-ready and there hasn't been a sufficient track record to |
282 |
comment positively nor negatively on its general stability at this point. |
283 |
</p> |
284 |
|
285 |
</body> |
286 |
</subsection> |
287 |
<subsection id="filesystems-apply"> |
288 |
<title>Applying a Filesystem to a Partition</title> |
289 |
<body> |
290 |
|
291 |
<p> |
292 |
To create a filesystem on a partition or volume, there are tools available for |
293 |
each possible filesystem: |
294 |
</p> |
295 |
|
296 |
<table> |
297 |
<tr> |
298 |
<th>Filesystem</th> |
299 |
<th>Creation Command</th> |
300 |
</tr> |
301 |
<tr> |
302 |
<ti>ext2</ti> |
303 |
<ti><c>mke2fs</c></ti> |
304 |
</tr> |
305 |
<tr> |
306 |
<ti>ext3</ti> |
307 |
<ti><c>mke2fs -j</c></ti> |
308 |
</tr> |
309 |
<tr> |
310 |
<ti>reiserfs</ti> |
311 |
<ti><c>mkreiserfs</c></ti> |
312 |
</tr> |
313 |
<tr> |
314 |
<ti>xfs</ti> |
315 |
<ti><c>mkfs.xfs</c></ti> |
316 |
</tr> |
317 |
<tr> |
318 |
<ti>jfs</ti> |
319 |
<ti><c>mkfs.jfs</c></ti> |
320 |
</tr> |
321 |
</table> |
322 |
|
323 |
<p> |
324 |
For instance, to have the root partition (<path>/dev/hda3</path> in our example) |
325 |
in ext3 (as in our example), you would use: |
326 |
</p> |
327 |
|
328 |
<pre caption="Applying a filesystem on a partition"> |
329 |
# <i>mke2fs -j /dev/hda3</i> |
330 |
</pre> |
331 |
|
332 |
<p> |
333 |
Now create the filesystems on your newly created partitions (or logical |
334 |
volumes). |
335 |
</p> |
336 |
|
337 |
</body> |
338 |
</subsection> |
339 |
<subsection> |
340 |
<title>Activating the Swap Partition</title> |
341 |
<body> |
342 |
|
343 |
<p> |
344 |
<c>mkswap</c> is the command that is used to initialize swap partitions: |
345 |
</p> |
346 |
|
347 |
<pre caption="Creating a Swap signature"> |
348 |
# <i>mkswap /dev/hda4</i> |
349 |
</pre> |
350 |
|
351 |
<p> |
352 |
To activate the swap partition, use <c>swapon</c>: |
353 |
</p> |
354 |
|
355 |
<pre caption="Activating the swap partition"> |
356 |
# <i>swapon /dev/hda4</i> |
357 |
</pre> |
358 |
|
359 |
<p> |
360 |
Create and activate the swap now. |
361 |
</p> |
362 |
|
363 |
</body> |
364 |
</subsection> |
365 |
</section> |
366 |
<section> |
367 |
<title>Mounting</title> |
368 |
<body> |
369 |
|
370 |
<p> |
371 |
Now that your partitions are initialized and are housing a filesystem, it is |
372 |
time to mount those partitions. Use the <c>mount</c> command. Don't forget to |
373 |
create the necessary mount directories for every partition you created. As an |
374 |
example we mount the root and boot partition: |
375 |
</p> |
376 |
|
377 |
<pre caption="Mounting partitions"> |
378 |
# <i>mount /dev/hda3 /mnt/gentoo</i> |
379 |
</pre> |
380 |
|
381 |
<note> |
382 |
If you want your <path>/tmp</path> to reside on a separate partition, be sure to |
383 |
change its permissions after mounting: <c>chmod 1777 /mnt/gentoo/tmp</c>. This |
384 |
also holds for <path>/var/tmp</path>. |
385 |
</note> |
386 |
|
387 |
<p> |
388 |
We also need to mount the proc filesystem (a virtual interface with the kernel) |
389 |
on <path>/proc</path>. We first create the <path>/mnt/gentoo/proc</path> |
390 |
mountpoint and then mount the filesystem: |
391 |
</p> |
392 |
|
393 |
<pre caption="Creating the /mnt/gentoo/proc mountpoint"> |
394 |
# <i>mkdir /mnt/gentoo/proc</i> |
395 |
# <i>mount -t proc none /mnt/gentoo/proc</i> |
396 |
</pre> |
397 |
|
398 |
<p> |
399 |
Now continue with <uri link="?part=1&chap=5">Installing the Gentoo |
400 |
Installation Files</uri>. |
401 |
</p> |
402 |
|
403 |
</body> |
404 |
</section> |
405 |
</sections> |