ハンドブック:PPC64/ブロック/ディスク

From Gentoo Wiki
Jump to:navigation Jump to:search
This page is a translated version of the page Handbook:PPC64/Blocks/Disks and the translation is 36% complete.


Although it is theoretically possible to use a full disk to house a Linux system, this is almost never done in practice. Instead, full disk block devices are split up in smaller, more manageable block devices. On most systems, these are called partitions. Other architectures use a similar technique, called slices.


パーティション構成の設計

パーティション数とサイズ

ディスクのパーティションレイアウトの設計は、システムに対する要求と、デバイスに適用されるファイルシステムに大きく依存します。多数のユーザがいる場合、セキュリティを向上し、バックアップの作成とその他のメンテナンスを容易にするために、/home を分離されたパーティションに配置することが推奨されます。もし メールサーバとして動作する場合は、/var を分離されたパーティションとし、すべてのメールを /var ディレクトリに保存すべきでしょう。ゲームサーバでは、ほとんどのゲームサーバソフトウェアは /opt にインストールされるので、/opt を分離されたパーティションとすることができます。これらが推奨される理由は最初の /home ディレクトリと同様で、セキュリティ、バックアップ、そしてメンテナンスです。

Gentoo では多くの場合、/usr/var は相対的に大きい容量を確保すべきです。/usr にはシステム上で利用可能なアプリケーションの大部分と、Linux カーネルソース (/usr/src 配下) が配置されます。デフォルトでは、/var には Gentoo ebuild リポジトリが (/var/db/repos/gentoo 配下に) 配置され、ファイルシステム依存ではあるものの通常 650 MiB ほどのディスク容量を消費します。この推定容量には /var/cache/distfiles/var/cache/binpkgs ディレクトリは含まれていません。これらはそれぞれ、ソースファイルとバイナリパッケージ (使用している場合) を格納するディレクトリで、システムに追加すればするほど大きくなっていきます。

適切なパーティションの数とサイズは、システムを取り巻く環境と、トレードオフを考慮することで大きく変わります。パーティションやボリュームを分離することには下記の利点があります:

  • それぞれのパーティションまたはボリュームに対して、最も性能が高いファイルシステムを選択できます
  • ゾンビプロセスがパーティションまたはボリュームに継続的に書き込みをした場合でも、システム全体の空き領域を使い切ることはありません
  • 必要ならば、複数のチェックを並行して実行することで、ファイルシステムチェックの時間を短縮できます (複数のパーティションよりも複数のディスクの方が効果を実感できます)
  • リードのみ、nosuid(setuidビット無効)、noexec(実行ビット無効)等のマウントオプションによって、セキュリティが向上します


しかし、複数パーティションにはデメリットもあります:

  • もし適切に設定されていないと、あるパーティションが空き領域をたくさん持ち、別のパーティションにはまったく空き領域がなくなるといったことが起こり得ます。
  • /usr/ を独立したパーティションにすると、他のブートスクリプトが動作する前にパーティションをマウントするために、initramfs を使ってブートする必要があるかもしれません。initramfs の生成と保守はこのハンドブックのスコープの範囲外ですので、慣れていない方が /usr を独立したパーティションとすることは推奨しません。
  • SCSI や SATA では仕様上の制約により、GPT ラベルを使用しない限りは 15 個までしかパーティションを作れません。
メモ
サービスおよび init システムとして systemd を使うつもりのインストールでは、/usr ディレクトリはルートファイルシステムの一部とするか、または initramfs によりマウントされるようにして、ブート時に利用できるようにしなくてはなりません。

スワップ領域について

スワップ領域のサイズについて完璧な値というものはありません。スワップ領域の目的は、メインメモリ(RAM)が逼迫した際、カーネルにディスク領域を提供するためにあります。スワップ領域があれば、カーネルは最近最も使われていないメモリページをディスクに書き出し(スワップもしくはページアウト)、現在のタスクのために RAM 上に置かれたメモリを開放します。もちろん、もしディスクにスワップされたページが急に必要になった場合は、これらのページはメモリに戻す(ページイン)必要があります。これには、RAM から読み込むより相当長い時間がかかります(メインメモリと比較してディスクはとても遅いためです)。

システムがメモリを大量に消費するアプリケーションを実行しないとき、またシステムが多くの RAM を持っているときは、それほど大きいスワップ領域は必要ではありません。しかし、ハイバネーションの際に、スワップ領域はメモリの内容すべてを保存するために使われる(サーバシステムよりも、デスクトップやラップトップシステムでよくあることです)ことに留意してください。システムにハイバネーションのサポートが必要な場合は、メモリの全体量以上のサイズのスワップ領域が必要です。

