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