Note

The Funtoo Linux project has transitioned to "Hobby Mode" and this wiki is now read-only.

Install/zh-cn

From Funtoo
Revision as of 06:43, January 7, 2018 by Facility (talk | contribs) (Created page with "==== /etc/conf.d/hwclock ==== 如果你想让 Funtoo Linux 与 Windows 双系统启动,你需要编辑这个文件,把 '''clock''' 的值从 '''UTC''' 改为 '''local'''...")
Jump to navigation Jump to search

Install Funtoo Linux

Other languages:
Deutsch • ‎English • ‎Türkçe • ‎español • ‎français • ‎italiano • ‎polski • ‎português • ‎slovenčina • ‎Ελληνικά • ‎русский • ‎українська • ‎հայերեն • ‎עברית • ‎ไทย • ‎中文(中国大陆)‎ • ‎中文(台灣)‎ • ‎日本語 • ‎한국어
   {{{title}}}
{{{body}}}

介绍

这篇文章指导你如何在 PC 兼容机器上安装 Funtoo Linux 系统,我们将只进行包含基本系统配置的最小化安装。

如果你曾经有过 Gentoo Linux 的安装经验,你会发现很多步骤是相似的。但由于两者安装过程有些许不同,还是建议你通读本文。如果你是第一次安装 Gentoo 系 Linux 发行版,甚至第一次接触 Linux,也没有关系,我们会尽力让安装指南对于纯新手友好。

   Note

如果你在 ARM 架构的机器上安装 Funtoo Linux,请阅读 Funtoo Linux Installation on ARM 这篇文章,以了解不同之处。

安装步骤

下面介绍Funtoo Linux安装的基本步骤:

  1. 准备 Live CD
  2. 准备硬盘
  3. 创建挂载 文件系统
  4. 安装 Stage 3 文件包
  5. Chroot 进入新系统
  6. 下载 Portage 源码树
  7. 系统配置网络配置
  8. 安装 Linux 内核
  9. 安装系统引导程序
  10. 最后扫尾工作
  11. 重启系统

Live CD

为了安装 Funtoo Linux,你首先要使用一个基于 Linux 的 Live CD 或者 USB 介质启动电脑。我们推荐你使用 Gentoo 系的 System Rescue CD,因为它包含大量的工具,并且同时支持32位和64位的系统,你可以将它烧录在 CD/DVD 或者 USB 介质中,从这里下载它的 ISO 镜像文件:

   Important

无显示: System Rescue CD 以 UEFIgig方式启动时可能无法正确初始化显卡。 (请查阅 FL-2030.) 如果碰到此问题,请在System Rescue CD启动 GRUB 菜单时, 输入 e编辑 GRUB 启动行并添加insmod all_video 然后再启动系统。这个问题已经提交到System Rescue CD 的开发者。

   Note

如果使用老一些 版本 System Rescue CD进行启动, 在你打算安装64位g系统时,一定要在启动菜单选择rescue64 内核进行启动。默认情况下, System Rescue CD 以32位模式启动,并且能够自动识别64位CPU。

连接网络

如果已经成功启动System Rescue CD,请确认是否连接到Internet,因为安装 Funtoo Linux需要互联网:

root # ping www.google.com
PING www.google.com (216.58.217.36) 56(84) bytes of data.
64 bytes from den03s10-in-f4.1e100.net (216.58.217.36): icmp_seq=1 ttl=57 time=30.1 ms

如果能够ping通外网 (检查64 bytes 信息,) 表示网络连接正常。 输入 Control-C停止ping程序。

如果以WiFi方式连接互联网,System Rescue CD 必须要运行图形界面。可以运行 startx 命令来启动图形界面:

root # startx
caption

接下来,用 NetworkManager软件连接WIFI网络。 (软件图表在图形界面的任务栏的右下方) 然后,在图形界面下运行终端程序,确认电脑已经连接到互联网。

远程安装

当然,也可以通过网络以SSH远程登录到System Rescue CD 的系统进行安装操作。

如果你采取远程登录System Rescue CD 方式进行安装,先要确认系统已经联网,然后还需要给System Rescue CD设置一个root密码:

root # passwd
New password: ********
Retype new password: ********
passwd: password updated successfully

设定完root密码后,还要知道System Rescue CD的当前IP地址。然后就可以通过 ssh 连接了。可以在System Rescue CD的终端上输入 ifconfig来获取需要连接的IP地址:

root # ifconfig

可以从某个本地LAN口上看到(包含字段 inet addr:) IP地址信息。该地址就是你通过远程主机连接到 System Rescue CD的IP地址。 例如,你可以通过你现有的Linux 或者MacOS等系统连接System Rescue CD的这样格式的1.2.3.4 IP地址:

(remote system) $ ssh root@1.2.3.4
Password: **********
   Note

如果用Microsoft Windows系统来进行远程操作,则需要另外的SSH 客户端,如果没有可以通过 PuTTY

下载。

在通过SSH远程登录 System Rescue CD 系统后,即可执行下一步安装操作。

准备硬盘分区

在本段,我们将了解Funtoo Linux系统如何从硬盘启动。"启动",意思是在当打开电脑的电源开关后(比如桌面电脑,笔记本,服务器),进入Linux系统的过程。也可以理解为“启动”类似处理器先启动内置的固件,然后查找Linux内核再运行它,并由Linux内核识别系统硬件和启动这些硬件。

背景知识

   Note

作为Linux新手,可以忽略下面这段,选择哪一个?

