ハンドブック:IA64/インストール/ディスク

From Gentoo Wiki
Jump to:navigation Jump to:search
This page is a translated version of the page Handbook:IA64/Installation/Disks and the translation is 100% complete.
IA64 ハンドブック
インストール
インストールについて
メディアの選択
ネットワーク設定
ディスクの準備
stage3のインストール
Gentooベースシステムのインストール
カーネルの設定
システムの設定
ツールのインストール
ブートローダの設定
締めくくり
Gentooの操作
Portageについて
USEフラグ
Portageの機能
Initスクリプトシステム
環境変数
Portageの操作
ファイルとディレクトリ
変数
ソフトウェアブランチの併用
追加ツール
カスタムPortageツリー
高度な機能
ネットワーク設定
はじめに
高度な設定
モジュール式ネットワーク
無線
機能の追加
動的な管理


ブロックデバイスの概要

ブロックデバイス

Gentoo Linuxの、そしてLinux一般の、ブロックデバイス、パーティション、Linuxファイルシステムを含めた、ディスクやファイルシステム中心の考え方について詳しく見てみましょう。ディスクの入出力とファイルシステムについて理解することで、インストールのためのパーティションとファイルシステムを構築できるようになります。

まずはブロックデバイスについて見ていきます。SCSIドライブやシリアルATAドライブは両方とも/dev/sda/dev/sdb/dev/sdcなどのようなデバイスハンドルとしてラベル付されます。更にモダンなマシンでは、PCI ExpressベースのNVMeソリッドステートディスクは、/dev/nvme0n1/dev/nvme0n2などのようなデバイスハンドルを持ちます。

下の表は、各種のブロックデバイスがシステム上のどこにあるかを判断するのに役立つでしょう:

デバイスの種類 デフォルトのデバイスハンドル 編集者メモと、考慮すべき点
SATA、SAS、SCSI、または USB フラッシュメモリ /dev/sda 2007 年頃から現在までに製造されたハードウェアで見られます。このデバイスハンドルはおそらく Linux 上でもっともよく使用されているものでしょう。この種のデバイスは SATA バスSCSIUSB バスを介してブロックストレージとして接続されます。例えば、最初の SATA デバイス上の最初のパーティションは /dev/sda1 という名前になります。
NVM Express (NVMe) /dev/nvme0n1 ソリッドステートテクノロジとして最新の NVMe ドライブは PCI Express バスに接続され、一般市場でもっとも高速な転送速度を持っています。2014 年頃以降のシステムは NVMe ハードウェアのサポートを備えているかもしれません。最初の NVMe デバイスの最初のパーティションは /dev/nvme0n1p1 という名前になります。
MMC、eMMC、および SD カード /dev/mmcblk0 embedded MMC デバイス、SD カード、そして他の種類のメモリーカードはデータ用のストレージとして有用です。つまり、多くのシステムはこれらの種類のデバイスからのブートを許可していないかもしれません。これらのデバイスに Linux をインストールして常用するのはおすすめできません。それらの設計目標である、ファイルの交換用に使うものと考えてください。短期バックアップとして使用すると便利かもしれません。

上のブロックデバイスは、ディスクへの抽象的なインターフェースを表しています。ユーザープログラムはこれらのブロックデバイスを用いて、デバイスが SATA、SCSI、もしくは他のものであるかどうかを心配することなしにディスクと通信することができます。プログラムは容易にディスク上の記憶領域を、ランダムアクセスできる 4096 バイト (4K) ごとの連続領域としてアドレッシングできます。


パーティション

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

Itanium systems use EFI, the Extensible Firmware Interface, for booting. The partition table format that EFI understands is called GPT, or GUID Partition Table. The partitioning program that understands GPT is called "parted", so that is the tool used below. Additionally, EFI can only read FAT filesystems, so that is the format to use for the EFI boot partition, where the kernel will be installed by "elilo".

Advanced storage

The IA64 Installation CDs provide support for LVM2. LVM2 increases the flexibility offered by the partitioning setup. During the installation instructions, we will focus on "regular" partitions, but it is still good to know LVM2 is supported as well.

