| 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: /var/cvsroot/gentoo/xml/htdocs/doc/en/handbook/hb-install-hppa-disk.xml,v 1.8 2004/09/14 11:55:12 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>Partitions and 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 most systems, |
| 48 |
these are called <e>partitions</e>. Other architectures use a similar technique, |
| 49 |
called <e>slices</e>. |
| 50 |
</p> |
| 51 |
|
| 52 |
</body> |
| 53 |
</subsection> |
| 54 |
</section> |
| 55 |
<section> |
| 56 |
<title>Designing a Partitioning Scheme</title> |
| 57 |
<subsection> |
| 58 |
<title>How Many and How Big?</title> |
| 59 |
<body> |
| 60 |
|
| 61 |
<p> |
| 62 |
The number of partitions is highly dependent on your environment. For instance, |
| 63 |
if you have lots of users, you will most likely want to have your |
| 64 |
<path>/home</path> separate as it increases security and makes backups easier. |
| 65 |
If you are installing Gentoo to perform as a mailserver, your |
| 66 |
<path>/var</path> should be separate as all mails are stored inside |
| 67 |
<path>/var</path>. A good choice of filesystem will then maximise your |
| 68 |
performance. Gameservers will have a separate <path>/opt</path> as most gaming |
| 69 |
servers are installed there. The reason is similar for <path>/home</path>: |
| 70 |
security and backups. |
| 71 |
</p> |
| 72 |
|
| 73 |
<p> |
| 74 |
As you can see, it very much depends on what you want to achieve. Separate |
| 75 |
partitions or volumes have the following advantages: |
| 76 |
</p> |
| 77 |
|
| 78 |
<ul> |
| 79 |
<li> |
| 80 |
You can choose the best performing filesystem for each partition or volume |
| 81 |
</li> |
| 82 |
<li> |
| 83 |
Your entire system cannot run out of free space if one defunct tool is |
| 84 |
continuously writing files to a partition or volume |
| 85 |
</li> |
| 86 |
<li> |
| 87 |
If necessary, file system checks are reduced in time, as multiple checks can |
| 88 |
be done in parallel (although this advantage is more with multiple disks than |
| 89 |
it is with multiple partitions) |
| 90 |
</li> |
| 91 |
<li> |
| 92 |
Security can be enhanced by mounting some partitions or volumes read-only, |
| 93 |
nosuid (setuid bits are ignored), noexec (executable bits are ignored) etc. |
| 94 |
</li> |
| 95 |
</ul> |
| 96 |
|
| 97 |
<p> |
| 98 |
However, multiple partitions have one big disadvantage: if not configured |
| 99 |
properly, you might result in having a system with lots |
| 100 |
of free space on one partition and none on another. There is also a 15-partition |
| 101 |
limit for SCSI and SATA. |
| 102 |
</p> |
| 103 |
|
| 104 |
</body> |
| 105 |
</subsection> |
| 106 |
</section> |
| 107 |
<section> |
| 108 |
<title>Using fdisk on HPPA to Partition your Disk</title> |
| 109 |
<body> |
| 110 |
|
| 111 |
<p> |
| 112 |
Use <c>fdisk</c> to create the partitions you want: |
| 113 |
</p> |
| 114 |
|
| 115 |
<pre caption="Partitioning the disk"> |
| 116 |
# <i>fdisk /dev/sda</i> |
| 117 |
</pre> |
| 118 |
|
| 119 |
<p> |
| 120 |
HPPA machines use the PC standard DOS partition tables. To create a new |
| 121 |
DOS partition table, simply use the <c>o</c> command. |
| 122 |
</p> |
| 123 |
|
| 124 |
<pre caption="Creating a DOS partition table"> |
| 125 |
# <i>fdisk /dev/sda</i> |
| 126 |
|
| 127 |
Command (m for help): <i>o</i> |
| 128 |
Building a new DOS disklabel. |
| 129 |
</pre> |
| 130 |
|
| 131 |
<p> |
| 132 |
PALO (the HPPA bootloader) needs a special partition to work. You have |
| 133 |
to create a partition of at least 16Mb at the beginning of your disk. |
| 134 |
The partition type must be of type <e>f0</e> (Linux/PA-RISC boot). |
| 135 |
</p> |
| 136 |
|
| 137 |
<impo> |
| 138 |
If you ignore this and continue without a special PALO partition, your system |
| 139 |
will stop loving you and fail to start. Also, if your disk is larger than 2Gb, |
| 140 |
make sure that the boot partition is in the first 2Gb of your disk. PALO is |
| 141 |
unable to read a kernel after the 2Gb limit. |
| 142 |
</impo> |
| 143 |
|
| 144 |
<pre caption="A simple default partition schema"> |
| 145 |
# <i>cat /etc/fstab</i> |
| 146 |
/dev/sda2 /boot ext3 noauto,noatime 1 1 |
| 147 |
/dev/sda3 none swap sw 0 0 |
| 148 |
/dev/sda4 / ext3 noatime 0 0 |
| 149 |
|
| 150 |
# <i>fdisk /dev/sda</i> |
| 151 |
|
| 152 |
Command (m for help): <i>p</i> |
| 153 |
|
| 154 |
Disk /dev/sda: 4294 MB, 4294816768 bytes |
| 155 |
133 heads, 62 sectors/track, 1017 cylinders |
| 156 |
Units = cylinders of 8246 * 512 = 4221952 bytes |
| 157 |
|
| 158 |
Device Boot Start End Blocks Id System |
| 159 |
/dev/sda1 1 8 32953 f0 Linux/PA-RISC boot |
| 160 |
/dev/sda2 9 20 49476 83 Linux |
| 161 |
/dev/sda3 21 70 206150 82 Linux swap |
| 162 |
/dev/sda4 71 1017 3904481 83 Linux |
| 163 |
</pre> |
| 164 |
|
| 165 |
<p> |
| 166 |
Now that your partitions are created, you can now continue with <uri |
| 167 |
link="#filesystems">Creating Filesystems</uri>. |
| 168 |
</p> |
| 169 |
|
| 170 |
</body> |
| 171 |
</section> |
| 172 |
<section id="filesystems"> |
| 173 |
<title>Creating Filesystems</title> |
| 174 |
<subsection> |
| 175 |
<title>Introduction</title> |
| 176 |
<body> |
| 177 |
|
| 178 |
<p> |
| 179 |
Now that your partitions are created, it is time to place a filesystem on them. |
| 180 |
If you don't care about what filesystem to choose and are happy with what we use |
| 181 |
as default in this handbook, continue with <uri |
| 182 |
link="#filesystems-apply">Applying a Filesystem to a Partition</uri>. |
| 183 |
Otherwise read on to learn about the available filesystems... |
| 184 |
</p> |
| 185 |
|
| 186 |
</body> |
| 187 |
</subsection> |
| 188 |
<subsection> |
| 189 |
<title>Filesystems?</title> |
| 190 |
<body> |
| 191 |
|
| 192 |
<p> |
| 193 |
Several filesystems are available. Ext2, ext3, XFS and reiserfs are found stable on |
| 194 |
the HPPA architecture. The others are very experimental. |
| 195 |
</p> |
| 196 |
|
| 197 |
<p> |
| 198 |
<b>ext2</b> is the tried and true Linux filesystem but doesn't have metadata |
| 199 |
journaling, which means that routine ext2 filesystem checks at startup time can |
| 200 |
be quite time-consuming. There is now quite a selection of newer-generation |
| 201 |
journaled filesystems that can be checked for consistency very quickly and are |
| 202 |
thus generally preferred over their non-journaled counterparts. Journaled |
| 203 |
filesystems prevent long delays when you boot your system and your filesystem |
| 204 |
happens to be in an inconsistent state. |
| 205 |
</p> |
| 206 |
|
| 207 |
<p> |
| 208 |
<b>ext3</b> is the journaled version of the ext2 filesystem, providing metadata |
| 209 |
journaling for fast recovery in addition to other enhanced journaling modes like |
| 210 |
full data and ordered data journaling. ext3 is a very good and reliable |
| 211 |
filesystem. It has an additional hashed b-tree indexing option that enables |
| 212 |
high performance in almost all situations. In short, ext3 is an excellent |
| 213 |
filesystem. |
| 214 |
</p> |
| 215 |
|
| 216 |
<p> |
| 217 |
<b>ReiserFS</b> is a B*-tree based filesystem that has very good overall |
| 218 |
performance and greatly outperforms both ext2 and ext3 when dealing with small |
| 219 |
files (files less than 4k), often by a factor of 10x-15x. ReiserFS also scales |
| 220 |
extremely well and has metadata journaling. As of kernel 2.4.18+, ReiserFS is |
| 221 |
solid and usable as both general-purpose filesystem and for extreme cases such |
| 222 |
as the creation of large filesystems, the use of many small files, very large |
| 223 |
files and directories containing tens of thousands of files. |
| 224 |
</p> |
| 225 |
|
| 226 |
<p> |
| 227 |
<b>XFS</b> is a filesystem with metadata journaling which comes with a robust |
| 228 |
feature-set and is optimized for scalability. We only recommend using this |
| 229 |
filesystem on Linux systems with high-end SCSI and/or fibre channel storage and |
| 230 |
an uninterruptible power supply. Because XFS aggressively caches in-transit data |
| 231 |
in RAM, improperly designed programs (those that don't take proper precautions |
| 232 |
when writing files to disk and there are quite a few of them) can lose a good |
| 233 |
deal of data if the system goes down unexpectedly. |
| 234 |
</p> |
| 235 |
|
| 236 |
<p> |
| 237 |
<b>JFS</b> is IBM's high-performance journaling filesystem. It has recently |
| 238 |
become production-ready and there hasn't been a sufficient track record to |
| 239 |
comment positively nor negatively on its general stability at this point. |
| 240 |
</p> |
| 241 |
|
| 242 |
</body> |
| 243 |
</subsection> |
| 244 |
<subsection id="filesystems-apply"> |
| 245 |
<title>Applying a Filesystem to a Partition</title> |
| 246 |
<body> |
| 247 |
|
| 248 |
<p> |
| 249 |
To create a filesystem on a partition or volume, there are tools available for |
| 250 |
each possible filesystem: |
| 251 |
</p> |
| 252 |
|
| 253 |
<table> |
| 254 |
<tr> |
| 255 |
<th>Filesystem</th> |
| 256 |
<th>Creation Command</th> |
| 257 |
</tr> |
| 258 |
<tr> |
| 259 |
<ti>ext2</ti> |
| 260 |
<ti><c>mke2fs</c></ti> |
| 261 |
</tr> |
| 262 |
<tr> |
| 263 |
<ti>ext3</ti> |
| 264 |
<ti><c>mke2fs -j</c></ti> |
| 265 |
</tr> |
| 266 |
<tr> |
| 267 |
<ti>reiserfs</ti> |
| 268 |
<ti><c>mkreiserfs</c></ti> |
| 269 |
</tr> |
| 270 |
<tr> |
| 271 |
<ti>xfs</ti> |
| 272 |
<ti><c>mkfs.xfs</c></ti> |
| 273 |
</tr> |
| 274 |
<tr> |
| 275 |
<ti>jfs</ti> |
| 276 |
<ti><c>mkfs.jfs</c></ti> |
| 277 |
</tr> |
| 278 |
</table> |
| 279 |
|
| 280 |
<p> |
| 281 |
For instance, to have the boot partition (<path>/dev/sda2</path> in our |
| 282 |
example) in ext2 and the root partition (<path>/dev/sda4</path> in our example) |
| 283 |
in ext3 (as in our example), you would use: |
| 284 |
</p> |
| 285 |
|
| 286 |
<pre caption="Applying a filesystem on a partition"> |
| 287 |
# <i>mke2fs /dev/sda2</i> |
| 288 |
# <i>mke2fs -j /dev/sda4</i> |
| 289 |
</pre> |
| 290 |
|
| 291 |
<p> |
| 292 |
Now create the filesystems on your newly created partitions (or logical |
| 293 |
volumes). |
| 294 |
</p> |
| 295 |
|
| 296 |
</body> |
| 297 |
</subsection> |
| 298 |
<subsection> |
| 299 |
<title>Activating the Swap Partition</title> |
| 300 |
<body> |
| 301 |
|
| 302 |
<p> |
| 303 |
<c>mkswap</c> is the command that is used to initialize swap partitions: |
| 304 |
</p> |
| 305 |
|
| 306 |
<pre caption="Creating a Swap signature"> |
| 307 |
# <i>mkswap /dev/sda3</i> |
| 308 |
</pre> |
| 309 |
|
| 310 |
<p> |
| 311 |
To activate the swap partition, use <c>swapon</c>: |
| 312 |
</p> |
| 313 |
|
| 314 |
<pre caption="Activating the swap partition"> |
| 315 |
# <i>swapon /dev/sda3</i> |
| 316 |
</pre> |
| 317 |
|
| 318 |
<p> |
| 319 |
Create and activate the swap now. |
| 320 |
</p> |
| 321 |
|
| 322 |
</body> |
| 323 |
</subsection> |
| 324 |
</section> |
| 325 |
<section> |
| 326 |
<title>Mounting</title> |
| 327 |
<body> |
| 328 |
|
| 329 |
<p> |
| 330 |
Now that your partitions are initialized and are housing a filesystem, it is |
| 331 |
time to mount those partitions. Use the <c>mount</c> command. Don't forget to |
| 332 |
create the necessary mount directories for every partition you created. As an |
| 333 |
example we mount the root and boot partition: |
| 334 |
</p> |
| 335 |
|
| 336 |
<pre caption="Mounting partitions"> |
| 337 |
# <i>mount /dev/sda4 /mnt/gentoo</i> |
| 338 |
# <i>mkdir /mnt/gentoo/boot</i> |
| 339 |
# <i>mount /dev/sda2 /mnt/gentoo/boot</i> |
| 340 |
</pre> |
| 341 |
|
| 342 |
<note> |
| 343 |
If you want your <path>/tmp</path> to reside on a separate partition, be sure to |
| 344 |
change its permissions after mounting: <c>chmod 1777 /mnt/gentoo/tmp</c>. This |
| 345 |
also holds for <path>/var/tmp</path>. |
| 346 |
</note> |
| 347 |
|
| 348 |
<p> |
| 349 |
We will also have to mount the proc filesystem (a virtual interface with the |
| 350 |
kernel) on <path>/proc</path>. But first we will need to place our files on the partitions. |
| 351 |
</p> |
| 352 |
|
| 353 |
<p> |
| 354 |
Continue with <uri link="?part=1&chap=5">Installing the Gentoo |
| 355 |
Installation Files</uri>. |
| 356 |
</p> |
| 357 |
|
| 358 |
</body> |
| 359 |
</section> |
| 360 |
</sections> |