This is Gentoo's testing wiki. It is a non-operational environment and its textual content is outdated.

Please visit our production wiki at https://wiki.gentoo.org

Gentoo Linux x86 ハンドブック: Gentoo をインストールする

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


はじめに

ようこそ

まずはじめに、Gentooへようこそ!あなたは、選択と性能の世界に入ろうとしています。Gentooでは、全てが選択です。そのことは、インストールするときにもたびたび明らかになります。コンパイルを何回やらせたいか、Gentooをどのようにインストールしたいか、システムのロギングツールに何を使用したいかなどなど、ユーザに選択権があります。

Gentooは、高速で現代的なメタディストリビューションで、整理された柔軟なデザインになっています。Gentooは、フリーソフトウェアのエコシステムの上に成り立っており、内部をユーザに隠匿することがありません。Gentooで用いるパッケージ管理システムであるPortageはPythonで書かれていますので、ソースコードを容易に閲覧したり改変したりすることができます。Gentooで採用しているパッケージ化の手法は、(コンパイル済パッケージにも対応していますが、)ソースコードを用いるものです。Gentooの設定は、一般的なテキストファイルで行います。つまり言い換えれば、Gentooは、全てをユーザーに開放しています。

Gentooに実行させることの選択肢を全員が理解していることは、きわめて重要です。望まざることをユーザーに強いないよう、我々は努めています。もしかりにこれに反するようなことがあったならば、バグリポートを送ってください。

インストール作業の順序

Gentoo のインストール作業工程は、次章以降で説明する10のステップに分けられます。それぞれの段階を適切に完了させましょう。

ステップ 結果
1 Gentoo をインストール可能な作業環境にします。
2 Gentoo をインストールするためのインターネット接続の準備が完了します。
3 インストールする Gentoo をホストするハードディスクを初期化します。
4 インストールする環境を準備し、新たな環境にユーザーが chroot 可能にします。
5 Gentoo をインストールする全ての場合に共通する中核的なパッケージをインストールします。
6 Linux カーネルをインストールします。
7 Gentoo システムの主な設定ファイルを完成させます。
8 必要なシステムツールをインストールします。
9 適切なブートローダーもインストールし設定します。
10 インストールしたての Gentoo Linux 環境に繰り出す準備が完了します。

このハンドブックでは、一定の選択肢を提示したときには必ず、賛否両論の併記に努めます。デフォルトの選択肢で進める記載をした際にも(見出しに「デフォルト:」と記載)、他に取りうる選択肢も記載します(見出しに「代替案:」と記載)。決して、「デフォルトは Gentoo のお勧めだ」と考えないでください。デフォルトはあくまでも、多くのユーザーが利用すると思われる選択肢にすぎません。

ときには、追加可能な手順が続くことがあります。そのような手順は「追加可能:」と記載します。つまりこの手順は、Gentoo のインストール自体には必須ではありません。とはいえ、以前にした決断によっては必須になる追加手順もあります。その際には、その追加手順の説明の直前に、この旨を明記するとともに、原因となった決断をした時期も記載します。

Gentooのインストール方法

Gentoo は、さまざまな方法でインストールすることができます。ダウンロードしてインストールすることも、CD/DVD等の公式インストールメディアからインストールすることもできます。インストールメディアは USB メモリにインストールすることも、ネットワークブートすることもできます。さらには、インストール済の異なるディストリビューション環境や、(例えば Knoppix のような)Gentoo 以外のブータブルディスクといった非公式メディアからインストールすることも可能です。

この文書が扱っているのは、公式の Gentoo インストールメディアを用いる方法と、場合によってはネットワークブートによる方法です。

注意
Gentoo 以外のCDを用いる場合などの、ほかのインストール方法については、『Alternative installation guide』を読んでください。

また、我々が提供している『Gentoo インストールのヒントとトリック』 という文書も役にたつかもしれません。

トラブルがあったときは

インストール中に (またはインストールを説明しているハンドブックに) 何か問題を見つけたら、バグトラッキングシステムで既知のバグとして報告されていないかどうか、確認してみてください。 もし無いようであれば、私たちが対応できるように、その問題をバグ報告してください。 その (あなたが報告した) バグを担当する開発者たちを恐れないでください。取って喰われるようなことは (滅多に) ありませんから。

あなたが今読んでいる文書は、特定のアーキテクチャ向けということになっていますが、 他のアーキテクチャの情報も、その中に紛れ込んでしまっているかもしれない、ということを一応、先に言っておきます。これはGentooハンドブックの多くの部分が、全てのアーキテクチャに共通のテキストを使用していることに因ります (重複作業を減らして開発リソースを節約するため)。混乱しないように、このような部分は最小限に抑えていきたいと思っています。

その問題が、ユーザーの問題 (文書をよく読んだにもかかわらず起きたあなたのミス) なのか、ソフトウェアの問題 (インストール/文書をよくテストしたにもかかわらず起きた私たちのミス) なのか、はっきりしないときには、irc.freenode.net の #gentoo チャンネルに気軽に参加してみてください。そんなときじゃなくても全然かまわないんですけどね。

そういえば、Gentooについて何か分からないことがあったら、よくある質問を見てみてください。Gentoo Forums上にあるFAQsもあります。




X86 ハンドブック
インストール
インストールについて
メディアの選択
ネットワーク設定
ディスクの準備
stage3のインストール
Gentooベースシステムのインストール
カーネルの設定
システムの設定
ツールのインストール
ブートローダの設定
締めくくり
Gentooの操作
Portageについて
USEフラグ
Portageの機能
Initスクリプトシステム
環境変数
Portageの操作
ファイルとディレクトリ
変数
ソフトウェアブランチの併用
追加ツール
カスタムPortageツリー
高度な機能
ネットワーク設定
はじめに
高度な設定
モジュール式ネットワーク
無線
機能の追加
動的な管理


ハードウェア要件

始める前に、x86の機械に首尾よくGentooをインストールするために必要なハードウェアの条件を示します。


Minimal CD LiveDVD
CPU i486 or later i686 or later
Memory 256 MB 512 MB
Disk space 2.5 GB (excluding swap space)
Swap space At least 256 MB

The X86 project is a good place to be for more information about Gentoo's x86 support.


Gentoo Linux インストールメディア

MinimalインストールCD

Note
2018年8月23日現在、公式 Minimal CD は UEFI モードで起動できます。古いバージョンは BIOS (MBR) モードでのみ起動します。UEFI ブート可能なシステムを構築しようとしている読者は最新の ISO をダウンロードする必要があります。

Gentoo MinimalインストールCDは、独立したGentoo環境を含むブート可能イメージです。このCDを使うとLinuxをCDやその他のインストールメディアから起動することができます。起動時、接続されたハードウェアが検出されて適切なドライバが読み込まれます。 このイメージは、Gentooの開発者によってメンテナンスされるもので、インターネット接続さえできれば誰でもGentooをインストールできるようにします。

MinimalインストールCDは、install-x86-minimal-<release>.isoと呼ばれます。

必要なときに使うGentoo LiveDVD

必要な場合に使う、Gentooをインストール用の特別なDVDがGentoo Tenプロジェクトによって作成されています。この章以降で説明する方法は、MinimalインストールCDをターゲットにしているので、少々の差異があるかもしれません。しかしLiveDVD (または他の起動可能なLinux環境) は、ターミナル上で単純にsudo su -またはsudo -iを実行するだけで、rootプロンプトの取得を行えます。

Stage とは?

stage3 tarballは最小限のGentoo環境を含んだアーカイブで、このマニュアルに従ってインストールを進めるのに適しています。以前は、Gentooハンドブックでは3つのstage tarballから1つを選ぶインストール方法を説明していました。現在でもstage1とstage2 tarballを提供していますが、公式なインストール手順ではstage3 tarballを使用します。もしstage1またはstage2 tarballからインストールしたいのであれば、Gentoo FAQ内のGentooをstage1やstage2のアーカイブからインストールするには?を読んでください。

stage3 tarballは、公式Gentooミラーのいずれか のreleases/x86/autobuilds/からダウンロードできます。stageファイルは頻繁に更新され、インストールイメージの中には含まれていません。

ダウンロード

メディアの入手

Gentoo Linuxが使う既定のインストールメディアは、MinimalインストールCDで、とても小さいブータブルGentoo Linux環境を格納しています。この環境はGentooをインストールするために最適なツールをすべて含んでいます。このCDのイメージは、ダウンロードページから(推奨)か、たくさんの利用可能なミラーのいずれかを自分で選び、そのミラー上でISOが置いてある場所を訪れることで、ダウンロードできます。

ミラーからダウンロードするなら、以下の場所でMinimalインストールCDを見つけられます:

  1. releases/ディレクトリに行く。
  2. 関連するターゲットアーキテクチャのディレクトリ(例えばx86/)を選択する。
  3. autobuilds/ディレクトリを選択する。
  4. amd64x86アーキテクチャでは、それぞれcurrent-install-amd64-minimal/ or current-install-x86-minimal/のどちらかを選択する。他のすべてのアーキテクチャでは、current-iso/ディレクトリへ進む。
Note
armmipss390のような一部のターゲットアーキテクチャには、MinimalインストールCDがありません。現時点では、Gentoo Release Engineering projectはこれらのターゲット向けの.isoファイルの作成をサポートしていません。

この場所の中では、インストールメディアファイルは.isoという接尾辞 (拡張子) を持ちます。例えば、以下の一覧を見てみてください。

CODE releases/x86/autobuilds/current-iso/におけるダウンロード可能なファイルの一覧の例
[DIR] hardened/                                          05-Dec-2014 01:42    -   
[   ] install-x86-minimal-20141204.iso                 04-Dec-2014 21:04  208M  
[   ] install-x86-minimal-20141204.iso.CONTENTS        04-Dec-2014 21:04  3.0K  
[   ] install-x86-minimal-20141204.iso.DIGESTS         04-Dec-2014 21:04  740   
[TXT] install-x86-minimal-20141204.iso.DIGESTS.asc     05-Dec-2014 01:42  1.6K  
[   ] stage3-x86-20141204.tar.bz2                      04-Dec-2014 21:04  198M  
[   ] stage3-x86-20141204.tar.bz2.CONTENTS             04-Dec-2014 21:04  4.6M  
[   ] stage3-x86-20141204.tar.bz2.DIGESTS              04-Dec-2014 21:04  720   
[TXT] stage3-x86-20141204.tar.bz2.DIGESTS.asc          05-Dec-2014 01:42  1.5K

上記の例では、install-x86-minimal-20141204.isoというファイルがMinimalインストールCDそのものです。 しかし見て分かりますが、他の関係ファイルも存在しています:

  • .CONTENTSファイルは、インストールメディアで利用可能な全てのファイルの一覧を含むテキストファイルです。このファイルは、インストールメディアをダウンロードする前に、特定のファームウェアまたはドライバが含まれているかどうか調べるために使えます。
  • .DIGESTSファイルは、様々なハッシュ形式とアルゴリズムで計算したISOファイルのハッシュ値を含んでいます。このファイルは、ダウンロードしたISOファイルが破損しているか否かを調べるために使われます。
  • .DIGESTS.ascファイルは、(.DIGESTSのような) ISOファイルのハッシュ値だけではなく、ファイルのデジタル署名を含みます。これは両方ともダウンロードしたファイルが破損しているか否かを調べるために使われますが、同様にダウンロードしたものがGentooリリースエンジニアリングチームによって実際に提供されたものであり、改竄されていないかを調べるためにも用います。

今のところ、この場所で利用可能な他のファイルは無視してください。インストールがもっと進んだ後に再登場しますので。.isoファイルをダウンロードし、もしダウンロードの検証が必要であれば、.isoファイル用の.DIGESTS.ascファイルも同じようにダウンロードします。 .CONTENTSファイルはダウンロードする必要はありません。これからのインストール手順ではもう参照しないからです。.DIGESTSファイルと.DIGESTS.ascは、後者が署名されていることを除いて、同じ情報が含まれています。

ダウンロードしたファイルを検証する

注意
これは任意自由選択なステップで、Gentoo Linuxをインストールするために必須なものではありません。しかしながら、ダウンロードしたファイルが破損していないことを確かめ、Gentooインフラストラクチャ チームから実際に提供されていることを保証するため、推奨されます。

.DIGESTS.DIGESTS.ascファイルを通じ、ISOファイルの妥当性は、適切なツール群を用いて確認できます。この検証は通常、2つのステップで行われます。

  1. まず、デジタル署名を検証します。これは、インストール·ファイルがGentooリリースエンジニアリングチームによって提供されていることを確認するためです。
  2. デジタル署名が正しければ、ダウンロードされたファイル自体が破損していないかを確かめるため、チェックサムを検証します。

Microsoft Windows上での検証

Microsoft Windowsシステムでは、チェックサムとデジタル署名を検証するための適切なツール群が普通にある見込みはまずありません。

まずデジタル署名を検証するには、例えばGPG4Winのようなツールを利用できます。インストール後、Gentooリリースエンジニアリングチームの公開鍵をインポートする必要があります。鍵の一覧は署名のページで提供されています。インポート後、ユーザは.DIGESTS.ascファイルの署名を検証できるようになります。

重要
これは.DIGESTSファイルが正しいことを検証しません。.DIGESTS.ascが正しいことだけを検証します。このことはまた、チェックサムが.DIGESTS.ascファイルに含まれる値を用いて検証されるべきであることを意味します。そのため、上記の手順では.DIGESTS.ascファイルのみダウンロードするようになっています。

チェックサム自体は、Hashcalcアプリケーションを使って検証できますが、多数の代替も同様に存在します。ほとんどの場合、これらのツールはユーザに対して計算されたチェックサムを表示しますので、ユーザはこのチェックサムを.DIGESTS.ascファイルの中にある値で検証する必要があります。

Linux上での検証

Linuxシステムでは、デジタル署名を検証する最も一般的な方法はapp-crypt/gnupgソフトウェアを使うことです。このパッケージがインストールされていると、.DIGESTS.ascファイルのデジタル署名を検証するために以下のコマンドが使えます。

まず、適切な鍵を利用できるようにするため、署名のページよりダウンロードします:

user $gpg --keyserver hkp://keys.gnupg.net --recv-keys 0xBB572E0E2D182910
gpg: requesting key 0xBB572E0E2D182910 from hkp server pool.sks-keyservers.net
gpg: key 0xBB572E0E2D182910: "Gentoo Linux Release Engineering (Automated Weekly Release Key) <releng@gentoo.org>" 1 new signature
gpg: 3 marginal(s) needed, 1 complete(s) needed, classic trust model
gpg: depth: 0  valid:   3  signed:  20  trust: 0-, 0q, 0n, 0m, 0f, 3u
gpg: depth: 1  valid:  20  signed:  12  trust: 9-, 0q, 0n, 9m, 2f, 0u
gpg: next trustdb check due at 2018-09-15
gpg: Total number processed: 1
gpg:         new signatures: 1

次に.DIGESTS.ascファイルのデジタル署名を検証します:

user $gpg --verify install-x86-minimal-20141204.iso.DIGESTS.asc
gpg: Signature made Fri 05 Dec 2014 02:42:44 AM CET
gpg:                using RSA key 0xBB572E0E2D182910
gpg: Good signature from "Gentoo Linux Release Engineering (Automated Weekly Release Key) <releng@gentoo.org>" [unknown]
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: 13EB BDBE DE7A 1277 5DFD  B1BA BB57 2E0E 2D18 2910

すべてが確実であることを完全に確かめるために、表示された指紋がGentooの署名のページ上にある指紋かどうかを調べます。

デジタル署名が検証されれば、次にチェックサムを確認します。これは、ダウンロードしたISOファイルが破損していないことを確認するためです。 .DIGESTS.ascファイルには、複数のハッシュアルゴリズムが含まれています。そのため、適切なものを検証するための1つの方法としては、.DIGESTS.ascに登録された先頭のチェックサムを見てください。 例えば、SHA512チェックサムを取得します:

user $grep -A 1 -i sha512 install-x86-minimal-20141204.iso.DIGESTS.asc
# SHA512 HASH
364d32c4f8420605f8a9fa3a0fc55864d5b0d1af11aa62b7a4d4699a427e5144b2d918225dfb7c5dec8d3f0fe2cddb7cc306da6f0cef4f01abec33eec74f3024  install-x86-minimal-20141204.iso
--
# SHA512 HASH
0719a8954dc7432750de2e3076c8b843a2c79f5e60defe43fcca8c32ab26681dfb9898b102e211174a895ff4c8c41ddd9e9a00ad6434d36c68d74bd02f19b57f  install-x86-minimal-20141204.iso.CONTENTS

上記の出力では、2つのSHA512チェックサムが表示されます。1つはinstall-x86-minimal-20141204.isoファイルのもので、1つはそれに付随する.CONTENTSファイルです。最初のチェックサムだけが重要で、その 比較対象となるSHA512チェックサムは、以下のように生成することができます:

user $sha512sum install-x86-minimal-20141204.iso
364d32c4f8420605f8a9fa3a0fc55864d5b0d1af11aa62b7a4d4699a427e5144b2d918225dfb7c5dec8d3f0fe2cddb7cc306da6f0cef4f01abec33eec74f3024  install-x86-minimal-20141204.iso

双方のチェックサムが同一であれば、ファイルは破損していません。インストールを続行できます。

ディスクに書き込む

もちろん、ISOファイルをダウンロードしただけでは、Gentoo Linuxのインストールは始められません。ISOファイルはブートCDに書き込む必要があり、しかもISOファイルそのものではなく、ISOファイルの中身を書き込む必要があります。以下にいくつかのよく使われる方法を示します--より詳細な情報が知りたい場合はISOファイルの書き込みについてのわたしたちのFAQを見てください。

Microsoft Windowsでの書き込み

Microsoft Windowsでは、ISOファイルのCD書き込みをサポートする多数のツールが存在します。

  • EasyCD Creatorを使う場合は、FileRecord CD from CD imageの順に選択してください。次に、Files of typeISO image fileに変更してください。それから、ISOファイルの場所を見つけてOpenをクリックしてください。Start recordingをクリックすると、CD-RにISOイメージが正しく書き込まれます。
  • Nero Burning ROMを使う場合は、自動的にポップアップするウィザードを中止して、FileメニューからBurn Imageを選択してください。書き込むイメージを選択して、Openをクリックしてください。Burnボタンを押して、ほやほやのCDが焼きあがるのを待ちましょう。