Designing a partition scheme

How many partitions and how big?

The design of disk partition layout is highly dependent on the demands of the system and the file system(s) applied to the device. If there are lots of users, then it is advised to have /home on a separate partition which will increase security and make backups and other types of maintenance easier. If Gentoo is being installed to perform as a mail server, then /var should be a separate partition as all mails are stored inside the /var directory. Game servers may have a separate /opt partition since most gaming server software is installed therein. The reason for these recommendations is similar to the /home directory: security, backups, and maintenance.

In most situations on Gentoo, /usr and /var should be kept relatively large in size. /usr hosts the majority of applications available on the system and the Linux kernel sources (under /usr/src). By default, /var hosts the Gentoo ebuild repository (located at /var/db/repos/gentoo) which, depending on the file system, generally consumes around 650 MiB of disk space. This space estimate excludes the /var/cache/distfiles and /var/cache/binpkgs directories, which will gradually fill with source files and (optionally) binary packages respectively as they are added to the system.

How many partitions and how big very much depends on considering the trade-offs and choosing the best option for the circumstance. Separate partitions or volumes have the following advantages:

  • Choose the best performing filesystem for each partition or volume.
  • The entire system cannot run out of free space if one defunct tool is continuously writing files to a partition or volume.
  • If necessary, file system checks are reduced in time, as multiple checks can be done in parallel (although this advantage is realized more with multiple disks than it is with multiple partitions).
  • Security can be enhanced by mounting some partitions or volumes read-only, nosuid (setuid bits are ignored), noexec (executable bits are ignored), etc.


However, multiple partitions have certain disadvantages as well:

  • If not configured properly, the system might have lots of free space on one partition and little free space on another.
  • A separate partition for /usr/ may require the administrator to boot with an initramfs to mount the partition before other boot scripts start. Since the generation and maintenance of an initramfs is beyond the scope of this handbook, we recommend that newcomers do not use a separate partition for /usr/.
  • There is also a 15-partition limit for SCSI and SATA unless the disk uses GPT labels.
注意
Installations that intend to use systemd as the service and init system must have the /usr directory available at boot, either as part of the root filesystem or mounted via an initramfs.

What about swap space?

There is no perfect value for swap space size. The purpose of the space is to provide disk storage to the kernel when internal memory (RAM) is under pressure. A swap space allows for the kernel to move memory pages that are not likely to be accessed soon to disk (swap or page-out), which will free memory in RAM for the current task. Of course, if the pages swapped to disk are suddenly needed, they will need to be put back in memory (page-in) which will take considerably longer than reading from RAM (as disks are very slow compared to internal memory).

When a system is not going to run memory intensive applications or has lots of RAM available, then it probably does not need much swap space. However do note in case of hibernation that swap space is used to store the entire contents of memory (likely on desktop and laptop systems rather than on server systems). If the system requires support for hibernation, then swap space larger than or equal to the amount of memory is necessary.

As a general rule, the swap space size is recommended to be twice the internal memory (RAM). For systems with multiple hard disks, it is wise to create one swap partition on each disk so that they can be utilized for parallel read/write operations. The faster a disk can swap, the faster the system will run when data in swap space must be accessed. When choosing between rotational and solid state disks, it is better for performance to put swap on the SSD. Also, swap files can be used as an alternative to swap partitions; this is mostly interesting for systems with very limited disk space.


Non-default example partition scheme

An example partitioning for a 20GB disk is shown below, used as a demonstration laptop (containing webserver, mailserver, gnome, ...):

root #df -h
Filesystem    Type    Size  Used Avail Use% Mounted on
/dev/sda5     ext4    509M  132M  351M  28% /
/dev/sda2     ext4    5.0G  3.0G  1.8G  63% /home
/dev/sda7     ext4    7.9G  6.2G  1.3G  83% /usr
/dev/sda8     ext4   1011M  483M  477M  51% /opt
/dev/sda9     ext4    2.0G  607M  1.3G  32% /var
/dev/sda1     ext2     51M   17M   31M  36% /boot
/dev/sda6     swap    516M   12M  504M   2% <not mounted>
(Unpartitioned space for future usage: 2 GB)