一般的なルールとして、スワップ領域のサイズは内部メモリ (RAM) の 2 倍であることが推奨されます。複数のハードディスクを備えるシステムでは、並列して読み込み/書き込み操作が行えるように、それぞれのディスクに 1 つずつスワップパーティションを作成するのが賢い方法です。スワップ空間内のデータにアクセスしなくてはならないときに、ディスクがより高速にスワップできるほど、システムもより高速に動作するでしょう。回転式ディスクとソリッドステートディスクを比較すると、SSD 上にスワップを置いたほうが高いパフォーマンスが発揮できます。また、スワップパーティションの代わりにスワップファイルを使用することもできます。これは主にディスク容量が非常に限られたシステムで興味深いものです。


Default: Using mac-fdisk

重要
These instructions are for the Apple G5 system.
Partition Description
/dev/sda1 Apple partition map, automatically created when the disk is formatted with a "mac" partition table.
/dev/sda2 New World boot block
/dev/sda3 Swap partition
/dev/sda4 Root partition

Start mac-fdisk:

root #mac-fdisk /dev/sda

First delete the partitions that have been cleared previously to make room for Linux partitions. Use the d key in mac-fdisk to delete those partition(s). It will ask for the partition number to delete.

Second, create an Apple_Bootstrap partition by pressing the b key. It will ask for a block from which to start. Enter the number of the first free partition, followed by entering a p. For instance this is 2p.

メモ
This partition is not a "boot" partition. It is not used by Linux at all; there is no need to place any filesystem on it and it should never be mounted. PPC users do not need an extra partition for /boot.

Now create a swap partition by pressing the c key. Again mac-fdisk will ask what block to start from. As we used 2 before to create the Apple_Bootstrap partition, enter 3p. When asked for the size, enter 512M (or whatever size needed). When asked for a name, enter swap (mandatory).

To create the root partition, enter c, followed by 4p to select from what block the root partition should start. When asked for the size, enter 4p again. mac-fdisk will interpret this as "Use all available space". When asked for the name, enter root (mandatory).

To finish up, write the partition to the disk using w and q to quit mac-fdisk.

メモ
To make sure everything is okay, run mac-fdisk once more to verify all the partitions are present. If a partition is absent, or it is missing some of the changes that were made, then reinitialize the partitions by pressing i in mac-fdisk. Note that this will recreate the partition map and thus remove all the partitions.

代替案: fdisk を用いる

重要
The following instructions are for IBM pSeries, iSeries, and OpenPower systems.
メモ
When planning to use a RAID disk array for the Gentoo installation on POWER5-based hardware, first run iprconfig to format the disks to Advanced Function format and create the disk array. Emerge sys-fs/iprutils after the installation is complete.

If the system has an ipr-based SCSI adapter, start the ipr utilities now.

root #/etc/init.d/iprinit start

The following parts explain how to create the example partition layout described previously, namely:

Partition Description
/dev/sda1 PPC PReP Boot partition
/dev/sda2 Swap partition
/dev/sda3 Root partition

Change or modify the partition layout according to personal preference.

Viewing current partition layout

fdisk is a popular and powerful tool to split a disk into partitions. Fire up fdisk on the current disk (in our example, we use /dev/sda):

root #fdisk /dev/sda
Command (m for help)

If there is still an AIX partition layout on the system, then the following error message will be displayed:

root #fdisk /dev/sda
  There is a valid AIX label on this disk.
  Unfortunately Linux cannot handle these
  disks at the moment.  Nevertheless some
  advice:
  1. fdisk will destroy its contents on write.
  2. Be sure that this disk is NOT a still vital
     part of a volume group. (Otherwise you may
     erase the other disks as well, if unmirrored.)
  3. Before deleting this physical volume be sure
     to remove the disk logically from your AIX
     machine.  (Otherwise you become an AIXpert).

Don't worry, new empty DOS partition table can be created by pressing o.

警告
This will destroy any installed AIX version!

Type p to display the disk current partition configuration:

Command (m for help):p
Disk /dev/sda: 30.7 GB, 30750031872 bytes
141 heads, 63 sectors/track, 6761 cylinders
Units = cylinders of 8883 * 512 = 4548096 bytes
  
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1          12       53266+  83  Linux
/dev/sda2              13         233      981571+  82  Linux swap
/dev/sda3             234         674     1958701+  83  Linux
/dev/sda4             675        6761    27035410+   5  Extended
/dev/sda5             675        2874     9771268+  83  Linux
/dev/sda6            2875        2919      199836   83  Linux
/dev/sda7            2920        3008      395262   83  Linux
/dev/sda8            3009        6761    16668918   83  Linux