Linuxでの書き込み

Linuxでは、ISOファイルのCD書き込みにcdrecordコマンドが利用可能です。これはapp-cdr/cdrtoolsパッケージに含まれます。

例えば、/dev/sr0デバイス(これはシステム上の1番目のCDデバイスです。必要ならば正しいデバイスに置き換えてください)のCDにISOファイルを書き込むには:

user $cdrecord dev=/dev/sr0 install-x86-minimal-20141204.iso

GUIを好むユーザーはkde-apps/k3bパッケージの一部であるK3Bを使うことができます。K3Bでは、ToolsメニューからBurn CD Imageを選択してください。それから、K3Bの指示に従ってください。

起動する

Booting the installation media

Once the installation media is ready, it is time to boot it. Insert the media in the system, reboot, and enter the motherboard's firmware user interface. This is usually performed by pressing a keyboard key such as DEL, F1, F10, or ESC during the Power-On Self-test (POST) process. The 'trigger' key varies depending on the system and motherboard. If it is not obvious use an internet search engine and do some research using the motherboard's model name as the search keyword. Results should be easy to determine. Once inside the motherboard's firmware menu, change the boot order so that the external bootable media (CD/DVD disks or USB drives) are tried before the internal disk devices. Without this change, the system will most likely reboot to the internal disk device, ignoring the external boot media.

Important
When installing Gentoo with the purpose of using the UEFI interface instead of BIOS, it is recommended to boot with UEFI immediately. If not, then it might be necessary to create a bootable UEFI USB stick (or other medium) once before finalizing the Gentoo Linux installation.

If not yet done, ensure that the installation media is inserted or plugged into the system, and reboot. A boot prompt should be shown. At this screen, Enter will begin the boot process with the default boot options. To boot the installation media with custom boot options, specify a kernel followed by boot options and then hit Enter.

At the boot prompt, users get the option of displaying the available kernels (F1) and boot options (F2). If no choice is made within 15 seconds (either displaying information or using a kernel) then the installation media will fall back to booting from disk. This allows installations to reboot and try out their installed environment without the need to remove the CD from the tray (something well appreciated for remote installations).

Specifying a kernel was mentioned. On the Minimal installation media, only two predefined kernel boot options are provided. The default option is called gentoo. The other being the -nofb variant; this disables kernel framebuffer support.

The next section displays a short overview of the available kernels and their descriptions:

Kernel choices

gentoo
Default kernel with support for K8 CPUs (including NUMA support) and EM64T CPUs.
gentoo-nofb
Same as gentoo but without framebuffer support.
memtest86
Test the local RAM for errors.

Alongside the kernel, boot options help in tuning the boot process further.

Hardware options

acpi=on
This loads support for ACPI and also causes the acpid daemon to be started by the CD on boot. This is only needed if the system requires ACPI to function properly. This is not required for Hyperthreading support.
acpi=off
Completely disables ACPI. This is useful on some older systems and is also a requirement for using APM. This will disable any Hyperthreading support of your processor.
console=X
This sets up serial console access for the CD. The first option is the device, usually ttyS0 on x86, followed by any connection options, which are comma separated. The default options are 9600,8,n,1.
dmraid=X
This allows for passing options to the device-mapper RAID subsystem. Options should be encapsulated in quotes.
doapm
This loads APM driver support. This also requires that acpi=off.
dopcmcia
This loads support for PCMCIA and Cardbus hardware and also causes the pcmcia cardmgr to be started by the CD on boot. This is only required when booting from PCMCIA/Cardbus devices.
doscsi
This loads support for most SCSI controllers. This is also a requirement for booting most USB devices, as they use the SCSI subsystem of the kernel.
sda=stroke
This allows the user to partition the whole hard disk even when the BIOS is unable to handle large disks. This option is only used on machines with an older BIOS. Replace sda with the device that requires this option.
ide=nodma
This forces the disabling of DMA in the kernel and is required by some IDE chipsets and also by some CDROM drives. If the system is having trouble reading from the IDE CDROM, try this option. This also disables the default hdparm settings from being executed.
noapic
This disables the Advanced Programmable Interrupt Controller that is present on newer motherboards. It has been known to cause some problems on older hardware.
nodetect
This disables all of the autodetection done by the CD, including device autodetection and DHCP probing. This is useful for doing debugging of a failing CD or driver.
nodhcp
This disables DHCP probing on detected network cards. This is useful on networks with only static addresses.
nodmraid
Disables support for device-mapper RAID, such as that used for on-board IDE/SATA RAID controllers.
nofirewire
This disables the loading of Firewire modules. This should only be necessary if your Firewire hardware is causing a problem with booting the CD.
nogpm
This disables gpm console mouse support.
nohotplug
This disables the loading of the hotplug and coldplug init scripts at boot. This is useful for doing debugging of a failing CD or driver.
nokeymap
This disables the keymap selection used to select non-US keyboard layouts.
nolapic
This disables the local APIC on Uniprocessor kernels.
nosata
This disables the loading of Serial ATA modules. This is used if the system is having problems with the SATA subsystem.
nosmp
This disables SMP, or Symmetric Multiprocessing, on SMP-enabled kernels. This is useful for debugging SMP-related issues with certain drivers and motherboards.
nosound
This disables sound support and volume setting. This is useful for systems where sound support causes problems.
nousb
This disables the autoloading of USB modules. This is useful for debugging USB issues.
slowusb
This adds some extra pauses into the boot process for slow USB CDROMs, like in the IBM BladeCenter.

Logical volume/device management

dolvm
This enables support for Linux's Logical Volume Management.

Other options

debug
Enables debugging code. This might get messy, as it displays a lot of data to the screen.
docache
This caches the entire runtime portion of the CD into RAM, which allows the user to umount /mnt/cdrom and mount another CDROM. This option requires that there is at least twice as much available RAM as the size of the CD.
doload=X
This causes the initial ramdisk to load any module listed, as well as dependencies. Replace X with the module name. Multiple modules can be specified by a comma-separated list.
dosshd
Starts sshd on boot, which is useful for unattended installs.
passwd=foo
Sets whatever follows the equals as the root password, which is required for dosshd since the root password is by default scrambled.
noload=X
This causes the initial ramdisk to skip the loading of a specific module that may be causing a problem. Syntax matches that of doload.
nonfs
Disables the starting of portmap/nfsmount on boot.
nox
This causes an X-enabled LiveCD to not automatically start X, but rather, to drop to the command line instead.
scandelay
This causes the CD to pause for 10 seconds during certain portions the boot process to allow for devices that are slow to initialize to be ready for use.
scandelay=X
This allows the user to specify a given delay, in seconds, to be added to certain portions of the boot process to allow for devices that are slow to initialize to be ready for use. Replace X with the number of seconds to pause.
Note
The bootable media will check for no* options before do* options, so that options can be overridden in the exact order specified.

Now boot the media, select a kernel (if the default gentoo kernel does not suffice) and boot options. As an example, we boot the gentoo kernel, with dopcmcia as a kernel parameter:

boot:gentoo dopcmcia

Next the user will be greeted with a boot screen and progress bar. If the installation is done on a system with a non-US keyboard, make sure to immediately press Alt+F1 to switch to verbose mode and follow the prompt. If no selection is made in 10 seconds the default (US keyboard) will be accepted and the boot process will continue. Once the boot process completes, the user is automatically logged in to the "Live" Gentoo Linux environment as the root user, the super user. A root prompt is displayed on the current console, and one can switch to other consoles by pressing Alt+F2, Alt+F3 and Alt+F4. Get back to the one started on by pressing Alt+F1.



例外的なハードウェア構成

インストールメディアが起動するとき、すべてのハードウェア機器を検出して適切なカーネルモジュールを読み込もうとします。これは非常に多くの場合、とても良い仕事をします。しかしある場合において、システムに必要なカーネルモジュールを自動で読み込まないかもしれません。PCI自動検出機能がシステムのハードウェアを見逃した場合、適切なカーネルモジュールを手動で読み込む必要があります。

次の例は、(ある種類のネットワークインタフェイスをサポートする) 8139tooモジュールを読み込みます:

root #modprobe 8139too

追加可能: ユーザアカウント

インストール環境に他の人たちがアクセスする必要があったり、インストールメディア上で非rootユーザでコマンドを実行する(例えば、セキュリティ上の理由から、root権限無しでirssiを使ってチャットする)必要があるなら、別のユーザアカウントを作成し、強いrootパスワードを設定する必要があります。

rootパスワードを変更するには、passwdユーティリティを使ってください:

root #passwd
New password: (新しいパスワードを入力)
Re-enter password: (もう一度新しいパスワードを入力)

ユーザーアカウントを作成するためには、まずアカウントの資格情報を、次にパスワードを入力します。このために、useraddpasswdコマンドを使います。

次の例では、johnというユーザが作成されます:

root #useradd -m -G users john
root #passwd john
New password: (Enter john's password)
Re-enter password: (Re-enter john's password)

現在のrootユーザから新しく作成したユーザアカウントに切り替えるには、suコマンドを使ってください:

root #su - john

追加可能:インストール中のドキュメント閲覧

TTY

Gentooハンドブックをインストール中に見るには、最初に上記の方法でユーザアカウントを作ってください。そしてAlt+F2を押すことで新しい端末を使い始められます。

インストール中、 linksコマンドでGentooハンドブックを閲覧できます。もちろん、インターネット接続が機能し始めた瞬間からですけど。

user $links https://wiki.gentoo.org/wiki/Handbook:X86

元々の端末に戻るには、Alt+F1を押してください。

GNU Screen

公式 Gentoo インストールメディアにはデフォルトで GNU Screen ユーティリティがインストールされています。熟練の Linux ファンにとっては、上に書いた複数の TTY を使う方法よりも、ペインを分割してインストール指示を読むために screen を使うほうが効率がいいかもしれません。

追加可能:SSHデーモンの開始

他のユーザーがインストール中にシステムにアクセスできるようにする(インストール中のサポートをしたり、あるいは全て遠隔操作で行うため)ためには、(前述の通り)ユーザーアカウントを作成し、SSHデーモンを起動する必要があります。

OpenRC 上で SSH デーモンを始動させるためには、次のコマンドを実行します:

root #rc-service sshd start
Note
ユーザーがシステムにログオンすると、(指紋・fingerprint と呼ばれるもので) ホスト鍵を確認するようメッセージが表示されると思います。これはSSHサーバーへの最初の接続では期待される典型的な挙動です。ところが、この後の手順でシステムのセットアップが完了した後、改めてログオンしようとすると、SSHクライアントはホスト鍵が変更されていると警告します。SSH的には別のサーバー (現在インストールに使っているLive環境ではなく、新しくインストールされた Gentoo システム) にログオンしようとしているように見えるのです。この場合は画面上の指示に従い、クライアント側で記憶しているホスト鍵を更新しましょう。

sshdを使えるようにするには、ネットワークを適切に機能させる必要があります。ネットワーク設定の章を参照してください。




X86 Handbook
Installation
About the installation
Choosing the media
Configuring the network
Preparing the disks
Installing stage3
Installing base system
Configuring the kernel
Configuring the system
Installing tools
Configuring the bootloader
Finalizing
Working with Gentoo
Portage introduction
USE flags
Portage features
Initscript system
Environment variables
Working with Portage
Files and directories
Variables
Mixing software branches
Additional tools
Custom package repository
Advanced features
Network configuration
Getting started
Advanced configuration
Modular networking
Wireless
Adding functionality
Dynamic management


Automatic network detection

Maybe it just works?

If the system is plugged into an Ethernet network with a DHCP server, it is very likely that the networking configuration has already been set up automatically. If so, then the many included network-aware commands on the installation CD such as ssh, scp, ping, irssi, wget, and links, among others, will work immediately.

Determine interface names

ifconfig command

If networking has been configured, the ifconfig command should list one or more network interfaces (besides lo). In the example below eth0 shows up:

root #ifconfig
eth0      Link encap:Ethernet  HWaddr 00:50:BA:8F:61:7A
          inet addr:192.168.0.2  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::50:ba8f:617a/10 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1498792 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1284980 errors:0 dropped:0 overruns:0 carrier:0
          collisions:1984 txqueuelen:100
          RX bytes:485691215 (463.1 Mb)  TX bytes:123951388 (118.2 Mb)
          Interrupt:11 Base address:0xe800 

As a result of the shift towards predictable network interface names, the interface name on the system can be quite different from the old eth0 naming convention. Recent installation media might show regular network interfaces names like eno0, ens1, or enp5s0. Look for the interface in the ifconfig output that has an IP address related to the local network.

Tip
If no interfaces are displayed when the standard ifconfig command is used, try using the same command with the -a option. This option forces the utility to show all network interfaces detected by the system whether they be in an up or down state. If ifconfig -a produces no results then the hardware is faulty or the driver for the interface has not been loaded into the kernel. Both situations reach beyond the scope of this Handbook. Contact #gentoo for support.

ip command

As an alternative to ifconfig, the ip command can be used to determine interface names. The following example shows the output of ip addr (of another system so the information shown is different from the previous example):

root #ip addr
2: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether e8:40:f2:ac:25:7a brd ff:ff:ff:ff:ff:ff
    inet 10.0.20.77/22 brd 10.0.23.255 scope global eno1
       valid_lft forever preferred_lft forever
    inet6 fe80::ea40:f2ff:feac:257a/64 scope link 
       valid_lft forever preferred_lft forever

The output above may be a bit more complicated to read than alternative. The interface name in the above example directly follows the number; it is eno1.

In the remainder of this document, the handbook will assume that the operating network interface is called eth0.

Optional: Configure any proxies

If the Internet is accessed through a proxy, then it is necessary to set up proxy information during the installation. It is very easy to define a proxy: just define a variable which contains the proxy server information.

In most cases, it is sufficient to define the variables using the server hostname. As an example, we assume the proxy is called proxy.gentoo.org and the port is 8080.

To set up an HTTP proxy (for HTTP and HTTPS traffic):

root #export http_proxy="http://proxy.gentoo.org:8080"

To set up an FTP proxy:

root #export ftp_proxy="ftp://proxy.gentoo.org:8080"

To set up an RSYNC proxy:

root #export RSYNC_PROXY="proxy.gentoo.org:8080"

If the proxy requires a username and password, use the following syntax for the variable:

CODE Adding username/password to the proxy variable
http://username:password@proxy.gentoo.org:8080

Testing the network

Try pinging your ISP's DNS server (found in /etc/resolv.conf) and a web site of choice. This ensures that the network is functioning properly and that the network packets are reaching the net, DNS name resolution is working correctly, etc.

root #ping -c 3 www.gentoo.org

If this all works, then the remainder of this chapter can be skipped to jump right to the next step of the installation instructions (Preparing the disks).

Automatic network configuration

If the network doesn't work immediately, some installation media allow the user to use net-setup (for regular or wireless networks), pppoe-setup (for ADSL users) or pptp (for PPTP users).

If the installation medium does not contain any of these tools, continue with the Manual network configuration.

Default: Using net-setup

The simplest way to set up networking if it didn't get configured automatically is to run the net-setup script:

root #net-setup eth0

net-setup will ask some questions about the network environment. When all is done, the network connection should work. Test the network connection as stated before. If the tests are positive, congratulations! Skip the rest of this section and continue with Preparing the disks.

If the network still doesn't work, continue with Manual network configuration.

Alternative: Using PPP

Assuming PPPoE is needed to connect to the Internet, the installation CD (any version) has made things easier by including ppp. Use the provided pppoe-setup script to configure the connection. During the setup the Ethernet device that is connected to your ADSL modem, the username and password, the IPs of the DNS servers and if a basic firewall is needed or not will be asked.

root #pppoe-setup
root #pppoe-start

If something goes wrong, double-check that the username and password are correct by looking at etc/ppp/pap-secrets or /etc/ppp/chap-secrets and make sure to use the right Ethernet device. If the Ethernet device does not exist, the appropriate network modules need to be loaded. In that case continue with Manual network configuration as it will explain how to load the appropriate network modules there.

If everything worked, continue with Preparing the disks.

Alternative: Using PPTP

If PPTP support is needed, use pptpclient which is provided by the installation CDs. But first make sure that the configuration is correct. Edit /etc/ppp/pap-secrets or /etc/ppp/chap-secrets so it contains the correct username/password combination:

root #nano -w /etc/ppp/chap-secrets

Then adjust /etc/ppp/options.pptp if necessary:

root #nano -w /etc/ppp/options.pptp

When all that is done, run pptp (along with the options that couldn't be set in options.pptp) to connect the server:

root #pptp <server ip>

Now continue with Preparing the disks.

Manual network configuration

Loading the appropriate network modules

When the Installation CD boots, it tries to detect all the hardware devices and loads the appropriate kernel modules (drivers) to support the hardware. In the vast majority of cases, it does a very good job. However, in some cases, it may not auto-load the kernel modules needed.

If net-setup or pppoe-setup failed, then it is possible that the network card wasn't found immediately. This means users may have to load the appropriate kernel modules manually.

To find out what kernel modules are provided for networking, use the ls command:

root #ls /lib/modules/`uname -r`/kernel/drivers/net

If a driver is found for the network device, use modprobe to load the kernel module. For instance, to load the pcnet32 module:

root #modprobe pcnet32

To check if the network card is now detected, use ifconfig. A detected network card would result in something like this (again, eth0 here is just an example):

root #ifconfig eth0
eth0      Link encap:Ethernet  HWaddr FE:FD:00:00:00:00  
          BROADCAST NOARP MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

If however the following error is shown, the network card is not detected:

root #ifconfig eth0
eth0: error fetching interface information: Device not found

The available network interface names on the system can be listed through the /sys file system:

root #ls /sys/class/net
dummy0  eth0  lo  sit0  tap0  wlan0

In the above example, 6 interfaces are found. The eth0 one is most likely the (wired) Ethernet adapter whereas wlan0 is the wireless one.

Assuming that the network card is now detected, retry net-setup or pppoe-setup again (which should work now), but for the hardcore people we explain how to configure the network manually as well.

Select one of the following sections based on your network setup:

Using DHCP

DHCP (Dynamic Host Configuration Protocol) makes it possible to automatically receive networking information (IP address, netmask, broadcast address, gateway, nameservers etc.). This only works if a DHCP server is in the network (or if the ISP provider provides a DHCP service). To have a network interface receive this information automatically, use dhcpcd:

root #dhcpcd eth0

Some network administrators require that the hostname and domainname provided by the DHCP server is used by the system. In that case, use:

root #dhcpcd -HD eth0

If this works (try pinging some Internet server, like Google's 8.8.8.8 or Cloudflare's 1.1.1.1), then everything is set and ready to continue. Skip the rest of this section and continue with Preparing the disks.

Preparing for wireless access

Note
Support for the iw command might be architecture-specific. If the command is not available see if the net-wireless/iw package is available for the current architecture. The iw command will be unavailable unless the net-wireless/iw package has been installed.

When using a wireless (802.11) card, the wireless settings need to be configured before going any further. To see the current wireless settings on the card, one can use iw. Running iw might show something like:

root #iw dev wlp9s0 info
Interface wlp9s0
	ifindex 3
	wdev 0x1
	addr 00:00:00:00:00:00
	type managed
	wiphy 0
	channel 11 (2462 MHz), width: 20 MHz (no HT), center1: 2462 MHz
	txpower 30.00 dBm

To check for a current connection:

root #iw dev wlp9s0 link
Not connected.

or

root #iw dev wlp9s0 link
Connected to 00:00:00:00:00:00 (on wlp9s0)
	SSID: GentooNode
	freq: 2462
	RX: 3279 bytes (25 packets)
	TX: 1049 bytes (7 packets)
	signal: -23 dBm
	tx bitrate: 1.0 MBit/s
Note
Some wireless cards may have a device name of wlan0 or ra0 instead of wlp9s0. Run ip link to determine the correct device name.

For most users, there are only two settings needed to connect, the ESSID (aka wireless network name) and, optionally, the WEP key.

  • First, ensure the interface is active:
root #ip link set dev wlp9s0 up
  • To connect to an open network with the name GentooNode:
root #iw dev wlp9s0 connect -w GentooNode
  • To connect with a hex WEP key, prefix the key with d::
root #iw dev wlp9s0 connect -w GentooNode key 0:d:1234123412341234abcd
  • To connect with an ASCII WEP key:
root #iw dev wlp9s0 connect -w GentooNode key 0:some-password
Note
If the wireless network is set up with WPA or WPA2, then wpa_supplicant needs to be used. For more information on configuring wireless networking in Gentoo Linux, please read the Wireless networking chapter in the Gentoo Handbook.

Confirm the wireless settings by using iw dev wlp9s0 link. Once wireless is working, continue configuring the IP level networking options as described in the next section (Understanding network terminology) or use the net-setup tool as described previously.

Understanding network terminology

Note
If the IP address, broadcast address, netmask and nameservers are known, then skip this subsection and continue with Using ifconfig and route.

If all of the above fails, the network will need to be configured manually. This is not difficult at all. However, some knowledge of network terminology and basic concepts might be necessary. After reading this section, users will know what a gateway is, what a netmask serves for, how a broadcast address is formed and why systems need nameservers.

In a network, hosts are identified by their IP address (Internet Protocol address). Such an address is perceived as a combination of four numbers between 0 and 255. Well, at least when using IPv4 (IP version 4). In reality, such an IPv4 address consists of 32 bits (ones and zeros). Let's view an example:

CODE Example of an IPv4 address
IP Address (numbers):   192.168.0.2
IP Address (bits):      11000000 10101000 00000000 00000010
                        -------- -------- -------- --------
                           192      168       0        2
Note
The successor of IPv4, IPv6, uses 128 bits (ones and zeros). In this section, the focus is on IPv4 addresses.

Such an IP address is unique to a host as far as all accessible networks are concerned (i.e. every host that one wants to be able to reach must have a unique IP address). In order to distinguish between hosts inside and outside a network, the IP address is divided in two parts: the network part and the host part.

The separation is written down with the netmask, a collection of ones followed by a collection of zeros. The part of the IP that can be mapped on the ones is the network-part, the other one is the host-part. As usual, the netmask can be written down as an IP address.

CODE Example of network/host separation
IP address:    192      168      0         2
            11000000 10101000 00000000 00000010
Netmask:    11111111 11111111 11111111 00000000
               255      255     255        0
           +--------------------------+--------+
                    Network              Host

In other words, 192.168.0.14 is part of the example network, but 192.168.1.2 is not.

The broadcast address is an IP address with the same network-part as the network, but with only ones as host-part. Every host on the network listens to this IP address. It is truly meant for broadcasting packets.

CODE Broadcast address
IP address:    192      168      0         2
            11000000 10101000 00000000 00000010
Broadcast:  11000000 10101000 00000000 11111111
               192      168      0        255
           +--------------------------+--------+
                     Network             Host

To be able to surf on the Internet, each computer in the network must know which host shares the Internet connection. This host is called the gateway. Since it is a regular host, it has a regular IP address (for instance 192.168.0.1).

Previously we stated that every host has its own IP address. To be able to reach this host by a name (instead of an IP address) we need a service that translates a name (such as dev.gentoo.org) to an IP address (such as 64.5.62.82). Such a service is called a name service. To use such a service, the necessary name servers need to be defined in /etc/resolv.conf.

In some cases, the gateway also serves as a nameserver. Otherwise the nameservers provided by the ISP need to be entered in this file.

To summarize, the following information is needed before continuing:

Network item Example
The system IP address 192.168.0.2
Netmask 255.255.255.0
Broadcast 192.168.0.255
Gateway 192.168.0.1
Nameserver(s) 195.130.130.5, 195.130.130.133

Using ifconfig and route

Setting up the network consists of three steps:

  1. Assign an IP address using ifconfig
  2. Set up routing to the gateway using route
  3. Finish up by placing the nameserver IPs in /etc/resolv.conf

To assign an IP address, the IP address, broadcast address and netmask are needed. Then execute the following command, substituting ${IP_ADDR} with the right IP address, ${BROADCAST} with the right broadcast address and ${NETMASK} with the right netmask:

root #ifconfig eth0 ${IP_ADDR} broadcast ${BROADCAST} netmask ${NETMASK} up

Set up routing using route. Substitute ${GATEWAY} with the right gateway IP address:

root #route add default gw ${GATEWAY}

Now open /etc/resolv.conf:

root #nano -w /etc/resolv.conf

Fill in the nameserver(s) using the following as a template. Make sure to substitute ${NAMESERVER1} and ${NAMESERVER2} with the appropriate nameserver addresses:

FILE /etc/resolv.confDefault resolv.conf template
nameserver ${NAMESERVER1}
nameserver ${NAMESERVER2}

That's it. Now test the network by pinging some Internet server (like Google's 8.8.8.8 or Cloudflare's 1.1.1.1). If this works, congratulations then. Continue with Preparing the disks.




X86 Handbook
Installation
About the installation
Choosing the media
Configuring the network
Preparing the disks
Installing stage3
Installing base system
Configuring the kernel
Configuring the system
Installing tools
Configuring the bootloader
Finalizing
Working with Gentoo
Portage introduction
USE flags
Portage features
Initscript system
Environment variables
Working with Portage
Files and directories
Variables
Mixing software branches
Additional tools
Custom package repository
Advanced features
Network configuration
Getting started
Advanced configuration
Modular networking
Wireless
Adding functionality
Dynamic management


Introduction to block devices

Block devices

Let's take a good look at disk-oriented aspects of Gentoo Linux and Linux in general, including Linux filesystems, partitions, and block devices. Once the ins and outs of disks and filesystems are understood, partitions and filesystems can be established for the Gentoo Linux installation.

To begin, let's look at block devices. The most famous block device is probably the one that represents the first drive in a Linux system, namely /dev/sda. SCSI and Serial ATA drives are both labeled /dev/sd*; even IDE drives are labeled /dev/sd* with the libata framework in the kernel. When using the old device framework, then the first IDE drive is /dev/hda.

The block devices above represent an abstract interface to the disk. User programs can use these block devices to interact with the disk without worrying about whether the drives are IDE, SCSI, or something else. The program can simply address the storage on the disk as a bunch of contiguous, randomly-accessible 512-byte blocks.



Partition tables

Although it is theoretically possible to use a raw, unpartitioned disk to house a Linux system (when creating a btrfs RAID for example), this is almost never done in practice. Instead, disk block devices are split up into smaller, more manageable block devices. On x86 systems, these are called partitions. There are currently two standard partitioning technologies in use: MBR and GPT.

MBR

The MBR (Master Boot Record) setup uses 32-bit identifiers for the start sector and length of the partitions, and supports three partition types: primary, extended, and logical. Primary partitions have their information stored in the master boot record itself - a very small (usually 512 bytes) location at the very beginning of a disk. Due to this small space, only four primary partitions are supported (for instance, /dev/sda1 to /dev/sda4).

To support more partitions, one of the primary partitions can be marked as an extended partition. This partition can then contain logical partitions (partitions within a partition).

Important
Although still supported by most motherboard manufacturers partition tables are considered legacy. Unless working with hardware that is pre-2010, it best to partition a disk using a GUID Partition Table. Readers who must proceed with MBR should acknowledge the following information:
  • Most post-2010 motherboards consider MBR a legacy (supported, but not ideal) boot mode.
  • Due to using 32-bit identifiers, master boot record partitioning tables cannot handle disks that are greater than 2 TiBs in size.
  • Unless a extended partition is created, MBR supports a maximum of four partitions.
  • The MBR setup does not provide any backup-MBR, so if an application or user overwrites the MBR, all partition information is lost.

The Handbook authors suggest using GPT whenever possible for Gentoo installations.

GPT

The GPT (GUID Partition Table) setup uses 64-bit identifiers for the partitions. The location in which it stores the partition information is much bigger than the 512 bytes of an MBR, which means there is practically no limit on the amount of partitions for a GPT disk. Also the size of a partition is bounded by a much greater limit (almost 8 ZiB - yes, zettabytes).

When a system's software interface between the operating system and firmware is UEFI (instead of BIOS), GPT is almost mandatory as compatibility issues will arise with MBR.

GPT also takes advantage of checksumming and redundancy. It carries CRC32 checksums to detect errors in the header and partition tables and has a backup GPT at the end of the disk. This backup table can be used to recover damage of the primary GPT near the beginning of the disk.

GPT or MBR

From the description above, one might think that using GPT should always be the recommended approach, however there are a few caveats.

Using GPT on a BIOS-based computer works, but then one cannot dual-boot with a Microsoft Windows operating system. The reason is that Microsoft Windows will boot in UEFI mode if it detects a GPT partition label.

Some buggy motherboard firmware configured to boot in BIOS/CSM/legacy mode might also have problems with booting from GPT labeled disks. If that is the case, it might be possible to work around the problem by adding the boot/active flag on the protective MBR partition which has to be done through fdisk with the -t dos option to force it to read the partition table using the MBR format.

In this case, launch fdisk and toggle the flag using the a key. Press 1 to select the first partition, then press the w key to write the changes to the disk and exit the fdisk application:

user $fdisk -t dos /dev/sda
Welcome to fdisk (util-linux 2.24.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
  
Command (m for help): a
Partition number (1-4): 1
  
Command (m for help): w

Using UEFI

When installing Gentoo on a system that uses UEFI to boot the operating system (instead of BIOS), then it is important that an EFI System Partition (ESP) is created. The instructions for parted below contain the necessary pointers to correctly handle this operation.

The ESP must be a FAT variant (sometimes shown as vfat on Linux systems). The official UEFI specification denotes FAT12, 16, or 32 filesystems will be recognized by the UEFI firmware, although FAT32 is recommended for the ESP. Proceed in formatting the ESP as FAT32:

root #mkfs.fat -F 32 /dev/sda2
Important
If a FAT variant is not used for the ESP, the system's UEFI firmware is not guaranteed to find the bootloader (or Linux kernel) and most likely be unable to boot the system!

Advanced storage

Btrfs RAID

As noted above, btrfs has the ability to create filesystems across multiple devices. Btrfs filesystems generated in this way can act in the following modes: raid0, raid1, raid10, raid5, and raid6. RAID modes 5 and 6 have improved considerably, but are still considered unstable. After a multiple device filesystem has been created, new devices can be added and old devices removed in a few commands. Btrfs takes more involvement than other filesystems making it not as friendly to beginners.

ext4 filesytems can be converted into btrfs filesystems, which may be useful for those who'd like to install Gentoo with a stable, well tested filesystem and gradually increase their knowledge about newer filesystems such as btrfs by experimentation.

LVM

The x86 Installation CDs provide support for Logical Volume Manager (LVM). LVM increases the flexibility offered by the partitioning setup. The installation instructions below will focus on "regular" partitions, but it is good to know LVM is supported if that route is desired. Visit the LVM article for more details. Newcomers beware: although fully supported LVM is outside the scope of this guide.

Default partitioning scheme

Throughout the remainder of the handbook, the following partitioning scheme will be used as a simple example layout:

Partition Filesystem Size Description
/dev/sda1 (bootloader) 2M BIOS boot partition
/dev/sda2 ext2 (or fat32 if UEFI is being used) 128M Boot/EFI system partition
/dev/sda3 (swap) 512M or higher Swap partition
/dev/sda4 ext4 Rest of the disk Root partition

If this suffices and the reader going the GPT route they can immediately jump to Default: Using parted to partition the disk. Those who are still interested in MBR (hey - it happens!) and using the example layout can jump to Alternative: Using fdisk to partition the disk.

Both fdisk and parted are partitioning utilities. fdisk is well known, stable, and recommended for the MBR partition layout while parted was one of the first Linux block device management utilities to support GPT partitions. Those who like the user interface of fdisk can use gdisk (GPT fdisk) as an alternative to parted.

Before going to the creation instructions, the first set of sections will describe in more detail how partitioning schemes can be created and mention some common pitfalls.

Designing a partition scheme

How many partitions and how big?

The number of partitions is highly dependent on the environment. For instance, if there are lots of users, then it is advised to have /home/ separate as it increases security and makes backups easier. If Gentoo is being installed to perform as a mail server, then /var/ should be separate as all mails are stored inside /var/. A good choice of filesystem will then maximize the performance. Game servers will have a separate /opt/ as most gaming servers are installed there. The reason is similar for the /home/ directory: security and backups. In most situations, /usr/ is to be kept big: not only will it contain the majority of applications, it typically also hosts the Gentoo ebuild repository (by default located at /usr/portage) which already takes around 650 MiB. This disk space estimate excludes the packages/ and distfiles/ directories that are generally stored within this ebuild repository.

It very much depends on what the administrator wants to achieve. 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 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 disadvantages as well. If not configured properly, the system might have lots of free space on one partition and none on another. Another nuisance is that separate partitions - especially for important mount points like /usr/ or /var/ - often require the administrator to boot with an initramfs to mount the partition before other boot scripts start. This isn't always the case though, so results may vary.

There is also a 15-partition limit for SCSI and SATA unless the disk uses GPT labels.

What about swap space?

There is no perfect value for the swap partition. The purpose of swap 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), freeing memory. Of course, if that memory is suddenly needed, these pages need to be put back in memory (page-in) which will take a while (as disks are very slow compared to internal memory).

When the system is not going to run memory intensive applications or the system has lots of memory available, then it probably does not need much swap space. However, swap space is also used to store the entire memory in case of hibernation. If the system is going to need hibernation, then a bigger swap space is necessary, often at least the amount of memory installed in the system.


What is the BIOS boot partition?

A BIOS boot partition is a very small (1 to 2 MB) partition in which boot loaders like GRUB2 can put additional data that doesn't fit in the allocated storage (a few hundred bytes in case of MBR) and cannot be placed elsewhere.

Such partitions are not always necessary, but considering the low space consumption and the difficulties we have with documenting the plethora of partitioning differences otherwise, it is recommended to create it in either case.

For completeness, the BIOS boot partition is needed when a GPT partition layout is used with GRUB2 in PC/BIOS mode. It is not required when booting in EFI/UEFI mode.

Default: Using parted to partition the disk

In this chapter, the example partition layout mentioned earlier in the instructions will be used:

Partition Description
/dev/sda1 BIOS boot partition
/dev/sda2 Boot partition
/dev/sda3 Swap partition
/dev/sda4 Root partition

Change the partition layout according to personal preference.

Viewing the current partition layout with parted

The parted application offers a simple interface for partitioning the disks and supports very large partitions (more than 2 TB). Fire up parted against the disk (in our example, we use /dev/sda). It is recommended to ask parted to use optimal partition alignment:

root #parted -a optimal /dev/sda
GNU Parted 2.3
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.

Alignment means that partitions are started on well-known boundaries within the disk, ensuring that operations on the disk from the operating system level (retrieve pages from the disk) use the least amount of internal disk operations. Misaligned partitions might require the disk to fetch two pages instead of one even if the operating system asked for a single page.

To find out about all options supported by parted, type help and press return.

Setting the GPT label

Most disks on the x86 or amd64 architectures are prepared using an msdos label. Using parted, the command to put a GPT label on the disk is mklabel gpt:

Warning
Changing the partition type will remove all partitions from the disk. All data on the disk will be lost.
(parted)mklabel gpt

To have the disk with MBR layout, use mklabel msdos.

Removing all partitions with parted

If this isn't done yet (for instance through the mklabel operation earlier, or because the disk is a freshly formatted one), first remove all existing partitions from the disk. Type print to view the current partitions, and rm <N> where <N> is the number of the partition to remove.

(parted)rm 2

Do the same for all other partitions that aren't needed. However, make sure to not make any mistakes here - parted executes the changes immediately (unlike fdisk which stages them, allowing a user to "undo" his changes before saving or exiting fdisk).

Creating the partitions

Now parted will be used to create the partitions with the following settings:

  • The partition type to use. This usually is primary. If the msdos partition label is used, keep in mind that there can be no more than 4 primary partitions. If more than 4 partitions are needed, make one of the first four partitions extended and create logical partitions inside it.
  • The start location of a partition (which can be expressed in MB, GB, ...)
  • The end location of the partition (which can be expressed in MB, GB, ...)

First, tell parted that the size unit we work with is megabytes (actually mebibytes, abbreviated as MiB which is the "standard" notation, but we will use MB in the text throughout as it is much more common):

(parted)unit mib

Now create a 2 MB partition that will be used by the GRUB2 boot loader later. Use the mkpart command for this, and inform parted to start from 1 MB and end at 3 MB (creating a partition of 2 MB in size).

(parted)mkpart primary 1 3
(parted)name 1 grub
(parted)set 1 bios_grub on
(parted)print
Model: Virtio Block Device (virtblk)
Disk /dev/sda: 20480MiB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
  
Number   Start      End      Size     File system  Name   Flags
 1       1.00MiB    3.00MiB  2.00MiB               grub   bios_grub

Do the same for the boot partition (128 MB), swap partition (in the example, 512 MB) and the root partition that spans the remaining disk (for which the end location is marked as -1, meaning the end of the disk minus one MB, which is the farthest a partition can go).

(parted)mkpart primary 3 131
(parted)name 2 boot
(parted)mkpart primary 131 643
(parted)name 3 swap
(parted)mkpart primary 643 -1
(parted)name 4 rootfs

When using the UEFI interface to boot the system (instead of BIOS), mark the boot partition as the EFI System Partition. Parted does this automatically when the boot option is set on the partition:

(parted)set 2 boot on

The end result looks like so:

(parted)print
Model: Virtio Block Device (virtblk)
Disk /dev/sda: 20480MiB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
  
Number   Start      End      Size     File system  Name   Flags
 1       1.00MiB    3.00MiB  2.00MiB               grub   bios_grub
 2       3.00MiB    131MiB   128MiB                boot   boot
 3       131MiB     643MiB   512MiB                swap
 4       643MiB     20479MiB 19836MiB              rootfs
Note
On an UEFI installation, the boot and esp flags will show up on the boot partition.

Use the quit command to exit parted.

Alternative: Using fdisk to partition the disk

Note
Although recent fdisk should support GPT, it has still shown to have some issues with it. The instructions given below assume that the partition layout being used is MBR.

The following parts explain how to create the example partition layout using fdisk. The example partition layout was mentioned earlier:

Partition Description
/dev/sda1 BIOS boot partition
/dev/sda2 Boot partition
/dev/sda3 Swap partition
/dev/sda4 Root partition

Change the partition layout according to personal preference.

Viewing the current partition layout

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

root #fdisk /dev/sda
Note
To use GPT support, add -t gpt. It is recommended to closely investigate the fdisk output in case more recent developments in fdisk change its default behavior of defaulting to MBR. The remainder of the instructions assume an MBR layout.

Use the p key to display the disk's current partition configuration:

Command (m for help):p
Disk /dev/sda: 240 heads, 63 sectors, 2184 cylinders
Units = cylinders of 15120 * 512 bytes
  
   Device Boot    Start       End    Blocks   Id  System
/dev/sda1   *         1        14    105808+  83  Linux
/dev/sda2            15        49    264600   82  Linux swap
/dev/sda3            50        70    158760   83  Linux
/dev/sda4            71      2184  15981840    5  Extended
/dev/sda5            71       209   1050808+  83  Linux
/dev/sda6           210       348   1050808+  83  Linux
/dev/sda7           349       626   2101648+  83  Linux
/dev/sda8           627       904   2101648+  83  Linux
/dev/sda9           905      2184   9676768+  83  Linux

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

Removing all partitions with fdisk

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 now been scheduled for deletion. It will no longer show up when printing the list of partitions (p, but it will not be erased until the changes have been saved. This allows users to abort the operation if a mistake was made - in that case, type q immediately and hit Enter and the partition will not be deleted.

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 be empty:

Command (m for help):p
Disk /dev/sda: 30.0 GB, 30005821440 bytes
240 heads, 63 sectors/track, 3876 cylinders
Units = cylinders of 15120 * 512 = 7741440 bytes
  
Device Boot    Start       End    Blocks   Id  System

Now that the in-memory partition table is empty, we're ready to create the partitions.

Creating the BIOS boot partition

First create a very small BIOS 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 sector, make sure it starts from 2048 (which is needed for the boot loader) and hit Enter. When prompted for the last sector, type +2M to create a partition 2 Mbyte in size:

Note
The start from sector 2048 is a fail-safe in case the boot loader does not detect this partition as being available for its use.
Command (m for help):n
Command action
  e   extended
  p   primary partition (1-4)
p
Partition number (1-4): 1
First sector (64-10486533532, default 64): 2048
Last sector, +sectors +size{M,K,G} (4096-10486533532, default 10486533532): +2M

Mark the partition for UEFI purposes:

Command (m for help):t
Selected partition 1
Hex code (type L to list codes): 4
Changed system type of partition 1 to 4 (BIOS boot)
Note
Using UEFI with MBR partition layout is discouraged. If an UEFI capable system is used, please use GPT layout.

Creating the boot partition

Now create a small boot partition. Type n to create a new partition, then p to select a primary partition, followed by 2 to select the second primary partition. When prompted for the first sector, accept the default by hitting Enter. When prompted for the last sector, type +128M to create a partition 128 Mbyte in size:

Command (m for help):n
Command action
  e   extended
  p   primary partition (1-4)
p
Partition number (1-4): 2
First sector (5198-10486533532, default 5198): (Hit enter)
Last sector, +sectors +size{M,K,G} (4096-10486533532, default 10486533532): +128M

Now, when pressing p, the following partition printout is displayed:

Command (m for help):p
Disk /dev/sda: 30.0 GB, 30005821440 bytes
240 heads, 63 sectors/track, 3876 cylinders
Units = cylinders of 15120 * 512 = 7741440 bytes
  
   Device Boot    Start       End    Blocks   Id  System
/dev/sda1             1         3      5198+  ef  EFI (FAT-12/16/32)
/dev/sda2             3        14    105808+  83  Linux

Type a to toggle the bootable flag on a partition and select 2. After pressing p again, notice that an * is placed in the "Boot" column.

Creating the swap partition

To create the swap partition, 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. When prompted for the first sector, hit Enter. When prompted for the last sector, type +512M (or any other size needed for the swap space) to create a partition 512MB in size.

After all this is done, type t to set the partition type, 3 to select the partition just created and then type in 82 to set the partition type to "Linux Swap".

Creating the root partition

Finally, to create the root partition, type n to create a new partition, then p to tell fdisk to create a primary partition. Then type 4 to create the fourth primary partition, /dev/sda4. When prompted for the first sector, hit Enter. When prompted for the last sector, 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.0 GB, 30005821440 bytes
240 heads, 63 sectors/track, 3876 cylinders
Units = cylinders of 15120 * 512 = 7741440 bytes
  
   Device Boot    Start       End    Blocks   Id  System
/dev/sda1             1         3      5198+  ef  EFI (FAT-12/16/32)
/dev/sda2   *         3        14    105808+  83  Linux
/dev/sda3            15        81    506520   82  Linux swap
/dev/sda4            82      3876  28690200   83  Linux

Saving the partition layout

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

Command (m for help):w

With the partitions created, it is now time to put filesystems on them.



Creating file systems

Introduction

Now that the partitions are created, it is time to place a filesystem on them. In the next section the various file systems that Linux supports are described. Readers that already know which filesystem to use can continue with Applying a filesystem to a partition. The others should read on to learn about the available filesystems...

Filesystems

Several filesystems are available. Some of them are found stable on the x86 architecture - it is advised to read up on the filesystems and their support state before selecting a more experimental one for important partitions.

btrfs
A next generation filesystem that provides many advanced features such as snapshotting, self-healing through checksums, transparent compression, subvolumes and integrated RAID. A few distributions have begun to ship it as an out-of-the-box option, but it is not production ready. Reports of filesystem corruption are common. Its developers urge people to run the latest kernel version for safety because the older ones have known problems. This has been the case for years and it is too early to tell if things have changed. Fixes for corruption issues are rarely backported to older kernels. Proceed with caution when using this filesystem!
ext2
This is the tried and true Linux filesystem but doesn't have metadata journaling, which means that routine ext2 filesystem checks at startup time can be quite time-consuming. There is now quite a selection of newer-generation journaled filesystems that can be checked for consistency very quickly and are thus generally preferred over their non-journaled counterparts. Journaled filesystems prevent long delays when the system is booted and the filesystem happens to be in an inconsistent state.
ext3
The journaled version of the ext2 filesystem, providing metadata journaling for fast recovery in addition to other enhanced journaling modes like full data and ordered data journaling. It uses an HTree index that enables high performance in almost all situations. In short, ext3 is a very good and reliable filesystem.
ext4
Initially created as a fork of ext3, ext4 brings new features, performance improvements, and removal of size limits with moderate changes to the on-disk format. It can span volumes up to 1 EB and with maximum file size of 16TB. Instead of the classic ext2/3 bitmap block allocation ext4 uses extents, which improve large file performance and reduce fragmentation. Ext4 also provides more sophisticated block allocation algorithms (delayed allocation and multiblock allocation) giving the filesystem driver more ways to optimize the layout of data on the disk. Ext4 is the recommended all-purpose all-platform filesystem.
f2fs
The Flash-Friendly File System was originally created by Samsung for the use with NAND flash memory. As of Q2, 2016, this filesystem is still considered immature, but it is a decent choice when installing Gentoo to microSD cards, USB drives, or other flash-based storage devices.
JFS
IBM's high-performance journaling filesystem. JFS is a light, fast and reliable B+tree-based filesystem with good performance in various conditions.
ReiserFS
A B+tree-based journaled filesystem that has good overall performance, especially when dealing with many tiny files at the cost of more CPU cycles. ReiserFS appears to be less maintained than other filesystems.
XFS
A filesystem with metadata journaling which comes with a robust feature-set and is optimized for scalability. XFS seems to be less forgiving to various hardware problems.
vfat
Also known as FAT32, is supported by Linux but does not support any permission settings. It is mostly used for interoperability with other operating systems (mainly Microsoft Windows) but is also a necessity for some system firmware (like UEFI).
NTFS
This "New Technology" filesystem is the flagship filesystem of Microsoft Windows. Similar to vfat above it does not store permission settings or extended attributes necessary for BSD or Linux to function properly, therefore it cannot be used as a root filesystem. It should only be used for interoperability with Microsoft Windows systems (note the emphasis on only).

When using ext2, ext3, or ext4 on a small partition (less than 8GB), then the file system must be created with the proper options to reserve enough inodes. The mke2fs (mkfs.ext2) application uses the "bytes-per-inode" setting to calculate how many inodes a file system should have. On smaller partitions, it is advised to increase the calculated number of inodes.

On ext2, ext3 and ext4, this can be done using one of the following commands, respectively:

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

This will generally quadruple the number of inodes for a given file system as its "bytes-per-inode" reduces from one every 16kB to one every 4kB. This can be tuned even further by providing the ratio:

root #mkfs.ext2 -i <ratio> /dev/<device>

Applying a filesystem to a partition

To create a filesystem on a partition or volume, there are user space utilities available for each possible filesystem. Click the filesystem's name in the table below for additional information on each filesystem:

Filesystem Creation command On minimal CD? Package
btrfs mkfs.btrfs Yes sys-fs/btrfs-progs
ext2 mkfs.ext2 Yes sys-fs/e2fsprogs
ext3 mkfs.ext3 Yes sys-fs/e2fsprogs
ext4 mkfs.ext4 Yes sys-fs/e2fsprogs
f2fs mkfs.f2fs Yes sys-fs/f2fs-tools
jfs mkfs.jfs Yes sys-fs/jfsutils
reiserfs mkfs.reiserfs Yes sys-fs/reiserfsprogs
xfs mkfs.xfs Yes sys-fs/xfsprogs
vfat mkfs.vfat Yes sys-fs/dosfstools
NTFS mkfs.ntfs Yes sys-fs/ntfs3g

For instance, to have the boot partition (/dev/sda2) in ext2 and the root partition (/dev/sda4) in ext4 as used in the example partition structure, the following commands would be used:

root #mkfs.ext2 /dev/sda2
root #mkfs.ext4 /dev/sda4

Now create the filesystems on the newly created partitions (or logical volumes).

Activating the swap partition

mkswap is the command that is used to initialize swap partitions:

root #mkswap /dev/sda3

To activate the swap partition, use swapon:

root #swapon /dev/sda3

Create and activate the swap with the commands mentioned above.

Mounting the root partition

Now that the partitions are initialized and are housing a filesystem, it is time to mount those partitions. Use the mount command, but don't forget to create the necessary mount directories for every partition created. As an example we mount the root partition:

root #mount /dev/sda4 /mnt/gentoo
Note
If /tmp/ needs to reside on a separate partition, be sure to change its permissions after mounting:
root #chmod 1777 /mnt/gentoo/tmp
This also holds for /var/tmp.

Later in the instructions the proc filesystem (a virtual interface with the kernel) as well as other kernel pseudo-filesystems will be mounted. But first we install the Gentoo installation files.




X86 Handbook
Installation
About the installation
Choosing the media
Configuring the network
Preparing the disks
Installing stage3
Installing base system
Configuring the kernel
Configuring the system
Installing tools
Configuring the bootloader
Finalizing
Working with Gentoo
Portage introduction
USE flags
Portage features
Initscript system
Environment variables
Working with Portage
Files and directories
Variables
Mixing software branches
Additional tools
Custom package repository
Advanced features
Network configuration
Getting started
Advanced configuration
Modular networking
Wireless
Adding functionality
Dynamic management


Installing a stage tarball

Setting the date and time

Before installing Gentoo, it is a good idea to be sure the date and time are set correctly. A mis-configured clock may lead to strange results: base system files should be extracted with accurate time stamps. In fact, due to several websites and services using encrypted communications (SSL/TLS), it might not be possible to download the installation files at all if the system clock is too far skewed!

Verify the current date and time by running the date command:

root #date
Mon Oct  3 13:16:22 PDT 2016

If the date/time displayed is wrong, update it using one of the methods below.

Note
Motherboards that do not include a Real-Time Clock (RTC) should be configured to automatically sync the system clock with a time server. This is also true for systems that do include a RTC, but have a failed battery.

Automatic

Official Gentoo installation media includes the ntpd command (available through the net-misc/ntp package). Official media includes a configuration file pointing to ntp.org time servers. It can be used to automatically sync the system clock to UTC time using a time server. Using this method requires a working network configuration and may not be available on all architectures.

Warning
Automatic time sync comes at a price. It will reveal the system's IP address and related network information to a time server (in the case of the example below ntp.org). Users with privacy concerns should be aware of this before setting the system clock using the below method.
root #ntpd -q -g

Manual

The date command can also be used to perform a manual set on the system clock. Use the MMDDhhmmYYYY syntax (Month, Day, hour, minute and Year).

UTC time is recommended for all Linux systems. Later on during the installation a timezone will be defined. This will modify the display of the clock to local time.

For instance, to set the date to October 3rd, 13:16 in the year 2016:

root #date 100313162016

Choosing a stage tarball

Multilib (32 and 64-bit)

Choosing a base tarball for the system can save a considerable amount of time later on in the installation process, specifically when it is time to choose a system profile. The selection of a stage tarball will directly impact future system configuration and can save a headache or two later on down the line. The multilib tarball uses 64-bit libraries when possible, and only falls back to the 32-bit versions when necessary for compatibility. This is an excellent option for the majority of installations because it provides a great amount of flexibility for customization in the future. Those who desire their systems to be capable of easily switching profiles should download the multilib tarball option for their respective processor architecture.

Most users should not use the 'advanced' tarballs options; they are for specific software or hardware configurations.

No-multilib (pure 64-bit)

Selecting a no-multilib tarball to be the base of the system provides a complete 64-bit operating system environment. This effectively renders the ability to switch to multilib profiles improbable, but possible. Those who are just starting out with Gentoo should not choose a no-multilib tarball unless it is absolutely necessary.

Warning
Be aware, migrating from a no-multilib to a multilib system requires an extremely well-working knowledge of Gentoo and the lower-level toolchain (it may even cause our Toolchain developers to shudder a little). It is not for the faint of heart and is beyond the scope of this guide.

Downloading the stage tarball

Go to the Gentoo mount point where the root file system is mounted (most likely /mnt/gentoo):

root #cd /mnt/gentoo

Depending on the installation medium, the only tool necessary to download a stage tarball is a web browser.

Graphical browsers

Those using environments with fully graphical web browsers will have no problem copying a stage file URL from the main website's download section. Simply select the appropriate tab, right click the link to the stage file, then Copy link address (Firefox) or Copy link location (Chromium) to copy the link to the clipboard, then paste the link to the wget utility on the command-line to download the stage tarball:

root #wget <PASTED_STAGE_URL>

Command-line browsers

More traditional readers or 'old timer' Gentoo users, working exclusively from command-line may prefer using links, a non-graphical, menu-driven browser. To download a stage, surf to the Gentoo mirror list like so:

root #links https://www.gentoo.org/downloads/mirrors/

To use an HTTP proxy with links, pass on the URL with the -http-proxy option:

root #links -http-proxy proxy.server.com:8080 https://www.gentoo.org/downloads/mirrors/

Next to links there is also the lynx browser. Like links it is a non-graphical browser but it is not menu-driven.

root #lynx https://www.gentoo.org/downloads/mirrors/

If a proxy needs to be defined, export the http_proxy and/or ftp_proxy variables:

root #export http_proxy="http://proxy.server.com:port"
root #export ftp_proxy="http://proxy.server.com:port"

On the mirror list, select a mirror close by. Usually HTTP mirrors suffice, but other protocols are available as well. Move to the releases/x86/autobuilds/ directory. There all available stage files are displayed (they might be stored within subdirectories named after the individual sub-architectures). Select one and press d to download.

After the stage file download completes, it is possible to verify the integrity and validate the contents of the stage tarball. Those interested should proceed to the next section.

Those not interested in verifying and validating the stage file can close the command-line browser by pressing q and can move directly to the Unpacking the stage tarball section.

Verifying and validating

Note
Some tarballs are being delivered via xz compression. When downloading a tarball ending in .tar.xz, be sure to adjust the tarball filename from .tar.bz2 in the following commands.

Like with the minimal installation CDs, additional downloads to verify and validate the stage file are available. Although these steps may be skipped, these files are provided for users who care about the legitimacy of the file(s) they just downloaded.

  • A .CONTENTS file that contains a list of all files inside the stage tarball.
  • A .DIGESTS file that contains checksums of the stage file in different algorithms.
  • A .DIGESTS.asc file that, like the .DIGESTS file, contains checksums of the stage file in different algorithms, but is also cryptographically signed to ensure it is provided by the Gentoo project.

Use openssl and compare the output with the checksums provided by the .DIGESTS or .DIGESTS.asc files.

For instance, to validate the SHA512 checksum:

root #openssl dgst -r -sha512 stage3-x86-<release>.tar.?(bz2|xz)

Another way is to use the sha512sum command:

root #sha512sum stage3-x86-<release>.tar.?(bz2|xz)

To validate the Whirlpool checksum:

root #openssl dgst -r -whirlpool stage3-x86-<release>.tar.?(bz2|xz)

Compare the output of these commands with the value registered in the .DIGESTS(.asc) files. The values need to match, otherwise the downloaded file might be corrupt (or the digests file is).

Just like with the ISO file, it is also possible to verify the cryptographic signature of the .DIGESTS.asc file using gpg to make sure the checksums have not been tampered with:

root #gpg --verify stage3-x86-<release>.tar.?(bz2|xz){.DIGESTS.asc,}

Unpacking the stage tarball

Now unpack the downloaded stage onto the system. We use tar to proceed:

root #tar xpvf stage3-*.tar.bz2 --xattrs-include='*.*' --numeric-owner

Make sure that the same options (xpf and --xattrs-include='*.*') are used. The x stands for extract, the p for preserve permissions and the f to denote that we want to extract a file (not standard input). --xattrs-include='*.*' is to include preservation of the the extended attributes in all namespaces stored in the archive. Finally, --numeric-owner is used to ensure that the user and group IDs of the files being extracted from the tarball will remain the same as Gentoo's release engineering team intended (even if adventurous users are not using official Gentoo installation media).

Now that the stage file is unpacked, proceed with Configuring the compile options.

Configuring compile options

Introduction

To optimize Gentoo, it is possible to set a couple of variables which impacts the behavior of Portage, Gentoo's officially supported package manager. All those variables can be set as environment variables (using export) but that isn't permanent. To keep the settings, Portage reads in the /etc/portage/make.conf file, a configuration file for Portage.

Note
A commented listing of all possible variables can be found in /mnt/gentoo/usr/share/portage/config/make.conf.example. For a successful Gentoo installation only the variables that are mentioned below need to be set.

Fire up an editor (in this guide we use nano) to alter the optimization variables we will discuss hereafter.

root #nano -w /mnt/gentoo/etc/portage/make.conf

From the make.conf.example file it is obvious how the file should be structured: commented lines start with "#", other lines define variables using the VARIABLE="content" syntax. Several of those variables are discussed next.

CFLAGS and CXXFLAGS

The CFLAGS and CXXFLAGS variables define the optimization flags for GCC C and C++ compilers respectively. Although those are defined generally here, for maximum performance one would need to optimize these flags for each program separately. The reason for this is because every program is different. However, this is not manageable, hence the definition of these flags in the make.conf file.

In make.conf one should define the optimization flags that will make the system the most responsive generally. Don't place experimental settings in this variable; too much optimization can make programs behave bad (crash, or even worse, malfunction).

We will not explain all possible optimization options. To understand them all, read the GNU Online Manual(s) or the gcc info page (info gcc - only works on a working Linux system). The make.conf.example file itself also contains lots of examples and information; don't forget to read it too.

A first setting is the -march= or -mtune= flag, which specifies the name of the target architecture. Possible options are described in the make.conf.example file (as comments). A commonly used value is native as that tells the compiler to select the target architecture of the current system (the one users are installing Gentoo on).

A second one is the -O flag (that is a capital O, not a zero), which specifies the gcc optimization class flag. Possible classes are s (for size-optimized), 0 (zero - for no optimizations), 1, 2 or even 3 for more speed-optimization flags (every class has the same flags as the one before, plus some extras). -O2 is the recommended default. -O3 is known to cause problems when used system-wide, so we recommend to stick to -O2.

Another popular optimization flag is -pipe (use pipes rather than temporary files for communication between the various stages of compilation). It has no impact on the generated code, but uses more memory. On systems with low memory, gcc might get killed. In that case, do not use this flag.

Using -fomit-frame-pointer (which doesn't keep the frame pointer in a register for functions that don't need one) might have serious repercussions on the debugging of applications.

When the CFLAGS and CXXFLAGS variables are defined, combine the several optimization flags in one string. The default values contained in the stage3 archive that is unpacked should be good enough. The following one is just an example:

CODE Example CFLAGS and CXXFLAGS variables
# Compiler flags to set for all languages
COMMON_FLAGS="-O2 -march=i686 -pipe"
# Use the same settings for both variables
CFLAGS="${COMMON_FLAGS}"
CXXFLAGS="${COMMON_FLAGS}"
Tip
Although the GCC optimization article has more information on how the various compilation options can affect a system, the Safe CFLAGS article may be a more practical place for beginners to start optimizing their systems.

MAKEOPTS

The MAKEOPTS variable defines how many parallel compilations should occur when installing a package. A good choice is the number of CPUs (or CPU cores) in the system plus one, but this guideline isn't always perfect.

CODE Example MAKEOPTS declaration in make.conf
MAKEOPTS="-j2"

Ready, set, go!

Update the /mnt/gentoo/etc/portage/make.conf file to match personal preference and save (nano users would hit Ctrl+X).

Then continue with Installing the Gentoo base system.




X86 Handbook
Installation
About the installation
Choosing the media
Configuring the network
Preparing the disks
Installing stage3
Installing base system
Configuring the kernel
Configuring the system
Installing tools
Configuring the bootloader
Finalizing
Working with Gentoo
Portage introduction
USE flags
Portage features
Initscript system
Environment variables
Working with Portage
Files and directories
Variables
Mixing software branches
Additional tools
Custom package repository
Advanced features
Network configuration
Getting started
Advanced configuration
Modular networking
Wireless
Adding functionality
Dynamic management


Chrooting

Optional: Selecting mirrors

Distribution files

In order to download source code quickly it is recommended to select a fast mirror. Portage will look in the make.conf file for the GENTOO_MIRRORS variable and use the mirrors listed therein. It is possible to surf to the Gentoo mirror list and search for a mirror (or mirrors) that is close to the system's physical location (as those are most frequently the fastest ones). However, we provide a nice tool called mirrorselect which provides users with a nice interface to select the mirrors needed. Just navigate to the mirrors of choice and press Spacebar to select one or more mirrors.

root #mirrorselect -i -o >> /mnt/gentoo/etc/portage/make.conf

Gentoo ebuild repository

A second important step in selecting mirrors is to configure the Gentoo ebuild repository via the /etc/portage/repos.conf/gentoo.conf file. This file contains the sync information needed to update the package repository (the collection of ebuilds and related files containing all the information Portage needs to download and install software packages).

Configuring the repository can be done in a few simple steps. First, if it does not exist, create the repos.conf directory:

root #mkdir --parents /mnt/gentoo/etc/portage/repos.conf

Next, copy the Gentoo repository configuration file provided by Portage to the (newly created) repos.conf directory:

root #cp /mnt/gentoo/usr/share/portage/config/repos.conf /mnt/gentoo/etc/portage/repos.conf/gentoo.conf

Take a peek with a text editor or by using the cat command. The inside of the file should be in .ini format and look like this:

FILE /mnt/gentoo/etc/portage/repos.conf/gentoo.conf
[DEFAULT]
main-repo = gentoo

[gentoo]
location = /usr/portage
sync-type = rsync
sync-uri = rsync://rsync.gentoo.org/gentoo-portage
auto-sync = yes
sync-rsync-verify-jobs = 1
sync-rsync-verify-metamanifest = yes
sync-rsync-verify-max-age = 24
sync-openpgp-key-path = /usr/share/openpgp-keys/gentoo-release.asc
sync-openpgp-key-refresh-retry-count = 40
sync-openpgp-key-refresh-retry-overall-timeout = 1200
sync-openpgp-key-refresh-retry-delay-exp-base = 2
sync-openpgp-key-refresh-retry-delay-max = 60
sync-openpgp-key-refresh-retry-delay-mult = 4

# for daily squashfs snapshots
#sync-type = squashdelta
#sync-uri = mirror://gentoo/../snapshots/squashfs

The default sync-uri variable value listed above will determine a mirror location based on a rotation. This will aid in easing bandwidth stress on Gentoo's infrastructure and will provide a fail-safe in case a specific mirror is offline. It is recommended the default URI is retained unless a local, private Portage mirror will be used.

Tip
For those interested, the official specification for Portage's plug-in sync API can be found in the Portage project's Sync article.

Copy DNS info

One thing still remains to be done before entering the new environment and that is copying over the DNS information in /etc/resolv.conf. This needs to be done to ensure that networking still works even after entering the new environment. /etc/resolv.conf contains the name servers for the network.

To copy this information, it is recommended to pass the --dereference option to the cp command. This ensures that, if /etc/resolv.conf is a symbolic link, that the link's target file is copied instead of the symbolic link itself. Otherwise in the new environment the symbolic link would point to a non-existing file (as the link's target is most likely not available inside the new environment).

root #cp --dereference /etc/resolv.conf /mnt/gentoo/etc/

Mounting the necessary filesystems

In a few moments, the Linux root will be changed towards the new location. To make sure that the new environment works properly, certain filesystems need to be made available there as well.

The filesystems that need to be made available are:

  • /proc/ which is a pseudo-filesystem (it looks like regular files, but is actually generated on-the-fly) from which the Linux kernel exposes information to the environment
  • /sys/ which is a pseudo-filesystem, like /proc/ which it was once meant to replace, and is more structured than /proc/
  • /dev/ is a regular file system, partially managed by the Linux device manager (usually udev), which contains all device files

The /proc/ location will be mounted on /mnt/gentoo/proc/ whereas the other two are bind-mounted. The latter means that, for instance, /mnt/gentoo/sys/ will actually be /sys/ (it is just a second entry point to the same filesystem) whereas /mnt/gentoo/proc/ is a new mount (instance so to speak) of the filesystem.

root #mount --types proc /proc /mnt/gentoo/proc
root #mount --rbind /sys /mnt/gentoo/sys
root #mount --make-rslave /mnt/gentoo/sys
root #mount --rbind /dev /mnt/gentoo/dev
root #mount --make-rslave /mnt/gentoo/dev
Note
The --make-rslave operations are needed for systemd support later in the installation.
Warning
When using non-Gentoo installation media, this might not be sufficient. Some distributions make /dev/shm a symbolic link to /run/shm/ which, after the chroot, becomes invalid. Making /dev/shm/ a proper tmpfs mount up front can fix this:
root #test -L /dev/shm && rm /dev/shm && mkdir /dev/shm
root #mount --types tmpfs --options nosuid,nodev,noexec shm /dev/shm

Also ensure that mode 1777 is set:

root # chmod 1777 /dev/shm

Entering the new environment

Now that all partitions are initialized and the base environment installed, it is time to enter the new installation environment by chrooting into it. This means that the session will change its root (most top-level location that can be accessed) from the current installation environment (installation CD or other installation medium) to the installation system (namely the initialized partitions). Hence the name, change root or chroot.

This chrooting is done in three steps:

  1. The root location is changed from / (on the installation medium) to /mnt/gentoo/ (on the partitions) using chroot
  2. Some settings (those in /etc/profile) are reloaded in memory using the source command
  3. The primary prompt is changed to help us remember that this session is inside a chroot environment.
root #chroot /mnt/gentoo /bin/bash
root #source /etc/profile
root #export PS1="(chroot) ${PS1}"

From this point, all actions performed are immediately on the new Gentoo Linux environment. Of course it is far from finished, which is why the installation still has some sections left!

Tip
If the Gentoo installation is interrupted anywhere after this point, it should be possible to 'resume' the installation at this step. There is no need to repartition the disks again! Simply mount the root partition and run the steps above starting with copying the DNS info to re-enter the working environment. This is also useful for fixing bootloader issues. More information can be found in the chroot article.

Mounting the boot partition

Now that the new environment has been entered, it is necessary to create and mount the /boot partition. This will be important when it is time to compile the kernel and install the bootloader:

root #mkdir /boot
root #mount /dev/sda2 /boot

Configuring Portage

Installing an ebuild repository snapshot from the web

Next step is to install a snapshot of the main ebuild repository. This snapshot contains a collection of files that informs Portage about available software titles (for installation), which profiles the system administrator can select, package or profile specific news items, etc.

The use of emerge-webrsync is recommended for those who are behind restrictive firewalls (because it uses HTTP/FTP protocols for downloading the snapshot) and saves network bandwidth. Readers who have no network or bandwidth restrictions can happily skip down to the next section.

This will fetch the latest snapshot (which is released on a daily basis) from one of Gentoo's mirrors and install it onto the system:

root #emerge-webrsync
Note
During this operation, emerge-webrsync might complain about a missing /usr/portage/ location. This is to be expected and nothing to worry about - the tool will create the location.

From this point onward, Portage might mention that certain updates are recommended to be executed. This is because system packages installed through the stage file might have newer versions available; Portage is now aware of new packages because of the repository snapshot. Package updates can be safely ignored for now; updates can be delayed after the Gentoo installation has finished.

Optional: Updating the Gentoo ebuild repository

It is possible to update the Gentoo ebuild repository to the latest version. The previous emerge-webrsync command will have installed a very recent snapshot (usually recent up to 24h) so this step is definitely optional.

Suppose there is a need for the last package updates (up to 1 hour), then use emerge --sync. This command will use the rsync protocol to update the Gentoo ebuild repository (which was fetched earlier on through emerge-webrsync) to the latest state.

root #emerge --sync

On slow terminals, like some framebuffers or serial consoles, it is recommended to use the --quiet option to speed up the process:

root #emerge --sync --quiet

Reading news items

When the Gentoo ebuild repository is synchronized to the system, Portage may warn the user with messages similar to the following:

* IMPORTANT: 2 news items need reading for repository 'gentoo'.
* Use eselect news to read news items.

News items were created to provide a communication medium to push critical messages to users via the rsync tree. To manage them, use eselect news. The eselect application is a Gentoo application that allows for a common management interface towards system changes and operations. In this case, eselect is asked to use its news module.

For the news module, three operations are most used:

  • With list an overview of the available news items is displayed.
  • With read the news items can be read.
  • With purge news items can be removed once they have been read and will not be reread anymore.
root #eselect news list
root #eselect news read

More information about the newsreader is available through its manual page:

root #man news.eselect

Choosing the right profile

Warning
Do not select any of the the 17.1 profiles until reading the corresponding 17.1 news item. This profile is experimental and requires special migration instructions.

A profile is a building block for any Gentoo system. Not only does it specify default values for USE, CFLAGS, and other important variables, it also locks the system to a certain range of package versions. These settings are all maintained by Gentoo's Portage developers.

You can see what profile the system is currently using with eselect, now using the profile module:

root #eselect profile list
Available profile symlink targets:
  [1]   default/linux/x86/13.0 *
  [2]   default/linux/x86/13.0/desktop
  [3]   default/linux/x86/13.0/desktop/gnome
  [4]   default/linux/x86/13.0/desktop/kde
Note
The output of the command is just an example and evolves over time.

As can be seen, there are also desktop subprofiles available for some architectures.

Warning
Profile upgrades are not to be taken lightly. When selecting the initial profile, make sure to use profile corresponding to the same version as the one initially used by stage3 (e.g. 13.0). Each new profile version is announced through a news item containing migration instructions. Make sure to read it and follow them before switching to a newer profile.

After viewing the available profiles for the x86 architecture, users can select a different profile for the system:

root #eselect profile set 2

Note
The developer subprofile is specifically for Gentoo Linux development and is not meant to be used by casual users.

Updating the @world set

At this point, it is wise to update the system's @world set so that a base can be established.

This following step is necessary so the system can apply any updates or USE flag changes which have appeared since the stage3 was built and from any profile selection:

root #emerge --ask --verbose --update --deep --newuse @world
Tip
If a full scale desktop environment profile has been selected this process could greatly extend the amount of time necessary for the install process. Those in a time crunch can work by this 'rule of thumb': the shorter the profile name, the less specific the system's @world set; the less specific the @world set, the fewer packages the system will require. In other words:
  • selecting default/linux/amd64/13.0 will require very few packages to be updated, whereas
  • selecting default/linux/amd64/13.0/desktop/gnome/systemd will require many packages to be installed since the init system is changing from OpenRC to systemd, and the GNOME desktop environment framework will be installed.

Configuring the USE variable

USE is one of the most powerful variables Gentoo provides to its users. Several programs can be compiled with or without optional support for certain items. For instance, some programs can be compiled with support for GTK+ or with support for Qt. Others can be compiled with or without SSL support. Some programs can even be compiled with framebuffer support (svgalib) instead of X11 support (X-server).

Most distributions compile their packages with support for as much as possible, increasing the size of the programs and startup time, not to mention an enormous amount of dependencies. With Gentoo users can define what options a package should be compiled with. This is where USE comes into play.

In the USE variable users define keywords which are mapped onto compile-options. For instance, ssl will compile SSL support in the programs that support it. -X will remove X-server support (note the minus sign in front). gnome gtk -kde -qt4 -qt5 will compile programs with GNOME (and GTK+) support, and not with KDE (and Qt) support, making the system fully tweaked for GNOME (if the architecture supports it).

The default USE settings are placed in the make.defaults files of the Gentoo profile used by the system. Gentoo uses a (complex) inheritance system for its profiles, which we will not dive into at this stage. The easiest way to check the currently active USE settings is to run emerge --info and select the line that starts with USE:

root #emerge --info | grep ^USE
USE="X acl alsa amd64 berkdb bindist bzip2 cli cracklib crypt cxx dri ..."
Note
The above example is truncated, the actual list of USE values is much, much larger.

A full description on the available USE flags can be found on the system in /usr/portage/profiles/use.desc.

root #less /usr/portage/profiles/use.desc

Inside the less command, scrolling can be done using the and keys, and exited by pressing q.

As an example we show a USE setting for a KDE-based system with DVD, ALSA, and CD recording support:

root #nano -w /etc/portage/make.conf
FILE /etc/portage/make.confEnabling USE for a KDE-based system with DVD, ALSA and CD recording support
USE="-gtk -gnome qt4 qt5 kde dvd alsa cdr"

When USE is defined in /etc/portage/make.conf it is added (or removed if the USE flag starts with the - sign) from that default list. Users who want to ignore any default USE settings and manage it completely themselves should start the USE definition in make.conf with -*:

FILE /etc/portage/make.confIgnoring default USE flags
USE="-* X acl alsa"
Warning
Although possible, setting -* (as seen in the example above) is discouraged as carefully chosen USE flag defaults may be configured in some ebuilds to prevent conflicts and other errors.


Timezone

Select the timezone for the system. Look for the available timezones in /usr/share/zoneinfo/, then write it in the /etc/timezone file.

root #ls /usr/share/zoneinfo

Suppose the timezone of choice is Europe/Brussels:

root #echo "Europe/Brussels" > /etc/timezone

Please avoid the /usr/share/zoneinfo/Etc/GMT* timezones as their names do not indicate the expected zones. For instance, GMT-8 is in fact GMT+8.

Next, reconfigure the sys-libs/timezone-data package, which will update the /etc/localtime file for us, based on the /etc/timezone entry. The /etc/localtime file is used by the system C library to know the timezone the system is in.

root #emerge --config sys-libs/timezone-data

Configure locales

Most users will want to use only one or two locales on their system.

Locales specify not only the language that the user should use to interact with the system, but also what the rules are for sorting strings, displaying dates and times, etc.

The locales that a system should support should be mentioned in /etc/locale.gen.

root #nano -w /etc/locale.gen

The following locales are an example to get both English (United States) and German (Germany) with the accompanying character formats (like UTF-8).

FILE /etc/locale.genEnabling US and DE locales with the appropriate character formats
en_US ISO-8859-1
en_US.UTF-8 UTF-8
de_DE ISO-8859-1
de_DE.UTF-8 UTF-8
Warning
We strongly suggest to use at least one UTF-8 locale because some applications may require it.

The next step is to run locale-gen. It will generate all the locales specified in the /etc/locale.gen file.

root #locale-gen

To verify that the selected locales are now available, run locale -a.

Once done, it is now time to set the system-wide locale settings. Again we use eselect for this, now with the locale module.

With eselect locale list, the available targets are displayed:

root #eselect locale list
Available targets for the LANG variable:
  [1] C
  [2] POSIX
  [3] en_US
  [4] en_US.iso88591
  [5] en_US.utf8
  [6] de_DE
  [7] de_DE.iso88591
  [8] de_DE.iso885915
  [9] de_DE.utf8
  [ ] (free form)

With eselect locale set VALUE the correct locale can be set:

root #eselect locale set 9

Manually, this can still be accomplished through the /etc/env.d/02locale file:

FILE /etc/env.d/02localeManually setting system locale definitions
LANG="de_DE.UTF-8"
LC_COLLATE="C"

Make sure a locale is set, as the system would otherwise display warnings and errors during kernel builds and other software deployments later in the installation.

Now reload the environment:

root #env-update && source /etc/profile && export PS1="(chroot) $PS1"

We made a full Localization guide to help the user guide through this process. Another interesting article is the UTF-8 guide for very specific information to enable UTF-8 on the system.




X86 ハンドブック
インストール
インストールについて
メディアの選択
ネットワーク設定
ディスクの準備
stage3のインストール
Gentooベースシステムのインストール
カーネルの設定
システムの設定
ツールのインストール
ブートローダの設定
締めくくり
Gentooの操作
Portageについて
USEフラグ
Portageの機能
Initスクリプトシステム
環境変数
Portageの操作
ファイルとディレクトリ
変数
ソフトウェアブランチの併用
追加ツール
カスタムPortageツリー
高度な機能
ネットワーク設定
はじめに
高度な設定
モジュール式ネットワーク
無線
機能の追加
動的な管理


カーネルソースのインストール

すべてのディストリビューションが構築されるその中心にあるのがLinuxカーネルです。カーネルレイヤーはユーザープログラムとハードウェアの間に存在します。Gentooではカーネルソースについて複数の選択肢があります。説明付きのすべてのカーネルソースのリストは、Kernel overview pageで見ることができます。

x86ベースのシステムのために、Gentooは sys-kernel/gentoo-sourcesパッケージを推奨しています。

適切なカーネルソースを選択して、emergeでインストールします。

root #emerge --ask sys-kernel/gentoo-sources

このコマンドはカーネルソースを/usr/src/にインストールします。このディレクトリにあるlinuxがインストールされたカーネルソースへのシンボリックリンクとなります。

root #ls -l /usr/src/linux
lrwxrwxrwx    1 root   root    12 Oct 13 11:04 /usr/src/linux -> linux-3.16.5-gentoo

これで、カーネルソースを設定、コンパイルする準備が整いました。この設定およびコンパイルには二つのアプローチがあります。

  1. カーネルをマニュアルで設定およびビルドする。
  2. Linuxカーネルを自動的にビルド・インストールするgenkernelを使用する。

ここでは、環境を最適化するのに最も適した"マニュアル設定"をデフォルトとして説明します。

デフォルト: マニュアル設定

はじめに

カーネルのマニュアル設定は、しばしばLinuxユーザーがしなければならない最も難しい手続きと考えられます。これは真実ではありません。カーネルを数回設定してみれば、それが難しいと言われていたことなど忘れてしまうでしょう。

しかし、一つだけ真実があります。カーネルをマニュアルで設定する時、ハードウェア情報を知ることはとても役に立ちます。ほとんどの情報は、lspciコマンドを含むsys-apps/pciutilsをインストールすることで得られます。

root #emerge --ask sys-apps/pciutils
注意
chroot環境では、lspciが出力していると思われる(pcilib: cannot open /sys/bus/pci/devicesのような)pcilibの警告は、無視しても構いません。

システム情報を得るための別の方法は、lsmodを使ってインストールCDが使っているカーネルモジュールを把握することです。その情報は何を有効にすべきかとてもよいヒントを与えてくれるでしょう。

では、カーネルソースがあるディレクトリに移動して、make menuconfigを実行しましょう。このコマンドはメニューベースの設定画面を起動します。

root #cd /usr/src/linux
root #make menuconfig

Linuxカーネルの設定はとても多くのセクションを持っています。まず最初にいくつかの必須オプションを述べましょう(そうでない場合、Gentooは動作しない、もしくは追加の処置なしには正しく動作しません)。 Gentoo wikiのGentoo カーネルコンフィグレーションガイドには、さらに役立つ記述があるでしょう。

必須オプションを有効にする

システムのブートに必須となるドライバ(SCSIコントローラ等)は、モジュールではなく、カーネルの一部としてコンパイルしなければなりません。そうでないと、システムは全くブートできないでしょう。

次に正確なプロセッサタイプを選択します。このとき、もし使えるのであればMCE機能を有効にすることが推奨されます。これによりハードウェアの異常が通知されるようになるでしょう。いくつかのアーキテクチャ(x86_64)で、これらのエラーはdmesgでは確認できませんが、/dev/mcelogにログが残ります。この機能を有効にするためにapp-admin/mcelogパッケージが必要になります。

また、Maintain a devtmpfs file system to mount at /devを選択することで、必須となるデバイスファイルがブートプロセスの初期段階で使えるようになります (CONFIG_DEVTMPFSCONFIG_DEVTMPFS_MOUNT):

KERNEL devtmpfsサポートを有効にする
Device Drivers --->
  Generic Driver Options --->
    [*] Maintain a devtmpfs filesystem to mount at /dev
    [ ]   Automount devtmpfs at /dev, after the kernel mounted the rootfs

SCSI ディスクサポートが有効になっているか確認してください(CONFIG_BLK_DEV_SD):

KERNEL SCSIディスクサポートを有効にする
Device Drivers --->
   SCSI device support  --->
      <*> SCSI disk support

次にFile Systemsで、使用するファイルシステムに必要なサポートを選択しましょう。ルートファイルシステムに使われるファイルシステムをモジュールとしてコンパイルしてはいけません。モジュールにした場合、Gentooシステムはパーティションをマウントできないでしょう。また、ここでVirtual memory/proc file systemも選択してください。システムの必要に応じて以下の選択肢から1個以上を選択してください (CONFIG_EXT2_FS, CONFIG_EXT3_FS, CONFIG_EXT4_FS, CONFIG_MSDOS_FS, CONFIG_VFAT_FS, CONFIG_PROC_FS, and CONFIG_TMPFS):

KERNEL 必要なファイルシステムを選択する
File systems --->
  <*> Second extended fs support
  <*> The Extended 3 (ext3) filesystem
  <*> The Extended 4 (ext4) filesystem
  <*> Reiserfs support
  <*> JFS filesystem support
  <*> XFS filesystem support
  <*> Btrfs filesystem support
  DOS/FAT/NT Filesystems  --->
    <*> MSDOS fs support
    <*> VFAT (Windows-95) fs support
 
Pseudo Filesystems --->
    [*] /proc file system support
    [*] Tmpfs virtual memory file system support (former shm fs)

もしインターネットに接続するために、PPPoEもしくはダイヤルアップモデムを使う場合、次のオプションを有効にしてください (CONFIG_PPP, CONFIG_PPP_ASYNC, and CONFIG_PPP_SYNC_TTY):

KERNEL PPPoEに必要なドライバを選択する
Device Drivers --->
  Network device support --->
    <*> PPP (point-to-point protocol) support
    <*>   PPP support for async serial ports
    <*>   PPP support for sync tty ports

2つの圧縮オプションは選択しても差し支えありませんが、必須というわけでもありません。PPP over Ethernetオプションも同様です。これはカーネルモードのPPPoEをするために設定された時だけにpppによって使用されるものです。

カーネルにネットワークカード(イーサネットもしくはワイヤレス)のサポートを組み込むことを忘れてはいけません。

多くのシステムではマルチコアを使用できます。Symmetric multi-processing supportを有効にすることは重要です (CONFIG_SMP):

KERNEL SMPサポートを有効にする
Processor type and features  --->
  [*] Symmetric multi-processing support
注意
マルチコアシステムでは、それぞれのコアが1プロセッサとカウントされます。

USB接続の入力装置(キーボードやマウス)などのUSBデバイスを使用する場合、以下を必ず有効にしてください (CONFIG_HID_GENERIC and CONFIG_USB_HID, CONFIG_USB_SUPPORT, CONFIG_USB_XHCI_HCD, CONFIG_USB_EHCI_HCD, CONFIG_USB_OHCI_HCD):

KERNEL 入力装置のためにUSBサポートを有効にする
Device Drivers --->
  HID support  --->
    -*- HID bus support
    <*>   Generic HID driver
    [*]   Battery level reporting for HID devices
      USB HID support  --->
        <*> USB HID transport layer
  [*] USB support  --->
    <*>     xHCI HCD (USB 3.0) support
    <*>     EHCI HCD (USB 2.0) support
    <*>     OHCI HCD (USB 1.1) support



Architecture specific kernel configuration

Make sure to select IA32 Emulation if 32-bit programs should be supported (CONFIG_IA32_EMULATION). Gentoo installs a multilib system (mixed 32-bit/64-bit computing) by default, so unless a no-multilib profile is used, this option is required.

KERNEL Selecting processor types and features
Processor type and features  --->
   [ ] Machine Check / overheating reporting 
   [ ]   Intel MCE Features
   [ ]   AMD MCE Features
   Processor family (AMD-Opteron/Athlon64)  --->
      ( ) Opteron/Athlon64/Hammer/K8
      ( ) Intel P4 / older Netburst based Xeon
      ( ) Core 2/newer Xeon
      ( ) Intel Atom
      ( ) Generic-x86-64
Executable file formats / Emulations  --->
   [*] IA32 Emulation

Enable GPT partition label support if that was used previously when partitioning the disk (CONFIG_PARTITION_ADVANCED and CONFIG_EFI_PARTITION):

KERNEL Enable support for GPT
-*- Enable the block layer --->
   Partition Types --->
      [*] Advanced partition selection
      [*] EFI GUID Partition support

Enable EFI stub support and EFI variables in the Linux kernel if UEFI is used to boot the system (CONFIG_EFI, CONFIG_EFI_STUB, CONFIG_EFI_MIXED, and CONFIG_EFI_VARS):

KERNEL Enable support for UEFI
Processor type and features  --->
    [*] EFI runtime service support 
    [*]   EFI stub support
    [*]     EFI mixed-mode support
 
Firmware Drivers  --->
    EFI (Extensible Firmware Interface) Support  --->
        <*> EFI Variable Support via sysfs

Compiling and installing

With the configuration now done, it is time to compile and install the kernel. Exit the configuration and start the compilation process:

root #make && make modules_install
Note
It is possible to enable parallel builds using make -jX with X being an integer number of parallel tasks that the build process is allowed to launch. This is similar to the instructions about /etc/portage/make.conf earlier, with the MAKEOPTS variable.

When the kernel has finished compiling, copy the kernel image to /boot/. This is handled by the make install command:

root #make install

This will copy the kernel image into /boot/ together with the System.map file and the kernel configuration file.



任意自由選択: initramfsのビルド

いくつかの特別なケースでinitramfs(起動時のRAMベースのファイルシステム)のビルドが必要になります。最もよくある理由は、重要なディレクトリ(/usr//var/等)が別パーティションにある場合です。initramfsがあれば、initramfsの中にあるツールを使うことで、これらのパーティションをマウントすることができます。

initramfsがないケースで、ファイルシステムをマウントするツールがそのファイルシステムの中にある情報を必要としている場合、大きなリスクを負うことになります。initramfsはカーネルブートの直後かつ制御がinitツールに移る前に必要なファイルをアーカイブに引き込みます。initramfsのスクリプトはシステムがブートを継続するために必要なパーティションを正しくマウントすることを保証します。

initramfsをインストールするために、最初にsys-kernel/genkernelをインストールしましょう。そしてinitramfsを生成します。

root #emerge --ask sys-kernel/genkernel
root #genkernel --install initramfs

LVMやRAID等の特別なサポートをinitramfsで有効にするために、genkernelに適切なオプションを与えてください。詳しい情報については、genkernel --helpを参照してください。次の例では、LVMとソフトウェアRAID (mdadm)を有効にしています。

root #genkernel --lvm --mdadm --install initramfs

initramfsは/boot/に保存されます。生成されるファイルは単純にinitramfsで始まります。

root #ls /boot/initramfs*

次はカーネルモジュールです。

別の方法: genkernelを使用する

もしマニュアル設定に気後れしてしまった場合、genkernelがお薦めです。genkernelは自動的にカーネルを設定、ビルドします。

genkernelはインストールCDのカーネルが自動的に設定されるのとほぼ同じ方法でカーネルを設定します。これはカーネルのビルドにgenkernelを使った場合、インストールCDと同じようにブート時にすべてのハードウェアを検出することを意味します。genkernelはいかなるカーネルのマニュアル設定も要求しないため、ユーザー自身のカーネルをコンパイルすることを好まないユーザには理想的なソリューションです。

では、genkernelの使い方を見てみましょう。最初にsys-kernel/genkernelをemergeします。

root #emerge --ask sys-kernel/genkernel

次に、/etc/fstabファイルを編集します。2番目のフィールドに/boot/を含む行は、その1番目のフィールドで正しいデバイス指定します。もしハンドブックのパーティショニング例の通りであれば、このデバイスはほぼ間違いなくext2ファイルシステムを持つ/dev/sda2でしょう。この場合、エントリは次のようになります。

root #nano -w /etc/fstab
FILE /etc/fstab/bootマウントポイントを設定する
/dev/sda2	/boot	ext2	defaults	0 2
注意
Gentooインストールでは、/etc/fstabはさらにもう一回編集されますが、/bootの設定はgenkernelアプリケーションがそれを読み込むために今必要です

genkernel allを実行してカーネルソースをコンパイルしましょう。ただ、genkernelはほとんどすべてのハードウェアをサポートするカーネルを生成するため、コンパイルが完了するまでにかなりの時間が必要になることに注意しましょう。

注意
もしブートパーティションがファイルシステムとしてext2もext3も使用していない場合、おそらく、genkernel --menuconfig allを使ってマニュアルでカーネルを設定し、カーネルにこの特別なファイルシステムを(モジュールではなく)組み込む必要があるでしょう。また、LVM2のユーザーはおそらく引数に--lvmを加えることになるでしょう。
root #genkernel all

genkernel完了後、カーネル、モジュール群、初期RAMディスク(initramfs)が生成されるでしょう。このドキュメントの後半でブートローダーを設定する際、このカーネルとinitrdを使うことになります。ブートローダーの設定に必要になるため、カーネルとinitrdの名前をメモしておきましょう。"真の"システムが起動する前に(インストールCDがするように)ハードウェアを自動的に検出しなければならないため、initrdはブート後すぐに起動します。

root #ls /boot/kernel* /boot/initramfs*

カーネルモジュール

モジュールの設定

Note
ハードウェアモジュールを手作業で列挙する必要はありません。ほとんどの場合、udev は接続を検出したハードウェアのモジュールを自動でロードします。ですが、自動で検出されるモジュールを列挙することは特に有害ではありません。時として変なハードウェアは、ドライバをロードするのにこうした手助けが必要になることがあります。

/etc/modules-load.d/*.confファイルに、自動的にロードしなければならないモジュールを改行区切りで記載してください。モジュールに追加のオプションを与える必要があれば、/etc/modprobe.d/*.confファイルで設定すべきです。

すべての利用可能なモジュールを把握するためには、次のfindコマンドを実行してください。"<kernel version>"をたった今コンパイルしたカーネルのバージョンで置き換えることを忘れないでください。

root #find /lib/modules/<kernel version>/ -type f -iname '*.o' -or -iname '*.ko' | less

たとえば、3c59x.koモジュール(特定の3Comネットワークカード)を自動的にロードするためには、/etc/modules-load.d/network.confにモジュール名を記載してください。実際のファイル名はローダにとって重要ではありません。

root #mkdir -p /etc/modules-load.d
root #nano -w /etc/modules-load.d/network.conf
FILE /etc/modules-load.d/network.conf強制的に3c59x モジュールをロードする
3c59x

では、システムの設定に進み、インストールを続けましょう。

任意自由選択: ファームウェアのインストール

いくつかのドライバは、動作可能にするために追加のファームウェアのインストールを必要とします。これはしばしばネットワークインターフェース、特に無線ネットワークで必要になります。さらに、AMD、NVidia、Intelなどのベンダによる最近のビデオチップをオープンソースドライバで利用する場合にも、よく外部のファームウェアが必要になります。ファームウェアの多くはsys-kernel/linux-firmwareにパッケージされています。

root #emerge --ask sys-kernel/linux-firmware




X86 ハンドブック
インストール
インストールについて
メディアの選択
ネットワーク設定
ディスクの準備
stage3のインストール
Gentooベースシステムのインストール
カーネルの設定
システムの設定
ツールのインストール
ブートローダの設定
締めくくり
Gentooの操作
Portageについて
USEフラグ
Portageの機能
Initスクリプトシステム
環境変数
Portageの操作
ファイルとディレクトリ
変数
ソフトウェアブランチの併用
追加ツール
カスタムPortageツリー
高度な機能
ネットワーク設定
はじめに
高度な設定
モジュール式ネットワーク
無線
機能の追加
動的な管理


ファイルシステムの情報

fstabについて

Linuxでは、システムで使用するすべてのパーティションは/etc/fstabに記載されていなければなりません。このファイルは、これらパーティションのマウントポイント(これらはファイルシステムに存在しなければなりません)、どのようにマウントされるべきか、また特別なオプション(自動マウントかそうでないか、ユーザー権限でマウントできるかどうか等)を定義します。

fstabファイルを作成する

/etc/fstabファイルは表のように記述します。それぞれの行はスペース(一つまたは複数のスペース、タブ、もしくはその組み合わせ)で区切られる6つのフィールドを持ちます。それぞれのフィールドの意味は以下の通りです。

  1. 最初のフィールドは使用するパーティションを示します。(デバイスファイルのパス)
  2. 2番目のフィールドはそのパーティションがマウントされるマウントポイントを示します。
  3. 3番目のフィールドはそのパーティションのファイルシステムを示します。
  4. 4番目のフィールドは、そのパーティションをマウントするmountコマンドが使用するオプションを示します。すべてのファイルシステムは、固有のマウントオプションを持っています。ユーザーはマウントコマンドのmanページ(man mount)を参照することですべてのオプションを確認できます。複数のマウントオプションを記述する場合はカンマで区切ります。
  5. 5番目のフィールドはそのパーティションをdumpでダンプするかどうかを示しています。このフィールドは通常0(ゼロ)のままにしておいてかまいません。
  6. 6番目のフィールドは、直前のシャットダウンが正常に完了しなかったときに、fsckが各パーティションをどの順番でチェックするか示しています。ルートファイルシステムは1であるべきです。残りのファイルシステムは2(ファイルシステムチェックが不要であれば0)に設定しましょう。
重要
Gentooが提供するデフォルトの/etc/fstabファイルは適切な記述ではありません。テンプレートとしてのみ使用してください
root #nano -w /etc/fstab

これ以降、パーティションとして、デフォルトのブロックデバイスファイルである/dev/sd*を使います。

Filesystem labels and UUIDs

Both MBR (BIOS) and GPT include support for filesystem labels and filesystem UUIDs. These attributes can be defined in /etc/fstab as alternatives for the mount command to use when attempting to find and mount block devices. Filesystem labels and UUIDs are identified by the LABEL and UUID prefix and can be viewed with the blkid command:

root #blkid
Warning
If the filesystem inside a partition is wiped, then the filesystem label and the UUID values will be subsequently altered or removed.

Because of uniqueness, readers that are using an MBR-style partition table are recommended to use UUIDs over labels to define mountable volumes in /etc/fstab.

パーティションラベルとUUID

Users who have gone the GPT route have a couple more 'robust' options available to define partitions in /etc/fstab. Partition labels and partition UUIDs can be used to identify the block device's individual partition(s), regardless of what filesystem has been chosen for the partition itself. Partition labels and UUIDs are identified by the PARTLABEL and PARTUUID prefixes respectively and can be viewed nicely in the terminal by running the blkid command:

root #blkid

ラベルも絶対にとは言えないのに対し、fstab でUUIDを使ったパーティション指定を使えば、ブートローダーがパーティション検出に迷うことはありません。ブロックデバイスファイルが変わったとしてもです。従来のブロックデバイスファイル (/dev/sd*N) を使った指定は、SATAブロックデバイスの追加・削除とシステムの再起動が頻繁に行われるシステムでは危険です。

ブロックデバイスのファイル名は様々な要素 (例えばディスクがどんな順番でいくつ接続されているか) によって変化します。つまり、ディスクの順序を頻繁にいじったりしない限りは、デフォルトのブロックデバイスファイルを使うのはシンプルで素直な方法です。


Let us take a look at how to write down the options for the /boot/ partition. This is just an example, and should be modified according to the partitioning decisions made earlier in the installation. In our x86 partitioning example, /boot/ is usually the /dev/sda2 partition, with ext2 as filesystem. It needs to be checked during boot, so we would write down:

FILE /etc/fstabAn example /boot line for /etc/fstab
/dev/sda2   /boot     ext2    defaults        0 2

Some users don't want their /boot/ partition to be mounted automatically to improve their system's security. Those people should substitute defaults with noauto. This does mean that those users will need to manually mount this partition every time they want to use it.

実際のパーティション構成にあわせたルールや、CD-ROMドライブのためのルールを追加してください。他にパーティションやドライブがあれば、それも忘れずに追加しておきましょう。

以下は、より詳細な/etc/fstabの例です。


FILE /etc/fstabA full /etc/fstab example
/dev/sda2   /boot        ext2    defaults,noatime     0 2
/dev/sda3   none         swap    sw                   0 0
/dev/sda4   /            ext4    noatime              0 1
  
/dev/cdrom  /mnt/cdrom   auto    noauto,user          0 0

3番目のフィールドでautoを使う場合、mountコマンドはそのパーティションのファイルシステムが何かを推測します。これは様々なファイルシステムを使う可能性があるリムーバルメディアで推奨されます。4番目のuserオプションで、ルート権限を持たないユーザーがCDをマウントできるようになります。

パフォーマンスを改善するために、多くのユーザーはマウントオプションとしてnoatimeオプションを付け加えたいと考えるでしょう。アクセス時間が記録されないので、結果としてより高速なシステムになります(一般的にこの記録はほとんど必要ありません)。TRIMコマンドが動くようにdiscardオプション(現時点ではext4とbtrfsのみ)を使ってSSDをマウントする場合も、noatimeオプションを付けるとよいでしょう。

再度/etc/fstabを確認して、保存、エディタを終了します。

ネットワーク接続のための情報

ホストとドメインのための情報

さて、PCには名前をつけなければいけません。至極簡単に思えますが多くのユーザーはPCに名前を付けるのに苦労しています。事を早く進めるために、選んだ名前は後で変更できることを知っておいてください。判りやすいように、ここでは単にマシンをtux、ドメイン名をhomenetworkと呼ぶことにします。

root #nano -w /etc/conf.d/hostname
# hostname変数にホスト名を設定する。
hostname="tux"

次に、もしドメイン名が必要なら、/etc/conf.d/netに設定します。ISPやネットワーク管理者からそう言われているか、DNSサーバがありDHCPサーバがない場合には、ドメイン名が必要になります。もし、ダイナミックIPアドレスやネットワーク設定のためにDHCPを使っている場合は、DNSやドメイン名は気にしなくても構いません。

注意
デフォルトで/etc/conf.d/netが無い場合、新規作成する必要があります。
root #nano -w /etc/conf.d/net
# dns_domain_lo変数にドメイン名を設定する。
dns_domain_lo="homenetwork"
注意
もしドメイン名を設定しない場合、ログイン画面に"This is hostname.(none)"というメッセージが現れるでしょう。これは/etc/issueを編集して、.\Oを消去することで対策できます。

もし、NISドメインが必要であれば(それが何かを知らないユーザは必要ありません)、以下のように定義してください。

root #nano -w /etc/conf.d/net
# nis_domain_lo変数にNISドメイン名を設定。
nis_domain_lo="my-nisdomain"
注意
DNSとNISの設定詳細については、/usr/share/doc/netifrc-*/net.example.bz2にある例を参照してください。このファイルはbzlessで読むことができます。また、DNS/NIS設定を管理する場合、net-dns/openresolvをインストールすることは興味深いでしょう。

ネットワークを設定する

Gentoo Linuxをインストールしている間、ネットワークが使えるように設定されています。しかし、それはインストールCDのためのネットワーク設定であり、インストールされた環境のためのものではありません。では、インストールされたGentoo Linuxのネットワークを設定しましょう。

注意
bonding、ブリッジ、802.1Q VLAN、無線ネットワークに間するより詳細な情報は、Gentoo Network Configurationセクションを参照してください。

すべてのネットワーク設定は/etc/conf.d/netにあります。直接的ではありますが、おそらく直感で理解できる構文ではありません。しかし恐れることはありません。すべては以下で説明されます。/usr/share/doc/netifrc-*/net.example.bz2に、多くの異なる設定に対して完全にコメントが付与された例が記載されています。

最初に net-misc/netifrc をインストールします。

root #emerge --ask --noreplace net-misc/netifrc

DHCPはデフォルトで使用されます。DHCPを動かすために、DHCPクライアントをインストールしなければなりません。これは Installing Necessary System Toolsで説明されます。

もし、特別なDHCPのオプションを設定している、もしくはDHCPをまったく使いたくない等の理由で、ネットワーク接続をしなければならないときは、/etc/conf.d/netを編集します。

root #nano -w /etc/conf.d/net

IPアドレスとルーティングを設定するのはconfig_eth0routes_eth0です。

注意
ここではネットワークインターフェイスがeth0であると仮定していますが、これはシステムによって違います。もし、最近のインストールメディアから起動しているのであれば、インストール時と同じインターフェイス名が使われると思ってよいでしょう。より詳しい情報はNetwork Interface Namingを参照してください。
FILE /etc/conf.d/net
config_eth0="192.168.0.2 netmask 255.255.255.0 brd 192.168.0.255"
routes_eth0="default via 192.168.0.1"

DHCPを使う場合は、config_eth0を設定してください。

FILE /etc/conf.d/netDHCPの定義
config_eth0="dhcp"

使用可能なオプションのリストについては、/usr/share/doc/netifrc-*/net.example.bz2を参照してください。もし特定のDHCPを設定しなければならないときは、DHCPクライアントのmanページも必ず読みましょう。

もし、システムが複数のネットワークインターフェースを持っている場合は、config_eth1config_eth2、…に対して上記の手順を繰り返してください。

設定を保存し、エディタを終了しましょう。

起動時に自動でネットワーク接続する

ブート時にネットワークインターフェースを有効にする場合は、デフォルトランレベルにそれらを追加する必要があります。

root #cd /etc/init.d
root #ln -s net.lo net.eth0
root #rc-update add net.eth0 default

もし、複数のネットワークインターフェースがある場合は、net.eth0と同じ方法で、適切なnet.*ファイルを作成しなければなりません。

もし、ブート後、ネットワークインターフェース名(現在、このドキュメントではeth0と記述)が間違っていた場合、次の手順で修正してください。

  1. 正しいインターフェース名で/etc/conf.d/netファイルを更新します。(例えばeth0enp3s0と修正)
  2. 新しいシンボリックリンクを作成。(例えば/etc/init.d/net.enp3s0
  3. 古いシンボリックリンクを消去。(rm /etc/init.d/net.eth0
  4. 新しいスクリプトをデフォルトランレベルに追加。
  5. rc-update del net.eth0 defaultで古いスクリプトを消去。

hostsファイル

次に、ネットワーク環境をLinuxに伝えます。これは/etc/hostsに定義され、ネームサーバでは解決できないホストについて、ホスト名からIPアドレスを決められるようになります。

root #nano -w /etc/hosts
FILE /etc/hostsネットワーク情報の記述
# 以下は本システムの定義です。必ず設定されなければなりません。
127.0.0.1     tux.homenetwork tux localhost
  
# ネットワーク上にあるその他のホストの定義です。任意設定です。
192.168.0.5   jenny.homenetwork jenny
192.168.0.6   benny.homenetwork benny

設定をセーブし、エディタを終了しましょう。

任意自由選択: PCMCIAを機能させる

PCMCIAユーザーは、sys-apps/pcmciautilsパッケージをインストールする必要があります。

root #emerge --ask sys-apps/pcmciautils

システム情報

rootパスワード

passwdコマンドでルートのパスワードを設定します。

root #passwd

ルートアカウントはとてもパワフルなアカウントなので、強いパスワードを与えてください。後で、日常の作業のための一般ユーザーアカウントを作成します。

initとboot設定

(少なくともOpenRCを使っているときは)Gentooは、システムのサービス、スタートアップ、シャットダウンの設定に/etc/rc.confを使います。/etc/rc.confを開いて、ファイル中のすべてのコメントを楽しみましょう。設定をレビューして、必要な箇所を変更してください。

root #nano -w /etc/rc.conf

次に、キーボードを設定するために/etc/conf.d/keymapsを開いて、正しいキーボードを選択、設定します。

root #nano -w /etc/conf.d/keymaps

keymap変数に特に注意してください。もしキーマップを間違えた場合、キーボードを叩くたびに、奇妙な現象が起こるでしょう。

最後に、クロック設定をするために/etc/conf.d/hwclockを編集します。個々の好みに合わせて設定できます。

root #nano -w /etc/conf.d/hwclock

もし、ハードウェアクロックがUTCになっていない場合、このファイルにclock="local"を記述しなければなりません。そうでない場合、クロックスキューが発生するでしょう。




X86 ハンドブック
インストール
インストールについて
メディアの選択
ネットワーク設定
ディスクの準備
stage3のインストール
Gentooベースシステムのインストール
カーネルの設定
システムの設定
ツールのインストール
ブートローダの設定
締めくくり
Gentooの操作
Portageについて
USEフラグ
Portageの機能
Initスクリプトシステム
環境変数
Portageの操作
ファイルとディレクトリ
変数
ソフトウェアブランチの併用
追加ツール
カスタムPortageツリー
高度な機能
ネットワーク設定
はじめに
高度な設定
モジュール式ネットワーク
無線
機能の追加
動的な管理


システムロガー

同じ機能が複数のパッケージによって提供されるツールがいくつかあります。そういったツールはstage3アーカイブには含まれていません。どのパッケージをインストールしたいのかをあなた次第で選んでください。

まずシステムにロギング機能を提供するツールを決定しましょう。UnixとLinuxでは歴史をかけて素晴らしいログ機能を発展させてきました -- お望みならログファイルにシステムで起こった全てを記録できます。これはシステムロガーを使って行ないます。

Gentooでは複数のシステムロガーから使いたいものを選択することができます。このうちのいくつかを紹介します。

  • app-admin/sysklogdは、システムのログを取得するための伝統的なデーモンを集めたものです。デフォルトのログ設定をそのまま使ってもうまく働くので、このパッケージは初心者にはいい選択肢です。
  • app-admin/syslog-ngは、進化したシステムロガーです。1つの大きなファイルにログを取る以上のことをするには、何らかの設定が必要です。更に上級のユーザは、ロギングの発展性に基いてこのパッケージを選択できます。スマートなロギングのためには追加の設定が必要になることに注意してください。
  • app-admin/metalogは、高度な設定ができるシステムロガーです。

Portageツリーにはまだまだ他の選択肢があることでしょう。日毎にPortageツリーのパッケージは増えていますから。

Tip
もしsysklogdかsyslog-ngを使おうと思っているなら、これらのシステムログツールにはログファイルをローテーションする機構が無いので、後でlogrotateをインストールして設定しましょう。
Tip
systemd provides its own logging facility called the "journal". Installing a separate syslog provider is optional on systems running systemd, and may require additional configuration to have the syslog daemon read messages from the journal.

選択したシステムログツールをインストールするには、それをemergeして、rc-updateを使ってデフォルトのランレベルにスクリプトを追加してください。次の例ではapp-admin/sysklogdをインストールします。

root #emerge --ask app-admin/sysklogd
root #rc-update add sysklogd default

任意自由選択: cronデーモン

次はcronデーモンです。cronデーモンは入れても入れなくてもよく、システムに必須ではありませんが、インストールしておくのが賢明でしょう。

cronデーモンは予定されたコマンドを実行します。定期的(例えば日毎、週毎、月毎)にあるコマンドを実行する必要があるならとても重宝します。

Gentooではいくつものcronデーモンを提供しています。例をあげると sys-process/bcronsys-process/dcronsys-process/fcron、そしてsys-process/cronieです。その内の1つをインストールするのはシステムロガーをインストールするのに似ています。次の例はsys-process/cronieをインストールします。

root #emerge --ask sys-process/cronie
root #rc-update add cronie default

dcronかfcronを使う場合、初期設定のための追加コマンドが必要です。

root #crontab /etc/crontab

任意自由選択: ファイルのインデックスを作成

より高速なファイル検索のためにファイルシステム中の各ファイルのインデックスを作成するときは、sys-apps/mlocateをインストールしてください。

root #emerge --ask sys-apps/mlocate

任意自由選択: リモートアクセス

インストール後、システムにリモートからアクセスできるようにするためには、sshdをデフォルトのランレベルに追加してください。

root #rc-update add sshd default

(たとえばリモートサーバで)シリアルコンソールからアクセスしなければならない場合、/etc/inittabのシリアルコンソールの部分のコメントを外します。

root #nano -w /etc/inittab
# SERIAL CONSOLES
s0:12345:respawn:/sbin/agetty 9600 ttyS0 vt100
s1:12345:respawn:/sbin/agetty 9600 ttyS1 vt100

ファイルシステムツール

使っているファイルシステムよって、(ファイルシステムの整合性をチェックしたり、追加のファイルシステムを作成する等のために)必須のファイルシステムツールをインストールする必要があります。ext2/ext3/ext4ファイルシステムを管理するためのツール(sys-fs/e2fsprogs)は@system セットの一部としてインストール済みであることに注意してください。

次の表は、ファイルシステム毎にどのツールをインストールすべきかを示します。

ファイルシステム パッケージ
Ext2, 3, 4 sys-fs/e2fsprogs
XFS sys-fs/xfsprogs
ReiserFS sys-fs/reiserfsprogs
JFS sys-fs/jfsutils
VFAT (FAT32, ...) sys-fs/dosfstools
Btrfs sys-fs/btrfs-progs
Tip
Gentooのファイルシステムについてのさらなる情報は、ファイルシステムの記事を参照してください。

ネットワークツール

もし、追加のネットワークツールを必要としない場合、ブートローダーに進みましょう。

DHCPクライアントをインストールする

重要
DHCPはあくまで任意選択ですが、多くのユーザはネットワークに接続するためにDHCPクライアントが必要になるでしょう。この機会にDHCPクライアントをインストールしましょう。もしこの設定を忘れた場合、ネットワークに接続できないことになり、これによりDHCPクライアントがダウンロードできなくなってしまいます。

netifrcスクリプトを使用して、一つ以上のネットワークに自動的にIPアドレスを付与するときは、DHCPクライアントをインストールする必要があります。Gentooリポジトリには多くのDHCPクライアントがありますが、net-misc/dhcpcdがお薦めです。

root #emerge --ask net-misc/dhcpcd

dhcpcd articledhcpcdに関するより多くの情報があります。

任意自由選択: PPPoEクライアントのインストール

もしインターネットに接続するためにPPPを使うのであれば、net-dialup/pppパッケージをインストールします。

root #emerge --ask net-dialup/ppp

Optional: Install wireless networking tools

If the system will be connecting to wireless networks, install the net-wireless/iw package for Open or WEP networks and/or the net-wireless/wpa_supplicant package for WPA or WPA2 networks. iw is also a useful basic diagnostic tool for scanning wireless networks.

root #emerge --ask net-wireless/iw net-wireless/wpa_supplicant

次はブートローダーです。




X86 ハンドブック
インストール
インストールについて
メディアの選択
ネットワーク設定
ディスクの準備
stage3のインストール
Gentooベースシステムのインストール
カーネルの設定
システムの設定
ツールのインストール
ブートローダの設定
締めくくり
Gentooの操作
Portageについて
USEフラグ
Portageの機能
Initスクリプトシステム
環境変数
Portageの操作
ファイルとディレクトリ
変数
ソフトウェアブランチの併用
追加ツール
カスタムPortageツリー
高度な機能
ネットワーク設定
はじめに
高度な設定
モジュール式ネットワーク
無線
機能の追加
動的な管理


Although installing for a 32-bit CPU, almost all x86 motherboards (starting from around 2006-2007 until the present) that were produced with support for UEFI have 64-bit UEFI firmware. Some users may notice "64" in the name of configuration settings and files in the coming sections below. This is expected in nearly every case.

There are a few very small exceptions to this 64-bit UEFI firmware rule, namely few early Apple Macs and some Intel Atom powered Dell tablet PCs had support for 32-bit UEFI firmware. The vast majority of readers will never encounter 32-bit UEFI firmware in the wild. For this reason 32-bit UEFI firmware is not covered in the x86 Handbook.


Selecting a boot loader

With the Linux kernel configured, system tools installed and configuration files edited, it is time to install the last important piece of a Linux installation: the boot loader.

The boot loader is responsible for firing up the Linux kernel upon boot - without it, the system would not know how to proceed when the power button has been pressed.

For x86, we document how to configure either GRUB2 or LILO for BIOS based systems, and GRUB2 or efibootmgr for UEFI systems.

In this section of the Handbook a delineation has been made between emerging the boot loader's package and installing a boot loader to a system disk. Here the term emerge will be used to ask Portage to make the software package available to the system. The term install will signify the boot loader copying files or physically modifying appropriate sections of the system's disk drive in order to render the boot loader activated and ready to operate on the next power cycle.

Default: GRUB2

Previously, Gentoo Linux used what is now called GRUB Legacy as the recommended boot loader. As the name implies, the older GRUB package is no longer actively maintained and has been superseded by GRUB2. For more information about the legacy GRUB, please refer to its GRUB article.

By default, the majority of Gentoo systems now rely upon GRUB2 (found in the sys-boot/grub package), which is the direct successor to GRUB Legacy. With no additional configuration, GRUB2 gladly supports older BIOS ("pc") systems. With a small amount of configuration, necessary before build time, GRUB2 can support more than a half a dozen additional platforms. For more information, consult the Prerequisites section of the GRUB2 article.

Emerge

When using an older BIOS system supporting only MBR partition tables, no additional configuration is needed in order to emerge GRUB:

root #emerge --ask --verbose sys-boot/grub:2

A note for UEFI users: running the above command will output the enabled GRUB_PLATFORMS values before emerging. When using UEFI capable systems, users will need to ensure GRUB_PLATFORMS="efi-64" is enabled (as it is the case by default). If that is not the case for the setup, GRUB_PLATFORMS="efi-64" will need to be added to the /etc/portage/make.conf file before emerging GRUB2 so that the package will be built with EFI functionality:

root #echo 'GRUB_PLATFORMS="efi-64"' >> /etc/portage/make.conf
root #emerge --ask sys-boot/grub:2
If GRUB2 was somehow emerged without enabling GRUB_PLATFORMS="efi-64", the line (as shown above) can be added to make.conf then and dependencies for the world package set re-calculated by passing the --update --newuse options to emerge:
root #emerge --ask --update --newuse --verbose sys-boot/grub:2

The GRUB2 software has now been merged to the system, but not yet installed.

Install

Next, install the necessary GRUB2 files to the /boot/grub/ directory via the grub-install command. Presuming the first disk (the one where the system boots from) is /dev/sda, one of the following commands will do:

  • When using BIOS:
root #grub-install /dev/sda
  • When using UEFI:
Important
Make sure the EFI system partition has been mounted before running grub-install. It is possible for grub-install to install the GRUB EFI file (grubx64.efi) into the wrong directory without providing any indication the wrong directory was used.
root #grub-install --target=x86_64-efi --efi-directory=/boot
Note
Modify the --efi-directory option to the root of the EFI System Partition. This is necessary if the /boot partition was not formatted as a FAT variant.
Important
If grub_install returns an error like Could not prepare Boot variable: Read-only file system, it may be necessary to remount the efivars special mount as read-write in order to succeed:
root #mount -o remount,rw /sys/firmware/efi/efivars

Some motherboard manufacturers seem to only support the /efi/boot/ directory location for the .EFI file in the EFI System Partition (ESP). The GRUB installer can perform this operation automatically with the --removable option. Verify the ESP is mounted before running the following commands. Presuming the ESP is mounted at /boot (as suggested earlier), execute:

root #grub-install --target=x86_64-efi --efi-directory=/boot --removable

This creates the default directory defined by the UEFI specification, and then copies the grubx64.efi file to the 'default' EFI file location defined by the same specification.

Configure

Next, generate the GRUB2 configuration based on the user configuration specified in the /etc/default/grub file and /etc/grub.d scripts. In most cases, no configuration is needed by users as GRUB2 will automatically detect which kernel to boot (the highest one available in /boot/) and what the root file system is. It is also possible to append kernel parameters in /etc/default/grub using the GRUB_CMDLINE_LINUX variable.

To generate the final GRUB2 configuration, run the grub-mkconfig command:

root #grub-mkconfig -o /boot/grub/grub.cfg
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-3.16.5-gentoo
Found initrd image: /boot/initramfs-genkernel-x86-3.16.5-gentoo
done

The output of the command must mention that at least one Linux image is found, as those are needed to boot the system. If an initramfs is used or genkernel was used to build the kernel, the correct initrd image should be detected as well. If this is not the case, go to /boot/ and check the contents using the ls command. If the files are indeed missing, go back to the kernel configuration and installation instructions.

Tip
The os-prober utility can be used in conjunction with GRUB2 to detect other operating systems from attached drives. Windows 7, 8.1, 10, and other distributions of Linux are detectable. Those desiring dual boot systems should emerge the sys-boot/os-prober package then re-run the grub-mkconfig command (as seen above). If detection problems are encountered be sure to read the GRUB2 article in its entirety before asking the Gentoo community for support.

Alternative 1: LILO

Emerge

LILO, the LInuxLOader, is the tried and true workhorse of Linux boot loaders. However, it lacks features when compared to GRUB. LILO is still used because, on some systems, GRUB does not work and LILO does. Of course, it is also used because some people know LILO and want to stick with it. Either way, Gentoo supports both bootloaders.

Installing LILO is a breeze; just use emerge.

root #emerge --ask sys-boot/lilo

Configure

To configure LILO, first create /etc/lilo.conf:

root #nano -w /etc/lilo.conf

In the configuration file, sections are used to refer to the bootable kernel. Make sure that the kernel files (with kernel version) and initramfs files are known, as they need to be referred to in this configuration file.

Note
If the root filesystem is JFS, add an append="ro" line after each boot item since JFS needs to replay its log before it allows read-write mounting.
FILE /etc/lilo.confExample LILO configuration
boot=/dev/sda             # Install LILO in the MBR
prompt                    # Give the user the chance to select another section
timeout=50                # Wait 5 (five) seconds before booting the default section
default=gentoo            # When the timeout has passed, boot the "gentoo" section
compact                   # This drastically reduces load time and keeps the map file smaller; may fail on some systems
  
image=/boot/vmlinuz-3.16.5-gentoo
  label=gentoo            # Name we give to this section
  read-only               # Start with a read-only root. Do not alter!
  root=/dev/sda4          # Location of the root filesystem
  
image=/boot/vmlinuz-3.16.5-gentoo
  label=gentoo.rescue     # Name we give to this section
  read-only               # Start with a read-only root. Do not alter!
  root=/dev/sda4         # Location of the root filesystem
  append="init=/bin/bb"   # Launch the Gentoo static rescue shell
  
# The next two lines are for dual booting with a Windows system.
# In this example, Windows is hosted on /dev/sda6.
other=/dev/sda6
  label=windows
Note
If a different partitioning scheme and/or kernel image is used, adjust accordingly.

If an initramfs is necessary, then change the configuration by referring to this initramfs file and telling the initramfs where the root device is located:

FILE /etc/lilo.confAdding initramfs information to a boot entry
image=/boot/vmlinuz-3.16.5-gentoo
  label=gentoo
  read-only
  append="root=/dev/sda4"
  initrd=/boot/initramfs-genkernel-x86-3.16.5-gentoo

If additional options need to be passed to the kernel, use an append statement. For instance, to add the video statement to enable framebuffer:

FILE /etc/lilo.confAdding video parameter to the boot options
image=/boot/vmlinuz-3.16.5-gentoo
  label=gentoo
  read-only
  root=/dev/sda4
  append="video=uvesafb:mtrr,ywrap,1024x768-32@85"

Users that used genkernel should know that their kernels use the same boot options as is used for the installation CD. For instance, if SCSI device support needs to be enabled, add doscsi as kernel option.

Now save the file and exit.

Install

To finish up, run the /sbin/lilo executable so LILO can apply the /etc/lilo.conf settings to the system (i.e. install itself on the disk). Keep in mind that /sbin/lilo must be executed each time a new kernel is installed or a change has been made to the lilo.conf file in order for the system to boot if the filename of the kernel has changed.

root #/sbin/lilo

Alternative 2: efibootmgr

On UEFI based systems, the UEFI firmware on the system (in other words the primary bootloader), can be directly manipulated to look for UEFI boot entries. Such systems do not need to have additional (also known as secondary) bootloaders like GRUB2 in order to help boot the system. With that being said, the reason EFI-based bootloaders such as GRUB2 exist is to extend the functionality of UEFI systems during the boot process. Using efibootmgr is really for those who desire to take a minimalist (although more rigid) approach to booting their system; using GRUB2 (see above) is easier for the majority of users because it offers a flexible approach when booting UEFI systems.

Remember sys-boot/efibootmgr application is not a bootloader; it is a tool to interact with the UEFI firmware and update its settings, so that the Linux kernel that was previously installed can be booted with additional options (if necessary), or to allow multiple boot entries. This interaction is done through the EFI variables (hence the need for kernel support of EFI vars).

Be sure to read through the EFI stub kernel article before continuing. The kernel must have specific options enabled to be directly bootable by the system's UEFI firmware. It might be necessary to recompile the kernel. It is also a good idea to take a look at the efibootmgr article.

Note
To reiterate, efibootmgr is not a requirement to boot an UEFI system. The Linux kernel itself can be booted immediately, and additional kernel command-line options can be built-in to the Linux kernel (there is a kernel configuration option called that allows the user to specify boot parameters as command-line options. Even an initramfs can be 'built-in' to the kernel.

Those that have decided to take this approach must install the software:

root #emerge --ask sys-boot/efibootmgr

Then, create the /boot/efi/boot/ location, and then copy the kernel into this location, calling it bootx64.efi:

root #mkdir -p /boot/efi/boot
root #cp /boot/vmlinuz-* /boot/efi/boot/bootx64.efi

Next, tell the UEFI firmware that a boot entry called "Gentoo" is to be created, which has the freshly compiled EFI stub kernel:

root #efibootmgr --create --disk /dev/sda --part 2 --label "Gentoo" --loader "\efi\boot\bootx64.efi"

If an initial RAM file system (initramfs) is used, add the proper boot option to it:

root #efibootmgr -c -d /dev/sda -p 2 -L "Gentoo" -l "\efi\boot\bootx64.efi" initrd='\initramfs-genkernel-x86-3.16.5-gentoo'
Note
The use of \ as directory separator is mandatory when using UEFI definitions.

With these changes done, when the system reboots, a boot entry called "Gentoo" will be available.

Alternative 3: Syslinux

Syslinux is yet another bootloader alternative for the x86 architecture. It supports MBR and, as of version 6.00, it supports EFI boot. PXE (network) boot and lesser-known options are also supported. Although Syslinux is a popular bootloader for many it is unsupported by the Handbook. Readers can find information on emerging and then installing this bootloader in the Syslinux article.



システムのリブート

chroot環境を出て、全てのパーティションをアンマウントします。次に、最終かつ真のテストを実行するためのマジカルコマンドrebootを入力しましょう。

root #exit
cdimage ~#cd
cdimage ~#umount -l /mnt/gentoo/dev{/shm,/pts,}
cdimage ~#umount -R /mnt/gentoo
cdimage ~#reboot

もちろん、ブートCDを取り出しておいてください。そうしないと新しいGentooではなく、再度CDをブートしてしまいます。

新規にインストールされたGentooをリブートした後は、最終章インストールの締めくくりに進みましょう。




X86 ハンドブック
インストール
インストールについて
メディアの選択
ネットワーク設定
ディスクの準備
stage3のインストール
Gentooベースシステムのインストール
カーネルの設定
システムの設定
ツールのインストール
ブートローダの設定
締めくくり
Gentooの操作
Portageについて
USEフラグ
Portageの機能
Initスクリプトシステム
環境変数
Portageの操作
ファイルとディレクトリ
変数
ソフトウェアブランチの併用
追加ツール
カスタムPortageツリー
高度な機能
ネットワーク設定
はじめに
高度な設定
モジュール式ネットワーク
無線
機能の追加
動的な管理


ユーザー管理

毎日使用するためのユーザを追加します

Unix/Linuxシステム上で、rootとして作業するのは危険であり、できるだけ避けるべきです。そのため、日々の使用のためのユーザーを追加することを強くお勧めします。

グループは、そのグループに所属するメンバーができることを定義します。次の表はいくつかの重要なグループを示します。

グループ 説明
audio オーディオデバイスにアクセスできます。
cdrom 光学デバイスに直接アクセスできます。
floppy フロッピーデバイスに直接アクセスできます。
games ゲームができます。
portage Portageの制限されたリソースにアクセスできます。
usb USBデバイスにアクセスできます。
video ビデオキャプチャのためのハードウェアにアクセスして、ハードウェアアクセラレーションを有効にできます。
wheel suを使うことができます。

例えばwheelusersaudioの3グループに所属するlarryというユーザを作成するには、最初にrootとしてログインし(rootだけがユーザを作ることができます)、useraddを実行します。

Login:root
Password: (rootのパスワードを入力してください)
root #useradd -m -G users,wheel,audio -s /bin/bash larry
root #passwd larry
Password: (larryのパスワードを入力してください)
Re-enter password: (確認のためにもう一度パスワードを入力してください)

もし、rootで何か作業をする場合は、一時的にroot権限を得るためにsu -を使います。別の方法はsudoパッケージを使用することです。これは(正しく設定されれば)とても安全です。

ディスクのクリーンアップ

tarファイルの削除

Gentooのインストールおよびリブート完了後、かつインストールがすべてうまくいった場合、ダウンロードしたステージ3のtarファイルを削除できます。このファイルは/ディレクトリにダウンロードされたことを思いだしましょう。

root #rm /stage3-*.tar.bz2*

次にすることは?

ドキュメント

次に何をしますか?どのような選択肢がありますか?どこを探索すればよいでしょう?Gentooには多くの可能性と共にユーザーが存在します。それゆえ多くのドキュメント化された機能を使うことができます(記述量は多くないのですが…)。

Definitely take a look at the next part of the Gentoo Handbook entitled Working with Gentoo which explains how to keep the software up to date, install additional software packages, details on USE flags, the OpenRC init system, etc.

ハンドブック以外では、コミュニティから追加提供されるドキュメントを見つけるために、Gentoo Wikiの他のコーナーを探索したいと思うでしょう。Gentoo Wikiチームは、Documentation topic overviewを提案します。これは、このWikiにある記事のよいセレクションを提供しています。例えば、システムをよりあなたの国に適したものとするためには、ローカライゼーションガイドを参照します。

Gentooオンライン

もちろん、私たちのGentoo forumsや多くのGentoo IRC channelsの一つに参加することはウェルカムです。

すべてのユーザーに問いかけるためにseveral mailing listsもあります。参加のための情報は上記に記載されています。

インストールを楽しみましょう! (^o^)/




Warning: Display title "Gentoo Linux x86 ハンドブック: Gentoo をインストールする" overrides earlier display title "ハンドブック:X86/フル/インストール".