/usr/ is rather full (83% used) here, but once all software is installed, /usr/ doesn't tend to grow that much. Although allocating a few gigabytes of disk space for /var/ may seem excessive, remember that portage uses this partition by default for compiling packages. To keep /var/ at a more reasonable size, such as 1GB, alter the PORTAGE_TMPDIR variable in /etc/portage/make.conf to point to the partition with enough free space for compiling extremely large packages such as LibreOffice.

Using parted to partition the disk

The following parts explain how to create the example partition layout used in the remainder of the installation instructions, namely:

Partition Description
/dev/sda1 EFI Boot partition
/dev/sda2 Swap partition
/dev/sda3 Root partition

Change the partition layout according to personal preference.

Viewing the current partition layout

parted is the GNU partition editor. Fire up parted on the disk (in our example, we use /dev/sda):

root #parted /dev/sda

Once in parted, a prompt that looks like this shows up:

(parted)

At this point one of the available commands is help, to see the other available commands. Another command is print to display the disk's current partition configuration:

(parted)print
Disk geometry for /dev/sda: 0.000-34732.890 megabytes
Disk label type: gpt
Minor    Start       End     Filesystem  Name                  Flags
1          0.017    203.938  fat32                             boot
2        203.938   4243.468  linux-swap
3       4243.469  34724.281  ext4

This particular configuration is very similar to the one recommended above. Note on the second line that the partition table is type is GPT. If it is different, then the ia64 system will not be able to boot from this disk. To explain how partitions are created, let's first remove the partitions and recreate them.

Removing all partitions

注意
Unlike fdisk and some other partitioning programs which postpone committing changes until the write instruction is given, parted commands take effect immediately. So once partitions are added or removed, there is no undo.

The easy way to remove all partitions and start fresh, which guarantees that we are using the correct partition type, is to make a new partition table using the mklabel command. This results in an empty GPT partition table.

(parted) mklabelgpt
(parted) mklabelprint
Disk geometry for /dev/sda: 0.000-34732.890 megabytes
Disk label type: gpt
Minor    Start       End     Filesystem  Name                  Flags

Now that the partition table is empty, we're ready to 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 EFI boot partition

First create a small EFI boot partition. This is required to be a FAT filesystem in order for the IA64 firmware to read it. Our example makes this 32 MB, which is appropriate for storing kernels and elilo configuration. Expect each IA64 kernel to be around 5 MB, so this configuration leaves some room to grow and experiment.

(parted)mkpart primary fat32 0 32
(parted)print
Disk geometry for /dev/sda: 0.000-34732.890 megabytes
Disk label type: gpt
Minor    Start       End     Filesystem  Name                  Flags
1          0.017     32.000  fat32

Creating the swap partition

Let's now create the swap partition. The classic size to make the swap partition was twice the amount of RAM in the system. In modern systems with lots of RAM, this is no longer necessary. For most desktop systems, a 512 megabyte swap partition is sufficient. For a server, consider something larger to reflect the anticipated needs of the server.

(parted)mkpart primary linux-swap 32 544
(parted)print
Disk geometry for /dev/sda: 0.000-34732.890 megabytes
Disk label type: gpt
Minor    Start       End     Filesystem  Name                  Flags
1          0.017     32.000  fat32
2         32.000    544.000

Creating the root partition

Finally, create the root partition. Our configuration will make the root partition to occupy the rest of the disk. We default to ext4, but it is possible to use ext2, jfs, reiserfs or xfs. The actual filesystem is not created in this step, but the partition table contains an indication of what kind of filesystem is stored on each partition, and it's a good idea to make the table match the intentions.

(parted)mkpart primary ext4 544 34732.890
(parted)print
Disk geometry for /dev/sda: 0.000-34732.890 megabytes
Disk label type: gpt
Minor    Start       End     Filesystem  Name                  Flags
1          0.017     32.000  fat32
2         32.000    544.000
3        544.000  34732.874

Exiting parted

To quit from parted, type quit. There's no need to take a separate step to save the partition layout since parted has been saving it all along. Parted will give a reminder to update the /etc/fstab file, which is done later in the installation instructions.