This particular disk is configured to house six Linux filesystems (each with a corresponding partition listed as "Linux") as well as a swap partition (listed as "Linux swap").

Removing all partitions

First remove all existing partitions from the disk. Type d to delete a partition. For instance, to delete an existing /dev/sda1:

Command (m for help):d
Partition number (1-4): 1

The partition has been scheduled for deletion. It will no longer show up when typing p, but it will not be erased until the changes have been saved. If a mistake was made and the session needs to be aborted, then type q immediately and hit Enter and none of the partitions will be deleted or modified.

Now, assuming that indeed all partitions need to be wiped out, repeatedly type p to print out a partition listing and then type d and the number of the partition to delete it. Eventually, the partition table will show no more partitions:

Command (m for help):p
Disk /dev/sda: 30.7 GB, 30750031872 bytes
141 heads, 63 sectors/track, 6761 cylinders
Units = cylinders of 8883 * 512 = 4548096 bytes
  
Device Boot    Start       End    Blocks   Id  System

Now that the in-memory partition table is empty, let's create the partitions. We will use a default partitioning scheme as discussed previously. Of course, don't follow these instructions to the letter but adjust to personal preference.

Creating the PPC PReP boot partition

First create a small PReP boot partition. Type n to create a new partition, then p to select a primary partition, followed by 1 to select the first primary partition. When prompted for the first cylinder, hit Enter. When prompted for the last cylinder, type +7M to create a partition 7 MB in size. After this, type t to set the partition type, 1 to select the partition just created and then type in 41 to set the partition type to "PPC PReP Boot". Finally, mark the PReP partition as bootable.

メモ
The PReP partition has to be smaller than 8 MB!
Command (m for help):p
Disk /dev/sda: 30.7 GB, 30750031872 bytes
141 heads, 63 sectors/track, 6761 cylinders
Units = cylinders of 8883 * 512 = 4548096 bytes
  
   Device Boot      Start         End      Blocks   Id  System
Command (m for help):n
Command action
      e   extended
      p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-6761, default 1): 
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-6761, default
6761): +8M
Command (m for help):t
Selected partition 1
Hex code (type L to list codes): 41
Changed system type of partition 1 to 41 (PPC PReP Boot)
Command (m for help):a
Partition number (1-4): 1
Command (m for help):

Now, when looking at the partition table again (through p), the following partition information should be shown:

Command (m for help):p
Disk /dev/sda: 30.7 GB, 30750031872 bytes
141 heads, 63 sectors/track, 6761 cylinders
Units = cylinders of 8883 * 512 = 4548096 bytes
  
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1  *            1           3       13293   41  PPC PReP Boot

スワップパーティションを作成する

Now create the swap partition. To do this, type n to create a new partition, then p to tell fdisk to create a primary partition. Then type 2 to create the second primary partition, /dev/sda2 in our case. When prompted for the first cylinder, hit Enter. When prompted for the last cylinder, type +512M to create a partition 512MB in size. After this, type t to set the partition type, 2 to select the partition just created and then type in 82 to set the partition type to "Linux Swap". After completing these steps, typing p should display a partition table that looks similar to this:

Command (m for help):p
Disk /dev/sda: 30.7 GB, 30750031872 bytes
141 heads, 63 sectors/track, 6761 cylinders
Units = cylinders of 8883 * 512 = 4548096 bytes
  
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1           3       13293   41  PPC PReP Boot
/dev/sda2               4         117      506331   82  Linux swap

ルートパーティションを作成する

Finally, create the root partition. To do this, type n to create a new partition, then p to tell fdisk to create a primary partition. Then type 3 to create the third primary partition, /dev/sda3 in our case. When prompted for the first cylinder, hit Enter. When prompted for the last cylinder, hit enter to create a partition that takes up the rest of the remaining space on the disk. After completing these steps, typing p should display a partition table that looks similar to this:

Command (m for help):p
Disk /dev/sda: 30.7 GB, 30750031872 bytes
141 heads, 63 sectors/track, 6761 cylinders
Units = cylinders of 8883 * 512 = 4548096 bytes
  
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1           3       13293   41  PPC PReP Boot
/dev/sda2               4         117      506331   82  Linux swap
/dev/sda3             118        6761    29509326   83  Linux

パーティションのレイアウトを保存する

To save the partition layout and exit fdisk, type w.

Command (m for help):w