From Gentoo Wiki
Jump to: navigation, search
This page is a translated version of the page Handbook:AMD64/Installation/Base and the translation is 100% complete.

Other languages:
čeština • ‎Deutsch • ‎English • ‎español • ‎français • ‎italiano • ‎日本語 • ‎한국어 • ‎polski • ‎português do Brasil • ‎русский • ‎українська • ‎中文 • ‎中文(中国大陆)‎
AMD64 Handbook
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
Working with Gentoo
Portage introduction
USE flags
Portage features
Initscript system
Environment variables
Working with Portage
Files and directories
Mixing software branches
Additional tools
Custom package repository
Advanced features
Network configuration
Getting started
Advanced configuration
Modular networking
Adding functionality
Dynamic management

chroot する

任意自由選択: ミラーサーバーを選択する



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 /mnt/gentoo/etc/portage/repos.conf


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


FILE /mnt/gentoo/etc/portage/repos.conf/gentoo.conf
location = /usr/portage
sync-type = rsync
sync-uri = rsync://
auto-sync = yes

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.

興味のある人は、PortageプロジェクトのSync articleにあるPlug-in sync APIが役に立つでしょう。

DNS 情報をコピーする



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




  • /proc/ はLinuxカーネルから情報を引き出すための擬似ファイルシステムです(一見通常ファイルに見えますが、ファイルとしての実体はありません)。
  • /sys//proc/同様、擬似ファイルシステムです。/proc/より構造化されており、一度は/proc/を置き換えることを目的としていました。
  • /dev/は通常のファイルシステムです。一部はLinuxのデバイス管理機構(通常はudev)により管理されており、すべてのデバイスファイルを含んでいます。


root #mount -t 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
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 -t tmpfs -o nosuid,nodev,noexec shm /dev/shm

Also ensure that mode 1777 is set

root # chmod 1777 /dev/shm


ようやく、すべてのパーティションが初期化され、ベース環境がインストールされました。chrootを実行して新しいインストール環境に入りましょう。これは、セッションのroot(アクセスできる最も上位レベル)を、現状のインストール環境(インストールCDもしくは他のインストールメディア)から、インストールシステム(つまり初期化されたパーティション)に変更することを意味しています。これが"change root"もしくは"chroot"の意味です。


  1. chrootコマンドによって、最上位ディレクトリを(インストールメディアの)/から(パーティションをマウントしている)/mnt/gentoo/に変更する。
  2. /etc/profileのいくつかの設定をsourceコマンドでリロードする。
  3. chroot環境であることを忘れないようするために、シェルのプロンプトを変更する。
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!

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


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
この作業中、 emerge-webrsync が「/usr/portage/がない」というメッセージを出すかもしれません。これは想定内で、このディレクトリは自動的に作成されます。

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


root #emerge --sync --quiet


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

CODE Portageからのニュース
 * 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.


  • listを指定すると、現在有効なニュースアイテムの概要が表示されます。
  • readを指定すると、そのニュースアイテムを読むことができます。
  • purgeを指定すると、一度購読したニュースを削除することができます。これにより、それらのニュースを二度と目にすることはないでしょう。
root #eselect news list
root #eselect news read


root #man news.eselect




root #eselect profile list
Available profile symlink targets:
  [1]   default/linux/amd64/13.0 *
  [2]   default/linux/amd64/13.0/desktop
  [3]   default/linux/amd64/13.0/desktop/gnome
  [4]   default/linux/amd64/13.0/desktop/kde



root #eselect profile set 2



root #eselect profile list
Available profile symlink targets:
  [1]   default/linux/amd64/13.0 *
  [2]   default/linux/amd64/13.0/desktop
  [3]   default/linux/amd64/13.0/desktop/gnome
  [4]   default/linux/amd64/13.0/desktop/kde
  [5]   default/linux/amd64/13.0/no-multilib

そして、"non-multilib" プロファイルを指定します:

root #eselect profile set 5
root #eselect profile list
Available profile symlink targets:
  [1]   default/linux/amd64/13.0
  [2]   default/linux/amd64/13.0/desktop
  [3]   default/linux/amd64/13.0/desktop/gnome
  [4]   default/linux/amd64/13.0/desktop/kde
  [5]   default/linux/amd64/13.0/no-multilib *



root #eselect profile set default/linux/amd64/13.0/systemd
root #eselect profile list
Available profile symlink targets:
  [10]  default/linux/amd64/13.0/developer
  [11]  default/linux/amd64/13.0/no-multilib
  [12]  default/linux/amd64/13.0/systemd *
  [13]  default/linux/amd64/13.0/x32
  [14]  hardened/linux/amd64

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


この時点で、もし新しいシステムプロファイルを選択した場合は、@world setをアップデートするとよいでしょう。それによりベースシステムが新しいプロファイル向けに再構築されます。

このステップは、そのタイトルにsystemdを含んだプロファイルを選択した場合は必須です。なぜならGentooの公式なステージtarボールはデフォルトのinitシステムとしてOpenRCを使っているためです。なお、他のプロファイルにとってはこれは 任意 です。

root #emerge --ask --update --deep --newuse @world
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.


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).


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).

デフォルトのUSEの設定は、システムによって使用されるGentooプロファイルのmake.defaultsファイルに記述されています。Gentooはプロファイルをサポートするために、(複雑な)継承システムをサポートします。これにより今の段階でUSEの詳細に立ち入る必要はありません。現在有効なUSE設定を知るためのもっとも簡単な方法は、emerge --infoを実行してUSEで始まる行を抜き出すことです。

root #emerge --info | grep ^USE
USE="X acl alsa amd64 berkdb bindist bzip2 cli cracklib crypt cxx dri ..."
上記の例は出力のほとんどを省略しています。実際には、USE 変数のリストはずっとずっと長いものです。


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


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"


FILE /etc/portage/make.confデフォルトのUSEフラグを無視する
USE="-* X acl alsa ..."
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.

Optional: Using systemd as the init system

The remainder of the Gentoo Handbook focuses on OpenRC (the traditional Gentoo init system) as the default init system. If systemd is desired or if the reader will be installing GNOME 3.8 and later (which requires systemd), please consult the systemd article. It contains instructions equivalent to the instructions in the following sections of this Handbook. Specifically, it will walk the reader through various init system commands (systemctl) and systemd-specific services (such as timedatectl, hostnamectl, etc.) needed to establish a working systemd environment.

Certain applications are heavily dependent on the GNOME software ecosystem and subsequently dependent on systemd. Readers who are unsure if the GNOME desktop environment will be used can migrate to a systemd profile later.



root #ls /usr/share/zoneinfo


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



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



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.


root #nano -w /etc/locale.gen

次のロケールの例では、英語(United States)とドイツ語(Germany)を(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
UTF-8 のロケールを少なくとも一つは有効にすることを強く勧めます。おそらくいくつかのアプリケーションはUTF-8を必要とするためです。


root #locale-gen

現在使用可能なすべてのロケールを確認するためには、locale -aを実行してください。


eselect locale listを実行すると、利用可能なターゲットが表示されます。

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)

eselect locale set VALUE を実行することで、適切なロケールを設定することができます。

root #eselect locale set 9


FILE /etc/env.d/02localeシステムのロケールをマニュアル設定する



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