(parted)quit
Information: Don't forget to update /etc/fstab, if necessary.


ファイルシステムを作成する

はじめに

パーティションが作成できたら、その上にファイルシステムを作成します。次の節ではLinuxがサポートする各種ファイルシステムを紹介します。どのファイルシステムを使うかをすでに決めているなら、パーティションにファイルシステムを適用するへ進みましょう。そうでなければ、次の節を読んで利用可能なファイルシステムについて知るのがよいでしょう。

ファイルシステム

Linux は多くのファイルシステムをサポートしていますが、それらの多くは特定の目的をもって配備するのが賢明なものです。特定のファイルシステムのみが ia64 アーキテクチャ上で安定して動作するとされています - 重要なパーティションに実験的なファイルシステムを選択するときは、事前にファイルシステムのサポート状況を十分に知っておくことを推奨します。ext4 はすべてのプラットフォームで、すべての目的で推奨されるファイルシステムです。以下は、網羅的ではないリストです

btrfs
スナップショット、チェックサムによる自己修復、透過的圧縮、サブボリューム、RAIDの統合など、多くの先進機能を提供する次世代のファイルシステムです。 深刻な問題への対処がより新しい LTS カーネルブランチのリリースにしか含まれていないので、5.4.y より前のカーネルを btrfs と実運用するのは安全性の保証がありません。さらに古いカーネルブランチではファイルシステム破損の問題はよくあることで、4.4.y より古いものは特に危険で破損しやすいです。古い (5.4.y より前の) カーネルでは、圧縮が有効化されているとより破損が発生しやすいです。RAID 5/6 とクオータグループは、btrfs のすべてのバージョンで安全ではありません。さらに btrfs では内部断片化 (空き領域が DATA + SYSTEM チャンクにピン留めされているが、METADATA チャンクが必要としている) のために、df が空き領域を報告したのに ENOSPC でファイルシステムの操作に失敗するという、直感に反することが起きることがあります。加えて、a single 4K reference to a 128M extent inside btrfs は、空き領域が存在するが割り当てには利用できないということを引き起こすことがあります。これも df が空き領域を報告するのに btrfs は ENOSPC を返す原因になり得ます。sys-fs/btrfsmaintenance をインストールして定期的に実行するスクリプトを構成することで、btrfs をリバランスして ENOSPC 問題の可能性を減らすことができますが、空き領域が存在するのに ENOSPC のリスクは消えはしないでしょう。ENOSPC が発生するかは用途によります。運用中の ENOSPC のリスクが許容できない場合は、別のものを使うべきです。btrfs を使うなら、問題が発覚している構成を避けることを確実にしてください。ENOSPC は例外として、最新のカーネルブランチに存在する問題についての情報は btrfs wiki status page で確認できます。
ext4
もともと ext3 のフォークとして作られた ext4 は、新機能、パフォーマンスの向上と、ディスク上でのフォーマットの適度な変更による、サイズ制限の撤廃を提供します。ボリュームは1EBまで広げることができ、最大のファイルサイズは16TBです。古典的なext2/3のbitmap block割当ての代わりに、ext4 はextentを使い、大きなファイルでのパフォーマンスを向上し、断片化を減らしています。ext4は他にもより洗練されたアロケーションアルゴリズム(遅延割当てと複数ブロック割当て)を提供し、ファイルシステムドライバーに、ディスク上のデータのレイアウトを最適化するより多くの方法を与えています。ext4 は推奨される、全目的、全プラットフォームのファイルシステムです。
f2fs
Flash-Friendly File Systemはもともと、SamsungによってNANDフラッシュメモリで利用するために作られました。2016年Q2現在、このファイルシステムはまだ未熟なものと思われますが、GentooをmicroSDカードやUSBスティックや他のフラッシュベースの記憶装置にインストールする際にはすばらしい選択でしょう。
JFS
IBMの高パフォーマンスジャーナリングファイルシステムです。JFSは軽量、高速かつ信頼できる、B+木ベースのファイルシステムで、様々な条件で良いパフォーマンスが出ます。
XFS
メタデータジャーナリングのあるファイルシステムで、堅牢な機能セットを持ち、スケーラビリティに最適化されています。XFSはどうやら、様々なハードウェアの問題に対してはあまり寛大ではないようですが、継続的に新しい機能を取り入れるようにアップグレードしてきています。
VFAT
別名FAT32。Linuxでサポートされていますが、標準的なUNIXパーミッションの設定をサポートしていません。ほとんど、他のOS(Microsoft WindowsまたはApple macOS)との相互運用性/交換のために使われていますが、いくつかのシステムブートローダーファームウェア(たとえばUEFI)でも必要になります。UEFIシステムを使用している場合は、システムをブートするためにはVFATでフォーマットされたEFIシステムパーティションが必要になるでしょう。
NTFS
この "New Technology" ファイルシステムは、Windows NT 3.1以降のMicrosoft Windowsのフラッグシップファイルシステムです。VFATと同様、BSDやLinuxが正しく動作するために必要なUNIXパーミッション設定や拡張属性を保持しないため、ほとんどの場合ルートファイルシステムとして使うべきではありません。Microsoft Windowsとの相互運用/交換のためにのみ使うべきです(のみの強調に注意してください)。