以前, PC机只有一种启动模式。包括所有的个人电脑,服务器的启动固件都是 "PC BIOS,"并且所有的硬盘的主引导记录(MBR) 都位于硬盘的起始位置,PC BIOS 负责在主引导记录上读取分区信息,并查找和装载启动代码,并以此来启动Linux系统。

后来,又出现了新式系统引导固件 EFI (可扩展固件接口) 和 UEFI (统一可扩展固件接口),以及能够定义大于 2.2TB 容量的硬盘分区的 GPT 分区表。忽然之间,我们有了各种引导 Linux 系统的方式可以选择,之前的一招鲜吃遍天变得更加复杂了。

在这里我们先花点时间看看配置你的硬盘引导 Linux 又哪些方法可以选择。这份安装向导使用且通常推荐你使用老式的 BIOS 引导和 MBR 分区表。它们被几乎所有的硬件设备所支持。这种引导方式不会出问题。只要你的硬盘小于 2TB,它也不会妨碍你使用全部的硬盘空间。

然而,有时候老式办法不是最好的选择,如果你的硬盘容量大于 2TB,MBR 分区会阻碍你使用全部的硬盘空间。除此之外,有一些称作 “PC” 的系统不再支持 BIOS 启动,必须使用 UEFI ,所以这份安装指南也记载了如何用 UEFI 引导。

只要你没有特别的理由,我们都推荐你使用老式引导。这里我们用 GRUB 引导 Linux 内核,所以我们称这个方法为 BISOS + GRUB (MBR) 引导。这是在 PC 兼容平台上设置引导 Linux 的传统办法。

如果你需要用 UEFI 引导,我们不推荐使用 MBR 分区表,因为有些 UEFI 系统支持这个,有些不支持。我们推荐用 UEFI 引导 GRUB,由 GRUB 引导 Linux。我们称之为 UEFI + GRUB (GPT) 方法。

是的,还有更多的方法在 启动方法 页面。我们曾经推荐 BISO + GRUB(GPT) 但是这个并不被多少设备支持。

用哪种?

问题是——选哪种呢? 下面就是答案

原则1——旧式引导:如果你能正常启动 System Rescue CD 并且它显示一个蓝色的初始菜单,就说明你是用 BIOS 启动的,以及你应该也能用 BISO 引导 Funtoo。所以,除非你有特殊原因需要用 UEFI,比如有大于 2.2TB 的硬盘,这时你要参考原则2来确认你的设备支持 UEFI。反之则使用 BIOS 引导。
原则2——新式引导:如果你能正常启动 System Rescue CD 并且显示黑白的启动菜单——恭喜,你的系统支持 UEFI 引导。可能你的系统也同时支持 BIOS,但是请先试 UEFI。你也可以花点时间研究研究配置
   Note

高级用户可能想到: 旧式和新式之间有什么明显差别?: 如果你使用老式的MBR分区,你的/boot分区将是ext2文件系统,并且你需要使用fdisk新建分区。如果你使用新式GPT分区和UEFI启动,你的/boot 分区将使用vfat文件系统,因为vfat是UEFI所能读取的,你将使用gdisk创建分区。GRUB的安装过程将稍微不同。这就是接下来可能会涉及到的内容,满足你的好奇心。

要通过新式的UEFI方式安装Funtoo Linux,你必须让System Rescue CD以UEFI方式启动。如果你成功在UEFI下启动sysresccd,你将看到一个黑白界面让你选择启动rescue cd的模式。或者你将看到带有黑色文本的蓝屏,将不能以UEFI启动,你也不能在安装过程中设置UEFI启动

   Note

有些主板貌似支持UEFI但请不要使用例如我的Gigabyte GA-990FXA-UD7 rev 1.1的Award BIOS可以启用让CD/DVD以UEFI启动。但并不能让硬盘以UEFI启动并安装Funtoo Linux。UEFI必须同时支持可移动介质(所以你可以以UEFI启动System Rescue CD)以及固定介质(这样你才能启动Funtoo Linux开始安装)。该BIOS的新版(rev 3.0)完全支持UEFI。这指出了第三个要点——了解你的硬件

老式(BIOS/MBR)方法

   Note

如果System Rescue CD启动后菜单是浅蓝色则应该使用BIOS启动。如果你想使用新式方法, 点击此处跳转。

首先,你需要找到正确的磁盘分区。尝试此命令验证/dev/sda是要分区的磁盘

root # fdisk -l /dev/sda

Disk /dev/sda: 640.1 GB, 640135028736 bytes, 1250263728 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: gpt

root #         Start          End    Size  Type            Name
 1         2048   1250263694  596.2G  Linux filesyste Linux filesystem

现在,建议你删除一切现有磁盘上的MBR或者GPT分区表防止混淆。我们将使用sgdisk完成此操作:

   Warning

这将使现有分区不可访问,建议事先备份。

root # sgdisk --zap-all /dev/sda

Creating new GPT entries.
GPT data structures destroyed! You may now partition the disk using fdisk or
other utilities.

如果输出这样的结果,不必担心,命令已有效运行

***************************************************************
Found invalid GPT and valid MBR; converting MBR to GPT format
in memory. 
***************************************************************

现在我们将使用fdisk 创建MBR分区表和分区:

root # fdisk /dev/sda

fdisk下按照以下步骤操作:

清除分区表::

Command (m for help): o ↵

创建第一个分区: (boot):

Command (m for help): n ↵
Partition type (default p): 
Partition number (1-4, default 1): 
First sector: 
Last sector: +128M ↵

创建第二个分区: (swap):

