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