| 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-alpha-disk.xml,v 1.1 2004/04/02 08:14:45 swift 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 SCSI HD in a Linux system, namely |
| 27 |
<path>/dev/sda</path>. |
| 28 |
</p> |
| 29 |
|
| 30 |
<p> |
| 31 |
The block devices above represent an abstract interface to the disk. User |
| 32 |
programs can use these block devices to interact with your disk without worrying |
| 33 |
about whether your drives are IDE, SCSI or something else. The program can |
| 34 |
simply address the storage on the disk as a bunch of contiguous, |
| 35 |
randomly-accessible 512-byte blocks. |
| 36 |
</p> |
| 37 |
|
| 38 |
</body> |
| 39 |
</subsection> |
| 40 |
<subsection> |
| 41 |
<title>Slices</title> |
| 42 |
<body> |
| 43 |
|
| 44 |
<p> |
| 45 |
Although it is theoretically possible to use a full disk to house your Linux |
| 46 |
system, this is almost never done in practice. Instead, full disk block devices |
| 47 |
are split up in smaller, more manageable block devices. On Alpha systems, |
| 48 |
these are called <e>slices</e>. |
| 49 |
</p> |
| 50 |
|
| 51 |
</body> |
| 52 |
</subsection> |
| 53 |
</section> |
| 54 |
<section> |
| 55 |
<title>Designing a Partitioning Scheme</title> |
| 56 |
<subsection> |
| 57 |
<title>Default Partitioning Scheme</title> |
| 58 |
<body> |
| 59 |
|
| 60 |
<p> |
| 61 |
As an example we use the following slice layout: |
| 62 |
</p> |
| 63 |
|
| 64 |
<table> |
| 65 |
<tr> |
| 66 |
<th>Slice</th> |
| 67 |
<th>Description</th> |
| 68 |
</tr> |
| 69 |
<tr> |
| 70 |
<ti><path>/dev/sdaa</path></ti> |
| 71 |
<ti>Swap slice</ti> |
| 72 |
</tr> |
| 73 |
<tr> |
| 74 |
<ti><path>/dev/sdab</path></ti> |
| 75 |
<ti>Root slice</ti> |
| 76 |
</tr> |
| 77 |
<tr> |
| 78 |
<ti><path>/dev/sdac</path></ti> |
| 79 |
<ti>Full disk (required)</ti> |
| 80 |
</tr> |
| 81 |
</table> |
| 82 |
|
| 83 |
|
| 84 |
<p> |
| 85 |
If you are interested in knowing how big a partition should be, or even how |
| 86 |
many partitions (or volumes) you need, read on. Otherwise continue now with |
| 87 |
<uri link="#fdisk">Using fdisk to Partition your Disk</uri>. |
| 88 |
</p> |
| 89 |
|
| 90 |
</body> |
| 91 |
</subsection> |
| 92 |
<subsection> |
| 93 |
<title>How Many and How Big?</title> |
| 94 |
<body> |
| 95 |
|
| 96 |
<p> |
| 97 |
The number of partitions is highly dependent on your environment. For instance, |
| 98 |
if you have lots of users, you will most likely want to have your |
| 99 |
<path>/home</path> separate as it increases security and makes backups easier. |
| 100 |
If you are installing Gentoo to perform as a mailserver, your |
| 101 |
<path>/var</path> should be separate as all mails are stored inside |
| 102 |
<path>/var</path>. A good choice of filesystem will then maximise your |
| 103 |
performance. Gameservers will have a separate <path>/opt</path> as most gaming |
| 104 |
servers are installed there. The reason is similar for <path>/home</path>: |
| 105 |
security and backups. |
| 106 |
</p> |
| 107 |
|
| 108 |
<p> |
| 109 |
As you can see, it very much depends on what you want to achieve. Separate |
| 110 |
partitions or volumes have the following advantages: |
| 111 |
</p> |
| 112 |
|
| 113 |
<ul> |
| 114 |
<li> |
| 115 |
You can choose the most performant filesystem for each partition or volume |
| 116 |
</li> |
| 117 |
<li> |
| 118 |
Your entire system cannot run out of free space if one defunct tool is |
| 119 |
continuously writing files to a partition or volume |
| 120 |
</li> |
| 121 |
<li> |
| 122 |
If necessary, file system checks are reduced in time, as multiple checks can |
| 123 |
be done in parallel (although this advantage is more with multiple disks than |
| 124 |
it is with multiple partitions) |
| 125 |
</li> |
| 126 |
<li> |
| 127 |
Security can be enhanced by mounting some partitions or volumes read-only, |
| 128 |
nosuid (setuid bits are ignored), noexec (executable bits are ignored) etc. |
| 129 |
</li> |
| 130 |
</ul> |
| 131 |
|
| 132 |
<p> |
| 133 |
However, multiple partitions have one big disadvantage: if not configured |
| 134 |
properly, you might result in having a system with lots |
| 135 |
of free space on one partition and none on another. |
| 136 |
</p> |
| 137 |
|
| 138 |
</body> |
| 139 |
</subsection> |
| 140 |
</section> |
| 141 |
<section id="fdisk"> |
| 142 |
<title>Using fdisk on Alpha to Partition your Disk</title> |
| 143 |
<subsection> |
| 144 |
<body> |
| 145 |
|
| 146 |
<p> |
| 147 |
The following parts explain how to create the example slice layout described |
| 148 |
previously, namely: |
| 149 |
</p> |
| 150 |
|
| 151 |
<table> |
| 152 |
<tr> |
| 153 |
<th>Slice</th> |
| 154 |
<th>Description</th> |
| 155 |
</tr> |
| 156 |
<tr> |
| 157 |
<ti><path>/dev/sdaa</path></ti> |
| 158 |
<ti>Swap slice</ti> |
| 159 |
</tr> |
| 160 |
<tr> |
| 161 |
<ti><path>/dev/sdab</path></ti> |
| 162 |
<ti>Root slice</ti> |
| 163 |
</tr> |
| 164 |
<tr> |
| 165 |
<ti><path>/dev/sdac</path></ti> |
| 166 |
<ti>Full disk (required)</ti> |
| 167 |
</tr> |
| 168 |
</table> |
| 169 |
|
| 170 |
<p> |
| 171 |
Change your slice layout according to your own will. |
| 172 |
</p> |
| 173 |
|
| 174 |
|
| 175 |
</body> |
| 176 |
</subsection> |
| 177 |
<subsection> |
| 178 |
<title>Identifying Available Disks</title> |
| 179 |
<body> |
| 180 |
|
| 181 |
<p> |
| 182 |
To figure out what disks you have running, use the following commands: |
| 183 |
</p> |
| 184 |
|
| 185 |
<pre caption="Identifying available disks"> |
| 186 |
<comment>(For IDE disks)</comment> # <i>dmesg | grep 'drive$'</i> |
| 187 |
<comment>(For SCSI disks)</comment> # <i>dmesg | grep 'scsi'</i> |
| 188 |
</pre> |
| 189 |
|
| 190 |
<p> |
| 191 |
From this output you should be able to see what disks were detected and their |
| 192 |
respective <path>/dev</path> entry. In the following parts we assume that the |
| 193 |
disk is a SCSI disk on <path>/dev/sda</path>. |
| 194 |
</p> |
| 195 |
|
| 196 |
<p> |
| 197 |
Now fire up <c>fdisk</c>: |
| 198 |
</p> |
| 199 |
|
| 200 |
<pre caption="Starting fdisk"> |
| 201 |
# <i>fdisk /dev/sda</i> |
| 202 |
</pre> |
| 203 |
|
| 204 |
</body> |
| 205 |
</subsection> |
| 206 |
<subsection> |
| 207 |
<title>Deleting All Slices</title> |
| 208 |
<body> |
| 209 |
|
| 210 |
<p> |
| 211 |
We start with deleting all slices <e>except</e> the 'c'-slice. The following |
| 212 |
shows how to delete a slice (in the example we use 'a'). Repeat the process to |
| 213 |
delete all other slices (again, except the 'c'-slice). |
| 214 |
</p> |
| 215 |
|
| 216 |
<p> |
| 217 |
Use <c>p</c> to view all existing slices. <c>d</c> is used to delete a slice. |
| 218 |
</p> |
| 219 |
|
| 220 |
<pre caption="Deleting a slice"> |
| 221 |
BSD disklabel command (m for help): <i>p</i> |
| 222 |
|
| 223 |
8 partitions: |
| 224 |
# start end size fstype [fsize bsize cpg] |
| 225 |
a: 1 235* 234* 4.2BSD 1024 8192 16 |
| 226 |
b: 235* 469* 234* swap |
| 227 |
c: 1 5290* 5289* unused 0 0 |
| 228 |
d: 469* 2076* 1607* unused 0 0 |
| 229 |
e: 2076* 3683* 1607* unused 0 0 |
| 230 |
f: 3683* 5290* 1607* unused 0 0 |
| 231 |
g: 469* 1749* 1280 4.2BSD 1024 8192 16 |
| 232 |
h: 1749* 5290* 3541* unused 0 0 |
| 233 |
|
| 234 |
BSD disklabel command (m for help): <i>d</i> |
| 235 |
Partition (a-h): <i>a</i> |
| 236 |
</pre> |
| 237 |
|
| 238 |
<p> |
| 239 |
After repeating this process for all slices, a listing should show you something |
| 240 |
similar to this: |
| 241 |
</p> |
| 242 |
|
| 243 |
<pre caption="Viewing an empty scheme"> |
| 244 |
BSD disklabel command (m for help): <i>p</i> |
| 245 |
|
| 246 |
3 partitions: |
| 247 |
# start end size fstype [fsize bsize cpg] |
| 248 |
c: 1 5290* 5289* unused 0 0 |
| 249 |
</pre> |
| 250 |
|
| 251 |
</body> |
| 252 |
</subsection> |
| 253 |
<subsection> |
| 254 |
<title>Creating the Swap Slice</title> |
| 255 |
<body> |
| 256 |
|
| 257 |
<p> |
| 258 |
On Alpha based systems you don't need a separate boot partition. However, the |
| 259 |
first cylinder cannot be used as the <c>aboot</c> image will be placed there. |
| 260 |
</p> |
| 261 |
|
| 262 |
<p> |
| 263 |
We will create a swap slice starting at the third cylinder, with a total |
| 264 |
size of 1 Gbyte. Use <c>n</c> to create a new slice. After creating the slice, |
| 265 |
we will change its type to <c>1</c>, meaning <e>swap</e>. |
| 266 |
</p> |
| 267 |
|
| 268 |
<pre caption="Creating the swap slice"> |
| 269 |
BSD disklabel command (m for help): <i>n</i> |
| 270 |
Partition (a-p): <i>a</i> |
| 271 |
First cylinder (1-5290, default 1): <i>3</i> |
| 272 |
Last cylinder or +size or +sizeM or +sizeK (3-5290, default 5290): <i>+1024M</i> |
| 273 |
|
| 274 |
BSD disklabel command (m for help): <i>t</i> |
| 275 |
Partition (a-c): <i>a</i> |
| 276 |
Hex code (type L to list codes): <i>1</i> |
| 277 |
</pre> |
| 278 |
|
| 279 |
<p> |
| 280 |
After these steps you should see a layout similar to the following: |
| 281 |
</p> |
| 282 |
|
| 283 |
<pre caption="Slice layout after creating the swap slice"> |
| 284 |
BSD disklabel command (m for help): <i>p</i> |
| 285 |
|
| 286 |
3 partitions: |
| 287 |
# start end size fstype [fsize bsize cpg] |
| 288 |
a: 3 1003 1001 swap |
| 289 |
c: 1 5290* 5289* unused 0 0 |
| 290 |
</pre> |
| 291 |
|
| 292 |
</body> |
| 293 |
</subsection> |
| 294 |
<subsection> |
| 295 |
<title>Create the Root Slice</title> |
| 296 |
<body> |
| 297 |
|
| 298 |
<p> |
| 299 |
We will now create the root slice, starting from the first cylinder <e>after</e> |
| 300 |
the swap slice. Use the <c>p</c> command to view where the swap slice ends. In |
| 301 |
our example, this is at 1003, making the root partition start at 1004. |
| 302 |
</p> |
| 303 |
|
| 304 |
<p> |
| 305 |
Another problem is that there is currently a bug in <c>fdisk</c> making it think |
| 306 |
the number of available cylinders is one above the real number of cylinders. In |
| 307 |
other words, when you are asked for the last cylinder, decrease the cylinder |
| 308 |
number (in this example: 5290) with one. |
| 309 |
</p> |
| 310 |
|
| 311 |
<p> |
| 312 |
When the partition is created, we change the type to <c>8</c>, for <e>ext2</e>. |
| 313 |
</p> |
| 314 |
|
| 315 |
<pre caption="Creating the root slice"> |
| 316 |
D disklabel command (m for help): <i>n</i> |
| 317 |
Partition (a-p): <i>b</i> |
| 318 |
First cylinder (1-5290, default 1): <i>1004</i> |
| 319 |
Last cylinder or +size or +sizeM or +sizeK (1004-5290, default 5290): <i>5289</i> |
| 320 |
|
| 321 |
BSD disklabel command (m for help): <i>t</i> |
| 322 |
Partition (a-c): <i>b</i> |
| 323 |
Hex code (type L to list codes): <i>8</i> |
| 324 |
</pre> |
| 325 |
|
| 326 |
<p> |
| 327 |
Your slice layout should now be similar to this: |
| 328 |
</p> |
| 329 |
|
| 330 |
<pre caption="Viewing the slice layout"> |
| 331 |
BSD disklabel command (m for help): <i>p</i> |
| 332 |
|
| 333 |
3 partitions: |
| 334 |
# start end size fstype [fsize bsize cpg] |
| 335 |
a: 3 1003 1001 swap |
| 336 |
b: 1004 5289 4286 ext2 |
| 337 |
c: 1 5290* 5289* unused 0 0 |
| 338 |
</pre> |
| 339 |
|
| 340 |
</body> |
| 341 |
</subsection> |
| 342 |
<subsection> |
| 343 |
<title>Save the Slice Layout and Exit</title> |
| 344 |
<body> |
| 345 |
|
| 346 |
<p> |
| 347 |
Save <c>fdisk</c> by typing <c>w</c>. This will also save your slice layout. |
| 348 |
</p> |
| 349 |
|
| 350 |
<pre caption="Save and exit fdisk"> |
| 351 |
Command (m for help): <i>w</i> |
| 352 |
</pre> |
| 353 |
|
| 354 |
<p> |
| 355 |
Now that your slices are created, you can now continue with <uri |
| 356 |
link="#filesystems">Creating Filesystems</uri>. |
| 357 |
</p> |
| 358 |
|
| 359 |
</body> |
| 360 |
</subsection> |
| 361 |
</section> |
| 362 |
<section id="filesystems"> |
| 363 |
<title>Creating Filesystems</title> |
| 364 |
<subsection> |
| 365 |
<title>Introduction</title> |
| 366 |
<body> |
| 367 |
|
| 368 |
<p> |
| 369 |
Now that your partitions are created, it is time to place a filesystem on them. |
| 370 |
If you don't care about what filesystem to choose and are happy with what we use |
| 371 |
as default in this handbook, continue with <uri |
| 372 |
link="#filesystems-apply">Applying a Filesystem to a Partition</uri>. |
| 373 |
Otherwise read on to learn about the available filesystems... |
| 374 |
</p> |
| 375 |
|
| 376 |
</body> |
| 377 |
</subsection> |
| 378 |
<subsection> |
| 379 |
<title>Filesystems?</title> |
| 380 |
<body> |
| 381 |
|
| 382 |
<p> |
| 383 |
Several filesystems are available. Most of them are found stable on the |
| 384 |
Alpha architecture. |
| 385 |
</p> |
| 386 |
|
| 387 |
<p> |
| 388 |
<b>ext2</b> is the tried and true Linux filesystem but doesn't have metadata |
| 389 |
journaling, which means that routine ext2 filesystem checks at startup time can |
| 390 |
be quite time-consuming. There is now quite a selection of newer-generation |
| 391 |
journaled filesystems that can be checked for consistency very quickly and are |
| 392 |
thus generally preferred over their non-journaled counterparts. Journaled |
| 393 |
filesystems prevent long delays when you boot your system and your filesystem |
| 394 |
happens to be in an inconsistent state. |
| 395 |
</p> |
| 396 |
|
| 397 |
<p> |
| 398 |
<b>ext3</b> is the journaled version of the ext2 filesystem, providing metadata |
| 399 |
journaling for fast recovery in addition to other enhanced journaling modes like |
| 400 |
full data and ordered data journaling. ext3 is a very good and reliable |
| 401 |
filesystem. It has an additional hashed b-tree indexing option that enables |
| 402 |
high performance in almost all situations. In short, ext3 is an excellent |
| 403 |
filesystem. |
| 404 |
</p> |
| 405 |
|
| 406 |
<p> |
| 407 |
<b>ReiserFS</b> is a B*-tree based filesystem that has very good overall |
| 408 |
performance and greatly outperforms both ext2 and ext3 when dealing with small |
| 409 |
files (files less than 4k), often by a factor of 10x-15x. ReiserFS also scales |
| 410 |
extremely well and has metadata journaling. As of kernel 2.4.18+, ReiserFS is |
| 411 |
solid and usable as both general-purpose filesystem and for extreme cases such |
| 412 |
as the creation of large filesystems, the use of many small files, very large |
| 413 |
files and directories containing tens of thousands of files. |
| 414 |
</p> |
| 415 |
|
| 416 |
<p> |
| 417 |
<b>XFS</b> is a filesystem with metadata journaling that is fully supported |
| 418 |
under Gentoo Linux's xfs-sources kernel. It comes with a robust feature-set and |
| 419 |
is optimized for scalability. We only recommend using this filesystem on Linux |
| 420 |
systems with high-end SCSI and/or fibre channel storage and a uninterruptible |
| 421 |
power supply. Because XFS aggressively caches in-transit data in RAM, improperly |
| 422 |
designed programs (those that don't take proper precautions when writing files |
| 423 |
to disk and there are quite a few of them) can lose a good deal of data if the |
| 424 |
system goes down unexpectedly. |
| 425 |
</p> |
| 426 |
|
| 427 |
<p> |
| 428 |
<b>JFS</b> is IBM's high-performance journaling filesystem. It has recently |
| 429 |
become production-ready and there hasn't been a sufficient track record to |
| 430 |
comment positively nor negatively on its general stability at this point. |
| 431 |
</p> |
| 432 |
|
| 433 |
</body> |
| 434 |
</subsection> |
| 435 |
<subsection id="filesystems-apply"> |
| 436 |
<title>Applying a Filesystem to a Partition</title> |
| 437 |
<body> |
| 438 |
|
| 439 |
<p> |
| 440 |
To create a filesystem on a partition or volume, there are tools available for |
| 441 |
each possible filesystem: |
| 442 |
</p> |
| 443 |
|
| 444 |
<table> |
| 445 |
<tr> |
| 446 |
<th>Filesystem</th> |
| 447 |
<th>Creation Command</th> |
| 448 |
</tr> |
| 449 |
<tr> |
| 450 |
<ti>ext2</ti> |
| 451 |
<ti><c>mke2fs</c></ti> |
| 452 |
</tr> |
| 453 |
<tr> |
| 454 |
<ti>ext3</ti> |
| 455 |
<ti><c>mke2fs -j</c></ti> |
| 456 |
</tr> |
| 457 |
<tr> |
| 458 |
<ti>reiserfs</ti> |
| 459 |
<ti><c>mkreiserfs</c></ti> |
| 460 |
</tr> |
| 461 |
<tr> |
| 462 |
<ti>xfs</ti> |
| 463 |
<ti><c>mkfs.xfs</c></ti> |
| 464 |
</tr> |
| 465 |
<tr> |
| 466 |
<ti>jfs</ti> |
| 467 |
<ti><c>mkfs.jfs</c></ti> |
| 468 |
</tr> |
| 469 |
</table> |
| 470 |
|
| 471 |
<p> |
| 472 |
For instance, to have the root partition (<path>/dev/sdab</path> in our example) |
| 473 |
in ext3, you would use: |
| 474 |
</p> |
| 475 |
|
| 476 |
<pre caption="Applying a filesystem on a partition"> |
| 477 |
# <i>mke2fs -j /dev/sdab</i> |
| 478 |
</pre> |
| 479 |
|
| 480 |
<p> |
| 481 |
Now create the filesystems on your newly created partitions (or logical |
| 482 |
volumes). |
| 483 |
</p> |
| 484 |
|
| 485 |
</body> |
| 486 |
</subsection> |
| 487 |
<subsection> |
| 488 |
<title>Activating the Swap Partition</title> |
| 489 |
<body> |
| 490 |
|
| 491 |
<p> |
| 492 |
<c>mkswap</c> is the command that is used to initialize swap partitions: |
| 493 |
</p> |
| 494 |
|
| 495 |
<pre caption="Creating a Swap signature"> |
| 496 |
# <i>mkswap /dev/sdaa</i> |
| 497 |
</pre> |
| 498 |
|
| 499 |
<p> |
| 500 |
To activate the swap partition, use <c>swapon</c>: |
| 501 |
</p> |
| 502 |
|
| 503 |
<pre caption="Activating the swap partition"> |
| 504 |
# <i>swapon /dev/sdaa</i> |
| 505 |
</pre> |
| 506 |
|
| 507 |
<p> |
| 508 |
Create and activate the swap now. |
| 509 |
</p> |
| 510 |
|
| 511 |
</body> |
| 512 |
</subsection> |
| 513 |
</section> |
| 514 |
<section> |
| 515 |
<title>Mounting</title> |
| 516 |
<body> |
| 517 |
|
| 518 |
<p> |
| 519 |
Now that your partitions are initialized and are housing a filesystem, it is |
| 520 |
time to mount those partitions. Use the <c>mount</c> command. Don't forget to |
| 521 |
create the necessary mount directories for every partition you created. As an |
| 522 |
example we mount the root and boot partition: |
| 523 |
</p> |
| 524 |
|
| 525 |
<pre caption="Mounting partitions"> |
| 526 |
# <i>mount /dev/sdab /mnt/gentoo</i> |
| 527 |
</pre> |
| 528 |
|
| 529 |
<note> |
| 530 |
If you want your <path>/tmp</path> to reside on a separate partition, be sure to |
| 531 |
change its permissions after mounting: <c>chmod 1777 /mnt/gentoo/tmp</c>. This |
| 532 |
also holds for <path>/var/tmp</path>. |
| 533 |
</note> |
| 534 |
|
| 535 |
<p> |
| 536 |
We also need to mount the proc filesystem (a virtual interface with the kernel) |
| 537 |
on <path>/proc</path>. We first create the <path>/mnt/gentoo/proc</path> |
| 538 |
mountpoint and then mount the filesystem: |
| 539 |
</p> |
| 540 |
|
| 541 |
<pre caption="Creating the /mnt/gentoo/proc mountpoint"> |
| 542 |
# <i>mkdir /mnt/gentoo/proc</i> |
| 543 |
# <i>mount -t proc none /mnt/gentoo/proc</i> |
| 544 |
</pre> |
| 545 |
|
| 546 |
<p> |
| 547 |
Now continue with <uri link="?part=1&chap=5">Installing the Gentoo |
| 548 |
Installation Files</uri>. |
| 549 |
</p> |
| 550 |
|
| 551 |
</body> |
| 552 |
</section> |
| 553 |
</sections> |