Command (m for help): n ↵
Partition type (default p): 
Partition number (2-4, default 2): 
First sector: 
Last sector: +2G ↵
Command (m for help): t ↵ 
Partition number (1,2, default 2): 
Hex code (type L to list all codes): 82 ↵

创建根目录分区:

Command (m for help): n ↵
Partition type (default p): 
Partition number (3,4, default 3): 
First sector: 
Last sector: 

验证分区表:

Command (m for help): p

Disk /dev/sda: 298.1 GiB, 320072933376 bytes, 625142448 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x82abc9a6

Device    Boot     Start       End    Blocks  Id System
/dev/sda1           2048    264191    131072  83 Linux
/dev/sda2         264192   4458495   2097152  82 Linux swap / Solaris
/dev/sda3        4458496 625142447 310341976  83 Linux

将分区表写入磁盘:

Command (m for help): w

您的新MBR分区表已被写入你的系统磁盘。

   Note

你现在已经完成了分区!现在,跳转至 创建文件系统

新式(UEFI/GPT)方法

   Note

如果你想用 UEFI 启动,且 System Rescue CD 的启动介面是黑白的,则可以用该方式。如启动介面是蓝色,则该方式不会生效。

gdisk 命令可以用来创建一个 GPT 格式的分区。调整一个适合你自己的分区大小也是有必要的,但是对于新手来说,默认的分区设置就能够满足需求。运行 gdisk :

root # gdisk /dev/sda

gdisk 中,按照以下步骤来操作:

Create a new empty partition table (This will erase all data on the disk when saved):

Command: o ↵
This option deletes all partitions and creates a new protective MBR.
Proceed? (Y/N): y ↵

创建第一个分区(boot):

Command: n ↵
Partition Number: 1 ↵
First sector: 
Last sector: +500M ↵
Hex Code: EF00 ↵

创建第二个分区(swap):

Command: n ↵
Partition Number: 2 ↵
First sector: 
Last sector: +4G ↵
Hex Code: 8200 ↵

创建第三个分区(root):

Command: n ↵
Partition Number: 3 ↵
First sector: 
Last sector:  (for rest of disk)
Hex Code: 

在安装的整个过程当中,您可以敲入 "p" 然后点击回车键来查看当前的分区表。如果犯了错误,您可以通过命令 "d" 来删除一个您建立的分区。当对分区满意时,使用 "w" 来将改动写入磁盘:

将分区表写入磁盘

Command: w ↵
Do you want to proceed? (Y/N): Y ↵

分区表现在就将被写入磁盘,gdisk 也会关闭。

现在,你就创建了 GPT/GUID 分区,并且会在 Linux 中以 block devices 出现

  • /dev/sda1,被分配给 /boot 分区,
  • /dev/sda2,将被用作交换空间,并且
  • /dev/sda3,将被分配给 root 分区。
   Tip

你可以通过运行 lsblk 命令来验证你正确地创建了块设备

Creating filesystems

   Note

这个部分讲解了关于 BIOS UEFI 的安装,一定不能跳过!

在将你新建立的分区投入使用之前,在前面的步骤中创建的块设备需要用 metadata 文件系统来初始化。这个步骤被称为在块设备上创建文件系统。在快设备上创建了文件系统之后,你就可以挂载他们并且用他们来储存文件。

简单来说,你还在使用旧式的 MBR 分区吗?如果是这样,就让我们在 /dev/sda1 上创建一个 ext2 文件系统。

root # mkfs.ext2 /dev/sda1

如果你在为 UEFI 而使用新式的 GPT 分区,你需要在 /dev/sda1 创建一个 vfat 格式的分区,因为这是 UEFI 启动所必须的。

root # mkfs.vfat -F 32 /dev/sda1

好了,现在让我们创建一个交换分区。这个分区将被用作 Funtoo 上基于硬盘的虚拟内存空间。

因为交换分区不是用来存储文件的,所以在交换分区上,你将不会创建一个文件系统。但是你需要使用 mkswap 来将他初始化。由于之后的安装过程中我们需要交换分区,所以我们要运行 swapon 命令来将交换分区立即在 Live CD 的环境中投入使用。

root # mkswap /dev/sda2
root # swapon /dev/sda2

现在,我们需要创建一个 root 文件系统。这是 Funtoo 要安家的地方。我们一般推荐使用 ext4 和 XFS 作为 root 分区的文件系统。如果你不能确定要使用哪一个,那就使用 ext4 吧。下面展示了如何创建一个 ext4 文件系统:

root # mkfs.ext4 /dev/sda3

...现在,如果比起 ext4 你更喜欢使用 XFS 文件系统,那就到了创建 XFS root 文件系统的部分:

root # mkfs.xfs /dev/sda3

你的文件系统(包括交换分区)现在已经被初始化了,这样就可以被挂载了(附加到现有的目录层次结构中)并且用来存储文件。现在,我们已经准备好在崭新的分区上安装 Funtoo。

   Warning

当在部署一个 OpenVZ 架构的宿主机时,请仅使用 ext4 文件系统。Parallels 开发者团队广泛地对 ext4 和 openvz-rhel6-stable 的现代版本进行了测试,发现前两者与 XFS 兼容,并且你可能会遇到内核的错误。

挂载文件系统

按照如下的步骤挂载新创建的文件系统,创建 /mnt/funtoo 作为安装的挂载点。

root # mkdir /mnt/funtoo
root # mount /dev/sda3 /mnt/funtoo
root # mkdir /mnt/funtoo/boot
root # mount /dev/sda1 /mnt/funtoo/boot

可选:在你有一个独立的分区,例如 /home 或者其他时:

root # mkdir /mnt/funtoo/home
root # mount /dev/sda4 /mnt/funtoo/home

如果你打算将 /tmp 或者 /var/tmp 放置在独立的文件系统中,要确保在挂在后将挂载点的权限修改为全局可写,如下:

root # chmod 1777 /mnt/funtoo/tmp

设置日期

   Important

如果你的系统上的时间与实际的时间相差太远(特别是几月甚至是几年,)那么有可能会导致 Protage 无法正确的通过 https 下载源码包。原因是有一些源码会包会通过 https 下载,而 SSL 证书是具有一个完整的激活和过期时间的。但是,如果你的系统时间与正确的时间相差不多,目前是可以跳过这段的。

显示要验证日期和时间被正确的设定为 UTC 格式。使用 date 命令来校验日期和时间。

root # date
Fri Jul 15 19:47:18 UTC 2011

如果需要矫正日期和/或时间,那么可以使用 date MMDDhhmmYYYY 命令,一定要记住 hhmm 是 24 小时的格式。下面的例子展示了吧时间修改为 ”UTC 格式的

2011 年 7 月 16 日,下午 8:00“
root # date 071620002011
Fri Jul 16 20:00:00 UTC 2011

系统时间设置完成之后,将时间同步到机器的硬件时钟上是一个好主意,这样就能保证在重启之后时间维持不变。

root # hwclock --systohc

安装 Stage 3 压缩包

现在我们已经完成了创建分区以及设置系统时间这两个步骤,下一步便是下载 Stage 3 压缩包。Stage 3 压缩包是一个预编译的,可以作为安装 Funtoo Linux 的出发点的系统。

请移步至 Subarches 来为你的系统下载最新版本的 Funtoo Linux。其他平台的分支(例如 arm 等)是为了让 Funtoo Linux 能在某一特定的 CPU 平台上有最好的表现而设计的。它们也对于每个 CPU 的指令集有不同的优势。

The Subarches page lists all CPU-optimized versions of Funtoo Linux. Find the one that is appropriate for the type of CPU that your system has, and then click on its name in the first column (such as corei7, for example.) You will then go to a page dedicated to that subarch, and the available stage3's available for download will be listed. If you are using a virtualization technology to run Funtoo Linux, and your VM may migrate to different types of hardware, then it's recommended that you use a stage3 that is optimized for the oldest CPU instruction set that your VM will run on, or a generic image if it may run on both AMD and Intel processors.

For most subarches, you will have several stage3's available to choose from. This next section will help you understand which one to pick.

哪个版本?

如果你不确定,就选择 funtoo-current

Funtoo Linux 有很多不同的 '版本':

BuildDescription
funtoo-currentThe most commonly-selected build of Funtoo Linux. Receives rapid updates and preferred by desktop users.
funtoo-stableEmphasizes less-frequent package updates and trusted, reliable versions of packages over the latest versions.

Which Variant?

如果你不确定,就选择 standard

我们通常说的 stage3

是由 standard 的许多变种组成的,列表如下:
VariantDescription
standardThe "standard" version of Funtoo Linux
pure64A 64-bit build that drops multilib (32-bit compatibility) support. Can be ideal for server systems.
hardenedIncludes PIE/SSP toolchain for enhanced security. PIE does require the use of PaX in the kernel, while SSP works with any kernel, and provides enhanced security in user-space to avoid stack-based exploits. For expert users.

下载 Stage3

找到了你心仪的 stage3 之后,就可以着手下载了,使用 wget 命令来下载你选择的,将要作为基础系统的压缩包。它应当被保存在 /mnt/funtoo ,如下所示:

root # cd /mnt/funtoo
root # wget http://build.funtoo.org/funtoo-current/x86-64bit/generic_64/stage3-latest.tar.xz

注意:64 位的系统可以运行 32 位或是 64 位的 stage,但是 32 位的系统只能运行 32 位的 stage。一定要确保你选择了适合你的 CPU 的 Stage 3 版本。如果你不确定,可以毫无顾虑地选择 generic_64 或者是 generic_32 stage。参阅 Subarches 页面来获得更多信息。

Stage 文件下载完成之后,使用下列的命令来解压文件,记住需要用你下载的 stage3 文件的名字来替换命令中文件的名字:

root # tar xpf stage3-latest.tar.xz
   Important

在解压 Stage3 压缩包时,使用 tar 的 "p" 选项是很重要的,这将对 tar 声明要 保留 在压缩文件中所有的权限和所有权。若没有指明这个选项,你的 Funtoo Linux 的文件系统的权限有可能会变得不正确。

chroot 进入 Funtoo

我们需要先使用 chroot 才能安装 Funtoo。chroot 命令将 切换至 新的 Funtoo Linux 系统中,所以接下来你运行的命令都将在你新解压出的 Funtoo Linux 系统中运行。

在转换 root 环境之前,我们还需要做一些工作来将 chroot 的环境完善。你需要将 /proc, /sys and /dev 挂载到你的新系统中。可以使用下述指令:

root # cd /mnt/funtoo
root # mount -t proc none proc
root # mount --rbind /sys sys
root # mount --rbind /dev dev

你也需要复制一份 resolv.conf 到新的 chroot 环境中,来获得对域名的正确解析:

root # cp /etc/resolv.conf /mnt/funtoo/etc/

现在就可以 chroot 进入你新的系统中了,注意需要先执行 env 再执行 chroot

来确保安装介质中的环境变量不会进入你的新系统。
root # env -i HOME=/root TERM=$TERM chroot . bash -l
   Note

