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

ハンドブック:MIPS/インストール/カーネル

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


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

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

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

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

root #emerge --ask sys-kernel/mips-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


設定を準備する

Important
On the Origin 200/2000, Indigo2 Impact (R10000), Octane/Octane2 and O2, a 64-bit kernel is required to boot these systems. For these machines, emerge sys-devel/kgcc64 to create a cross-compiler for building 64-bit kernels.

Many of the systems supported have sample .configs hiding in amongst the kernel source. Not all systems have configs distributed in this way. Those that do, can be configured using the commands mentioned in the table below.

System Configure command
Cobalt Servers make cobalt_defconfig
Indy, Indigo2 (R4k), Challenge S make ip22_defconfig
Origin 200/2000 make ip27_defconfig
Indigo2 Impact (R10k) make ip28_defconfig
O2 make ip32_defconfig

All of the Gentoo installation images provide a kernel config option as part of the image itself, accessible as /proc/config.gz. This may be used in many cases. It is best though if the kernel source matches closely the kernel that is currently running. To extract it, simply run it through zcat as shown below.

root #zcat /proc/config.gz > .config
Important
This kernel config is set up for a netboot image. That is, it will expect to find a root filesystem image somewhere nearby, either as a directory for initramfs, or a loopback device for initrd. When executing make menuconfig, don't forget to go into General Setup and disable the options for initramfs.

設定をカスタマイズする

Once a configuration is found, download it into the kernel source directory, and rename it to .config. From there, run make oldconfig to bring everything up to date according to the instructions above, and customize the configuration before compiling.

root #cd /usr/src/linux
root #cp /path/to/example-config .config
root #make oldconfig

Just press the ENTER (or Return) key at each prompt to accept the defaults for now ...

root #make menuconfig
Important
In the Kernel Hacking section, there is an option named "Are You Using A Cross Compiler?". This tells the kernel Makefiles to prepend "mips-linux-" (or mipsel-linux ... etc) to gcc and as commands when compiling the kernel. This should be turned off, even if cross-compiling. Instead, if a cross-compiler needs to be called, specify the prefix using the CROSS_COMPILE variable as shown in the next section.
Important
There is a known issue with JFS and ALSA on Octane systems where the ALSA fails to work. Given the experimental nature of JFS on MIPS, it is recommended that people avoid using JFS for the time being.

コンパイルおよびインストール

カーネルのコンフィグレーションが完了し、コンパイルとインストールをする時がきました。コンフィグレーションを終了させ、コンパイル作業を開始しましょう:

注意
64 ビットマシンでは、CROSS_COMPILE=mips64-unknown-linux-gnu- (または、リトルエンディアンシステムでは mips64el-... ) を指定することで 64 ビットコンパイラーを使用します。

ネイティブにコンパイルするには:

root #make vmlinux modules modules_install

Cross-compiling on target machine, adjust the mips64-unknown-linux-gnu- accordingly:

root #make vmlinux modules modules_install CROSS_COMPILE=mips64-unknown-linux-gnu-

When compiling on another machine, such as an x86 box, use the following commands to compile the kernel & install modules into a specific directory to be transferred to the target machine.

root #make vmlinux modules CROSS_COMPILE=mips64-unknown-linux-gnu-
root #make modules_install INSTALL_MOD_PATH=/somewhere
Important
When compiling a 64-bit kernel for the Indy, Indigo2 (R4k), Challenge S and O2, use the vmlinux.32 target instead of vmlinux. Otherwise, the machine will not be able to boot. This is to work around the PROM not understanding the ELF64 format.
root #make vmlinux.32
Note
It is possible to enable parallel builds using make -jX with X being the 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.

上記の場合は vmlinux.32 が最終的なカーネルとして生成されます。

カーネルのコンパイルが終了したら、カーネルのイメージを /boot/ にコピーしましょう。

Note
On Cobalt servers, the bootloader will expect to see a compressed kernel image. Remember to gzip -9 the file once it is in /boot/.
root #cp vmlinux /boot/kernel-3.16.5-gentoo

Cobalt サーバー用では、カーネルイメージを圧縮します:

root #gzip -9v /boot/kernel-3.16.5-gentoo


任意自由選択: 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/sda1でしょう。この場合、エントリは次のようになります。

root #nano -w /etc/fstab
FILE /etc/fstab/bootマウントポイントを設定する
/dev/sda1	/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