パーティションにファイルシステムを適用する

パーティションまたはボリュームの上にファイルシステムを作成するには、ファイルシステムごとに異なるユーザースペースのユーティリティが利用可能です。下表でファイルシステムの名前をクリックすると、それぞれに追加の情報が得られます:

ファイルシステム 作成コマンド Minimal CD にある? パッケージ
btrfs mkfs.btrfs はい sys-fs/btrfs-progs
ext4 mkfs.ext4 はい sys-fs/e2fsprogs
f2fs mkfs.f2fs はい sys-fs/f2fs-tools
jfs mkfs.jfs はい sys-fs/jfsutils
reiserfs (非推奨) mkfs.reiserfs はい sys-fs/reiserfsprogs
xfs mkfs.xfs はい sys-fs/xfsprogs
vfat mkfs.vfat はい sys-fs/dosfstools
NTFS mkfs.ntfs はい sys-fs/ntfs3g

例えば、パーティション構造例の通りに、ルートパーティション(/dev/sda3)を ext4 として設定するには、次のコマンドが使えます:


root #mkfs.ext4 /dev/sda3

ext4 を (8 GiB 未満の) 小さいパーティションに使用するときは、十分な inode 数を確保できるように適切なオプションを指定してファイルシステムを作成する必要があります。これは、各ファイルシステム毎に、以下のコマンドのうちのひとつを使用することで行えます:

root #mkfs.ext4 -T small /dev/<device>

上のコマンドは通常では、「inodeあたりのバイト数」を16kBから4kBに減らすので、ファイルシステムに4倍のinode数を確保できます。

それでは、新しく作成したパーティション(または論理ボリューム)にファイルシステムを作成しましょう。

スワップパーティションを有効にする

mkswapはスワップパーティションを初期化するために使われるコマンドです:

root #mkswap /dev/sda2

スワップパーティションを有効化するには、swaponを使います:

root #swapon /dev/sda2

上述のコマンドで、スワップを作成して有効化しましょう。

ルートパーティションのマウント

ヒント
非 Gentoo インストールメディアを利用している場合、次を実行してマウントポイントを作成する必要があります:
root #mkdir --parents /mnt/gentoo

パーティションが初期化され、ファイルシステムを格納したので、それらのパーティションをマウントする時です。 mount コマンドを使用しますが、作成されたすべてのパーティションに必要なマウントディレクトリを作成することを忘れないでください。例として、 rootパーティションをマウントします。

root #mount /dev/sda3 /mnt/gentoo
注意
もし/tmp/を別のパーティションに置く必要があるなら、マウントしたあと権限の変更を忘れずに行ってください:
root #chmod 1777 /mnt/gentoo/tmp
/var/tmpについても同様です。

このあと解説の中で、proc ファイルシステム(仮想的なカーネルとのインターフェース)が、他のカーネル擬似ファイルシステムと同様にマウントされますが、まず最初は、Gentooインストールファイルをインストールします。