For users of live CDs with 64-bit kernels installing 32-bit systems: Some software may use uname -r to check whether the system is 32 or 64-bit. You may want append linux32 to the chroot command as a workaround, but it's generally not needed.

   Important

If you receive the error "chroot: failed to run command `/bin/bash': Exec format error", it is most likely because you are running a 32-bit kernel and trying to execute 64-bit code. Make sure that you have selected the proper type of kernel when booting SystemRescueCD.

在 chroot 环境下对默认的命令提示做一下改动也是一个好主意。这可以在你切换终端/终端模拟器时不至于搞混。使用下述指令:

root # export PS1="(chroot) $PS1"

在 chroot 环境下测试域名解析:

root # ping -c 5 google.com

如果你不能 ping 通,检查 /etc/resolv.conf,看看其中是否有 127.0.x.x 的行,如果有上述的行,那就把 127.0.x.x 改为 8.8.8.8 -- Google 的公共 DNS 服务器地址。在系统安装后,确保时用这个来替换掉 DNS 服务器地址。


乌拉!你现在已经 chroot 进入了一个新的 Funtoo Linux 系统中。是时候正确地配置 Funtoo Linux ,以便在没有任何手动设置的情况下,让它能正确的重启并且运行。

   Note

参考 Installing Portage From Snapshot 来了解做这件工作的另一种方式。

是时候安装一份 Portage 仓库的拷贝了,这其中包含了包脚本(ebuilds),即向 Portage 声明如何安装成千上万的软件包。只要在

chroot 环境下执行一句简单的指令 emerge --sync 就能创建 Portage 仓库。这个指令会自动地从  GitHub clone 一份 Portage tree 到本地:
(chroot) # emerge --sync
   Important

如果你在初始化 emerge --sync 时遇到了由于 git 协议的限制引起的错误,就在 /etc/portage/make.conf 中将 SYNC 变量设置为 "https://github.com/funtoo/ports-2012.git"

配置系统

正如对任何一个 Linux 发行版期盼的那样,Funtoo Linux 有它自己的一份配置文件。这份文件是 /etc/fstab 需要你的编辑它来确保 Funtoo Linux 来正确启动。其他的都是可选的。

使用 Nano

chroot 环境下包含的默认文本编辑器被称为 nano。若要编辑下列文本之一,可以按照下述方法使用 Nano:

(chroot) # nano /etc/fstab

在编辑器中时,可以使用方向键移动光标,并且退格和删除这一类的按键都会像往常一样工作。可以按 Control-X 并且 用 y 来回答是否将改动保存到文件的提示来保存文件。

配置文件

Here are a full list of files that you may want to edit, depending on your needs:

FileDo I need to change it?Description
/etc/fstab YES - required Mount points for all filesystems to be used at boot time. This file must reflect your disk partition setup. We'll guide you through modifying this file below.
/etc/localtime Maybe - recommended Your timezone, which will default to UTC if not set. This should be a symbolic link to something located under /usr/share/zoneinfo (e.g. /usr/share/zoneinfo/America/Montreal)
/etc/make.conf (symlink) - also known as:
/etc/portage/make.conf
Maybe - recommended Parameters used by gcc (compiler), portage, and make. It's a good idea to set MAKEOPTS. This is covered later in this document. Note that it is normal for this file to be empty in Funtoo Linux, as many settings have been migrated to our enhanced profile system.
/etc/conf.d/hostname Maybe - recommended Used to set system hostname. Set the hostname variable to the fully-qualified (with dots, ie. foo.funtoo.org) name if you have one. Otherwise, set to the local system hostname (without dots, ie. foo). Defaults to localhost if not set.
/etc/hosts No You no longer need to manually set the hostname in this file. This file is automatically generated by /etc/init.d/hostname.
/etc/conf.d/keymaps Optional Keyboard mapping configuration file (for console pseudo-terminals). Set if you have a non-US keyboard. See Funtoo Linux Localization.
/etc/conf.d/hwclock Optional How the time of the battery-backed hardware clock of the system is interpreted (UTC or local time). Linux uses the battery-backed hardware clock to initialize the system clock when the system is booted.
/etc/conf.d/modules Optional Kernel modules to load automatically at system startup. Typically not required. See Additional Kernel Resources for more info.
/etc/conf.d/consolefont Optional Allows you to specify the default console font. To apply this font, enable the consolefont service by running rc-update add consolefont.
profiles Optional Some useful portage settings that may help speed up intial configuration.

如果你正在安装一个英文版的 Funtoo Linux,那就可以按照原样使用大部分的配置文件。如果你在安装其他语言的版本,不必担心,我们在 Funtoo Linux Localization 页面上写出了必要的准备步骤。如有需要,还有许多友好的帮助在等着你(请参考这个 Community)。

让我们继续安装,看看还有什么需要做的。使用 nano -w <name_of_file> 来编辑文件-- "-w" 指令会禁用自动换行,这样让编辑配置配置文件更顺手。你可以从示例文件中复制粘贴。

   Warning

It's important to edit your /etc/fstab file before you reboot! You will need to modify both the "fs" and "type" columns to match the settings for your partitions and filesystems that you created with gdisk or fdisk. Skipping this step may prevent Funtoo Linux from booting successfully.

/etc/fstab

/etc/fstab 在系统启动时会被 mount 读取。这个文件中的每一行都会向 mount 声明需要挂载哪些文件系统以及如何挂载他们。为了让系统正常启动,你需要编辑 /etc/fstab 并且确保其中的配置与之前安装步骤中你对分区的修改一致,lsblk 会让这件事更容易:

(chroot) # nano -w /etc/fstab
   /etc/fstab - An example fstab file
# The root filesystem should have a pass number of either 0 or 1.
# All other filesystems should have a pass number of 0 or greater than 1.
#
# NOTE: If your BOOT partition is ReiserFS, add the notail option to opts.
#
# See the manpage fstab(5) for more information.
#
# <fs>	     <mountpoint>  <type>  <opts>         <dump/pass>

/dev/sda1    /boot         ext2    noauto,noatime 1 2
/dev/sda2    none          swap    sw             0 0
/dev/sda3    /             ext4    noatime        0 1
#/dev/cdrom  /mnt/cdrom    auto    noauto,ro      0 0
   Note

Currently, our default /etc/fstabfile has the root filesystem as /dev/sda4 and the swap partition as /dev/sda3. These will need to be changed to /dev/sda3 and /dev/sda2, respectively.

   Note

If you're using UEFI to boot, change the /dev/sda1 line so that it says vfat instead of ext2. Similarly, make sure that the /dev/sda3 line specifies either xfs or ext4, depending on which filesystem you chose earlier on in the installation process when you created filesystems.

/etc/localtime

/etc/localtime 用来明确你的机器处于哪个时区,默认是 UTC。如果想让 Funtoo Linux 系统使用当地时间,你需要将 {{|/etc/localtime}} 用一个符号链接指向你想要使用的时区。

(chroot) # ln -sf /usr/share/zoneinfo/MST7MDT /etc/localtime

The above sets the timezone to Mountain Standard Time (with daylight savings). Type ls /usr/share/zoneinfo to list available timezones. There are also sub-directories containing timezones described by location.

/etc/portage/make.conf

MAKEOPTS 可以用来指定在编译安装包时创建多少个并行的线程,这样可以显著地加速编译完成的速度。按照经验来讲,将 MAKEOPTS 设置为 CUP 数量的值(或 CPU 线程的值)+ 1 时比较好的。举个例子:如果你有一个不包含 hyper-threading 的双核CPU,你可以将 MAKEOPTS 设置为 3:

MAKEOPTS="-j3" 

如果你不确定你有多少个 核心/线程,可以用 命令nproc 查看

(chroot) # nproc
16

MAKEOPTS 设置为上面的数字加上一之后的值:

MAKEOPTS="-j17"

USE 字段指定了在软件包包安装时所启用的功能。在安装的过程中我们不推荐向 USE 标志中加入很多字段;在改变 USE 选项之前,你需要确定你有一个能正常启动、工作的系统。一个前面写着负号 ("-") 的 USE 标志会向 Portage 声明在编译时不要使用该选项。在不久的将来,会有一篇专门介绍 USE 的 Funtoo 指导手册。现在,你可以参考 Gentoo Handbook 来获得关于 USE 的更多信息。

LINGUAS 向 Portage 声明要将系统和应用 (就像使用 LINGUAS 作为环境变量的 OpenOffice) 编译为某个特定的语言。一般在使用英文的情况下是不需要这样做的。如果你需要另一种像法语(French,fr)或是德语(German,de)这样的语言,那需要合适地设置 LINGUAS:

LINGUAS="fr"

/etc/conf.d/hwclock

如果你想让 Funtoo Linux 与 Windows 双系统启动,你需要编辑这个文件,把 clock 的值从 UTC 改为 local,原因是 Windows 在每次启动时都会将硬件时钟设置为本地时钟。其他一般的情况下,是不需要编辑这个文件的。

(chroot) # nano -w /etc/conf.d/hwclock

本地化

By default, Funtoo Linux is configured with Unicode (UTF-8) enabled, and for the US English locale and keyboard. If you would like to configure your system to use a non-English locale or keyboard, see Funtoo Linux Localization.

Portage 简介

Portage, the Funtoo Linux package manager has a command called emerge which is used to build and install packages from source. It also takes care of installing all of the package's dependencies. You call emerge like this:

(chroot) # emerge packagename

When you install a package by specifying its name in the command-line, Portage records its name in the /var/lib/portage/world file. It does so because it assumes that, since you have installed it by name, you want to consider it part of your system and want to keep the package updated in the future. This is a handy feature, since when packages are being added to the world set, we can update our entire system by typing:

(chroot) # emerge --sync
(chroot) # emerge -auDN @world

This is the "official" way to update your Funtoo Linux system. Above, we first update our Portage tree using git to grab the latest ebuilds (scripts), and then run an emerge command to update the world set of packages. The options specified tell emerge to:

  • a - show us what will be emerged, and ask us if we want to proceed
  • u - update the packages we specify -- don't emerge them again if they are already emerged.
  • D - Consider the entire dependency tree of packages when looking for updates. In other words, do a deep update.
  • N - Update any packages that have changed (new) USE settings.

You should also consider passing --with-bdeps=y when emerging @world, at least once in a while. This will update build dependencies as well.

Of course, sometimes we want to install a package but not add it to the world file. This is often done because you only want the package installed temporarily or because you know the package in question is a dependnecy of another package. If this behavior is desired, you call emerge like this:

(chroot) # emerge -1 packagename

Advanced users may be interested in the Emerge wiki page.

Updating World

Now is actually a very good time to update the entire system and it can be a good idea to do so prior to first boot.

(chroot) # emerge --sync
(chroot) # emerge -auDN @world
   Important

Make sure you read any post emerge messages and follow their instructions. This is especially true if you have upgraded perl or python.

Kernel

Starting mid-May 2015, Funtoo Linux stage3's include a pre-built debian-sources kernel to make installation faster and easier. To see if debian-sources is installed, type:

(chroot) # emerge -s debian-sources
Searching...    
[ Results for search key : debian-sources ]
[ Applications found : 1 ]

*  sys-kernel/debian-sources
      Latest version available: 3.19.3
      Latest version installed: 3.19.3
      Size of files: 81,292 kB
      Homepage:      http://www.debian.org
      Description:   Debian Sources (and optional binary kernel)
      License:       GPL-2

If a version is listed under Latest version installed, then debian-sources is already pre-built for you and you can skip the rest of the Kernel section, and proceed to the Installing a Bootloader section.

Building the Kernel

If you need to build a kernel for Funtoo Linux, please follow these steps:

   Note

See Funtoo Linux Kernels for a full list of kernels supported in Funtoo Linux. We recommend debian-sources for new users.

   Important

debian-sources with binary USE flag requires at least 14GB free in /var/tmp and takes around 1 hour to build on a Intel Core i7 Processor.

Let's emerge our kernel:

(chroot) # emerge debian-sources

Once emerge completes, you'll have a brand new kernel and initramfs installed to /boot, plus kernel headers installed in /usr/src/linux, and you'll be ready to configure the boot loader to load these to boot your Funtoo Linux system.

   Warning

If you have a RAID in your machine, the kernel installation will pull in the mdadm tool as a dependency. It is important to edit the /etc/mdadm.conf file prior to rebooting the machine so the RAID is properly recognised and set up before the kernel attempts to mount it in the tree. Failing to do so can result in an unusable or even unbootable system! For specific details, consult the mdadm man page man mdadm or the mdadm ebuild page.

   Note

NVIDIA card users: the binary USE flag installs the Nouveau drivers which cannot be loaded at the same time as the proprietary drivers, and cannot be unloaded at runtime because of KMS. You need to blacklist it under /etc/modprobe.d/.

   Note

For an overview of other kernel options for Funtoo Linux, see Funtoo Linux Kernels. There may be modules that the Debian kernel doesn't include, a situation where genkernel would be useful. Also be sure to see hardware compatibility information.

安装一个启动引导器

These install instructions show you how to use GRUB to boot using BIOS (old-school) or UEFI (new-school). As of boot-update-1.7.2, now in Portage, the steps are very similar.

First, emerge boot-update. This will also cause grub-2 and efibootmgr to be merged, since they are dependencies:

(chroot) # emerge boot-update

Then, edit /etc/boot.conf using nano and specify "Funtoo Linux genkernel" as the default setting at the top of the file, replacing "Funtoo Linux".

/etc/boot.conf should now look like this:

   /etc/boot.conf
boot {
	generate grub
	default "Funtoo Linux genkernel" 
	timeout 3 
}

"Funtoo Linux" {
	kernel bzImage[-v]
}

"Funtoo Linux genkernel" {
	kernel kernel[-v]
	initrd initramfs[-v]
	params += real_root=auto 
} 

"Funtoo Linux better-initramfs" {
	kernel vmlinuz[-v]
	initrd /initramfs.cpio.gz
}

If you are booting a custom or non-default kernel, please read man boot.conf for information on the various options available to you.

旧式的 (BIOS) MBR

When using "old school" BIOS booting, run the following command to install GRUB to your MBR, and generate the /boot/grub/grub.cfg configuration file that GRUB will use for booting:

(chroot) # grub-install --target=i386-pc --no-floppy /dev/sda
(chroot) # boot-update

新式的 (UEFI)Boot Entry

If you're using "new school" UEFI booting, run of the following sets of commands, depending on whether you are installing a 64-bit or 32-bit system. This will add GRUB as a UEFI boot entry.

对于 x86_64 位系统:

(chroot) # grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id="Funtoo Linux [GRUB]" --recheck /dev/sda
(chroot) # boot-update

对于 x86_32 位系统:

(chroot) # grub-install --target=i386-efi --efi-directory=/boot --bootloader-id="Funtoo Linux [GRUB]" --recheck /dev/sda
(chroot) # boot-update

First Boot, and in the future...

一切就绪--你已准备好启动!

You only need to run grub-install when you first install Funtoo Linux, but you need to re-run boot-update every time you modify your /etc/boot.conf file or add new kernels to your system. This will regenerate /boot/grub/grub.cfg so that you will have new kernels available in your GRUB boot menu, the next time you reboot.

网络配置

It's important to ensure that you will be able to connect to your local-area network after you reboot into Funtoo Linux. There are three approaches you can use for configuring your network: NetworkManager, dhcpcd, and the Funtoo Linux Networking scripts. Here's how to choose which one to use based on the type of network you want to set up.

Wi-Fi 配置

For laptop/mobile systems where you will be using Wi-Fi, roaming, and connecting to various networks NetworkManager is strongly recommended. Since Wi-Fi cards require firmware to operate, it is also recommended that you emerge the linux-firmware ebuild:

(chroot) # emerge linux-firmware networkmanager
(chroot) # rc-update add NetworkManager default

The above command will ensure that NetworkManager starts after you boot into Funtoo Linux. Once you've completed these installation steps and have booted into Funtoo Linux, you can use the nmtui command (which has an easy-to-use console-based interface) to configure NetworkManager so that it will connect (and automatically reconnect, after reboot) to a Wi-Fi access point:

root # nmtui

For more information about NetworkManager, see the NetworkManager package page.

   Note

wpa_supplicant is also a good choice for wireless network connections. See the net-wireless/wpa_supplicant package for steps involved in setting up wpa_supplicant.

Desktop (Wired DHCP)

For a home desktop or workstation with wired Ethernet that will use DHCP, the simplest and most effective option to enable network connectivity is to simply add dhcpcd to the default runlevel:

(chroot) # rc-update add dhcpcd default

When you reboot, dhcpcd will run in the background and manage all network interfaces and use DHCP to acquire network addresses from a DHCP server.

If your upstream DHCP server is dnsmasq, it can be configured to assign addresses via mac address to make servers on DHCP feasible.

Server (Static IP)

For servers, the Funtoo Linux Networking scripts are recommended. They are optimized for static configurations and things like virtual ethernet bridging for virtualization setups. See Funtoo Linux Networking for information on how to use Funtoo Linux's template-based network configuration system.

Hostname

By default Funtoo uses "localhost" as hostname. Although the system will work perfectly fine using this name, some ebuilds refuse to install when detecting localhost as hostname. It also may create confusion if several systems use the same hostname. Therefore, it is advised to change it to a more meaningful name. The hostname itself is arbitrary, meaning you can choose almost any combination of characters, as long as it makes sense to the system administrator. To change the hostname, edit

(chroot) # nano /etc/conf.d/hostname

Look for the line starting with hostname and change the entry between the quotes. Save the file, on the next boot Funtoo will use the new hostname.

   Warning

Do not use special characters in the hostname, as the shell may interpret these, leading to unpredictable results. Use the Latin alphabet: a-z, A-Z, 0-9

   Tip

Use short hostnames (up to 8 or 10 characters) to prevent the terminal screen being filled with the hostname, leaving little space for the command itself. This become particularly poignant when coding long command strings in various programming languages like Bash, Python, SQL and Perl

Finishing Steps

Set your root password

It's imperative that you set your root password before rebooting so that you can log in.

(chroot) # passwd

重启系统

Now is the time to leave chroot, to unmount Funtoo Linux partitions and files and to restart your computer. When you restart, the GRUB boot loader will start, load the Linux kernel and initramfs, and your system will begin booting.

Leave the chroot, change directory to /mnt, unmount your Funtoo partitions, and reboot.

(chroot) # exit
root # cd /mnt
root # umount -lR funtoo
root # reboot
   Note

System Rescue CD will gracefully unmount your new Funtoo filesystems as part of its normal shutdown sequence.

You should now see your system reboot, the GRUB boot loader appear for a few seconds, and then see the Linux kernel and initramfs loading. After this, you should see Funtoo Linux itself start to boot, and you should be greeted with a login: prompt. Funtoo Linux has been successfully installed!

Profiles

Once you have rebooted into Funtoo Linux, you can further customize your system to your needs by using Funtoo Profiles. A quick introduction to profiles is included below -- consult the Funtoo Profiles page for more detailed information. There are five basic profile types: arch, build, subarch, flavors and mix-ins:

Sub-Profile TypeDescription
archTypically x86-32bit or x86-64bit, this defines the processor type and support of your system. This is defined when your stage was built and should not be changed.
buildDefines whether your system is a current, stable or experimental build. current systems will have newer packages unmasked than stable systems. This is defined when your stage is built and is typically not changed.
subarchDefines CPU optimizations for your system. The subarch is set at the time the stage3 is built, but can be changed later to better settings if necessary. Be sure to pick a setting that is compatible with your CPU.
flavorDefines the general type of system, such as server or desktop, and will set default USE flags appropriate for your needs.
mix-insDefines various optional settings that you may be interested in enabling.

One arch, build and flavor must be set for each Funtoo Linux system, while mix-ins are optional and you can enable more than one if desired. Often, flavors and mix-ins inherit settings from other sub-profiles. Use epro show to view your current profile settings, in addition to any inheritance information:

(chroot) #  epro show

=== Enabled Profiles: ===

        arch:  x86-64bit
       build:  current
     subarch:  intel64-haswell
      flavor:  desktop
     mix-ins:  gnome


=== All inherited flavors from desktop flavor: ===

                     workstation (from desktop flavor)
                            core (from workstation flavor)
                         minimal (from core flavor)

=== All inherited mix-ins from desktop flavor: ===

                               X (from workstation flavor)
                           audio (from workstation flavor)
                             dvd (from workstation flavor)
                           media (from workstation flavor)
      mediadevice-audio-consumer (from media mix-in)
                mediadevice-base (from mediadevice-audio-consumer mix-in)
      mediadevice-video-consumer (from media mix-in)
                mediadevice-base (from mediadevice-video-consumer mix-in)
        mediaformat-audio-common (from media mix-in)
          mediaformat-gfx-common (from media mix-in)
        mediaformat-video-common (from media mix-in)
                  console-extras (from workstation flavor)
                           print (from desktop flavor)

Here are some basic examples of epro usage:

DescriptionCommand
View available profiles. Enabled profiles will be highlighted in cyan. Directly enabled profiles will be in bold and have a * appended.
(chroot) # epro list
Change the system flavor.
(chroot) # epro flavor desktop
Add a mix-in.
(chroot) # epro mix-in +gnome

下一步

If you are brand new to Funtoo Linux and Gentoo Linux, please check out Funtoo Linux First Steps, which will help get you acquainted with your new system. We also have a category for our official documentation, which includes all docs that we officially maintain for installation and operation of Funtoo Linux.

我们也有许多尽全力帮助你安装系统的页面,参考

First Steps 来获得一份列表。

如果你的系统没有正确启动,参考 Installation Troubleshooting 来获得解决问题的方法。