Difference between revisions of "Install/zh-cn"

From Funtoo
Jump to navigation Jump to search
(Updating to match new version of source page)
 
(50 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<languages/>
<div lang="en" dir="ltr" class="mw-content-ltr">
{{Note|Translators: Thank you for your help! Please use the {{Install|section-by-section guide}} as the basis for your translations. Thanks again!}}
{{DISPLAYTITLE:Funtoo Linux Installation Guide}}
</div>
{{#widget:AddThis}}
{{#widget:AddThis}}
= Install Funtoo Linux =
{{translated_subpage|Install|Introduction}}
__NOTITLE__
{{translated_subpage|Install|Download LiveCD}}
<languages/>
{{translated_subpage|Install|Prepare Disk}}
{{Announce|To help us translate this documentation, {{CreateAccount}}, log in to the wiki. Then go to Actions -> Translate in the menu, or click the "Translate this page" link, above. You will be able to select small parts of the install docs and translate these parts to your native language.}}
{{translated_subpage|Install|MBR Partitioning}}
== 介绍 == 
{{translated_subpage|Install|GPT Partitioning}}
{{translated_subpage|Install|Creating Filesystems}}
{{translated_subpage|Install|Mounting Filesystems}}
{{translated_subpage|Install|Setting the Date}}
{{translated_subpage|Install|Download and Extract Stage3}}
{{translated_subpage|Install|Chroot}}
{{translated_subpage|Install|Download Portage Tree}}
{{translated_subpage|Install|Configuration Files}}
{{translated_subpage|Install|Introducing Portage}}
{{translated_subpage|Install|Kernel}}
{{translated_subpage|Install|Bootloader}}
{{translated_subpage|Install|Network}}
{{translated_subpage|Install|Finishing}}
{{translated_subpage|Install|Profiles}}
{{translated_subpage|Install|Done}}


这篇文章指导你如何在 PC 兼容机器上安装 Funtoo Linux 系统,我们将只进行包含基本系统配置的最小化安装。
[[Category:HOWTO]]
 
[[Category:Install]]
如果你曾经有过 Gentoo Linux 的安装经验,你会发现很多步骤是相似的。但由于两者安装过程有些许不同,还是建议你通读本文。如果你是第一次安装 Gentoo 系 Linux 发行版,甚至第一次接触 Linux,也没有关系,我们会尽力让安装指南对于纯新手友好。
[[Category:Official Documentation]]
 
{{Note|如果你在 [[Funtoo Linux Installation on ARM|ARM]] 架构的机器上安装 Funtoo Linux,请阅读  [[Funtoo Linux Installation on ARM]] 这篇文章,以了解不同之处。}}
 
== 安装步骤 ==
 
下面介绍 Funtoo Linux 安装的基本步骤:
 
# [[#Live CD|准备 Live CD]]
# [[#Prepare Hard Disk|准备硬盘]]
# [[#Creating filesystems|创建]] 并 [[#Mounting filesystems|挂载]] 文件系统
# [[#Installing the Stage 3 tarball|安装 Stage 3 文件包]]
# [[#Chroot into Funtoo|Chroot 进入新系统]]
# [[#Downloading the Portage tree|下载 Portage 源码树]]
# [[#Configuring your system|系统配置]] 和 [[#Configuring your network|网络配置]]
# [[#Configuring and installing the Linux kernel|安装 Linux 内核]]
# [[#Installing a Bootloader|安装系统引导程序]]
# [[#Finishing Steps|最后收尾工作]]
# [[#Restart your system|重启系统]]
 
=== Live CD ===
 
为了安装 Funtoo Linux,你首先要使用一个基于 Linux 的 Live CD 或者 USB 介质启动电脑。我们推荐你使用 Gentoo 系的 [http://www.sysresccd.org/ System Rescue CD],因为它包含大量的工具,并且同时支持32位和64位的系统,你可以将它烧录在 CD/DVD 或者 USB 介质中,从这里下载它的 ISO 镜像文件:
 
* 下载镜像 '''[http://ftp.osuosl.org/pub/funtoo/distfiles/sysresccd/sysresccd-4.7.0_zfs_0.6.5.4.iso osuosl.org]'''
* 下载镜像 '''[http://build.funtoo.org/distfiles/sysresccd/sysresccd-4.7.0_zfs_0.6.5.4.iso funtoo.org]'''
 
{{Important|'''无显示''': System Rescue CD 以 UEFI 方式启动时可能无法正确初始化显卡。 (请查阅 {{bug|FL-2030}}.) 如果碰到此问题,请在 System Rescue CD 启动 GRUB 菜单时, 输入 {{c|e}} 编辑 GRUB 启动行并添加{{c|insmod all_video}} 然后再启动系统。这个问题已经提交到 System Rescue CD 上游的开发者。}}
 
{{Note|如果使用老一些版本 System Rescue CD 进行启动, '''在你打算安装 64 位系统时,一定要在启动菜单选择<code>rescue64</code> 内核进行启动'''。默认情况下, System Rescue CD 以 32 位模式启动,并且能够自动识别 64 位 CPU。}}
 
==== 连接网络 ====
 
如果已经成功启动 System Rescue CD,请确认是否连接到 Internet,因为安装 Funtoo Linux 需要互联网:
 
<console>
# ##i##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
</console>
 
如果能够 ping 通外网 (检查 <code>64 bytes</code> 信息)表示网络连接正常。 输入 Control-C 停止 ping 程序。
 
如果以 WiFi 方式连接互联网,System Rescue CD 必须要运行图形界面。可以运行 <code>startx</code> 命令来启动图形界面:
<console>
# ##i##startx
</console>
 
[[File:NetworkManagerIcon.PNG|left|caption]]
 
接下来,用 NetworkManager 软件连接 WIFI 网络。 (软件图表在图形界面的任务栏的右下方) 然后,在图形界面下运行终端程序,确认电脑已经连接到互联网。
 
==== 远程安装====
 
当然,也可以通过网络以 SSH 远程登录到 System Rescue CD 的系统进行安装操作。
 
如果你采取远程登录 System Rescue CD 方式进行安装,先要确认系统已经联网,然后还需要给 System Rescue CD 设置一个 root 密码:
{{console|body=
###i## passwd
New password: ##i##********
Retype new password: ##i##********
passwd: password updated successfully
}}
设定完 root 密码后,还要知道 System Rescue CD 的 IP 地址。然后可以通过 {{c|ssh}} 连接。在 System Rescue CD 的终端上输入 {{c|ifconfig}} 来获取要连接的 IP 地址:
 
{{console|body=
###i## ifconfig
}}
可以从某个本地LAN口上看到(包含字段 {{c|inet addr:}}) IP地址信息。该地址就是你通过远程主机连接到 System Rescue CD的IP地址。 例如,你可以通过你现有的Linux 或者MacOS等系统连接System Rescue CD的这样格式的{{c|1.2.3.4}} IP地址:
 
{{console|body=
(remote system) $ ##i##ssh root@1.2.3.4
Password: ##i##**********}}
{{Note|如果使用 Microsoft Windows 系统进行远程连接,你需要在 Windows 上下载 SSH 客户端,比如 [http://www.chiark.greenend.org.uk/~sgtatham/putty/ PuTTY].}}
 
在通过 ssh 登录后,即可远程连接到 System Rescue CD 并执行安装步骤。
 
=== 准备硬盘分区 ===
 
在本段,我们将了解Funtoo Linux系统如何从硬盘启动。"启动",意思是在当打开电脑的电源开关后(比如桌面电脑,笔记本,服务器),进入Linux系统的过程。也可以理解为“启动”类似处理器先启动内置的固件,然后查找Linux内核再运行它,并由Linux内核识别系统硬件和启动这些硬件。
 
==== 背景知识 ====
 
{{Note|作为 Linux 新手,可以忽略下面这段,[[#Which to Use?|选择哪一个?]]}}
 
以前,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分区,你的{{f|/boot}}分区将是ext2文件系统,并且你需要使用{{c|fdisk}}新建分区。如果你使用新式GPT分区和UEFI启动,你的{{f|/boot}} 分区将使用vfat文件系统,因为vfat是UEFI所能读取的,你将使用{{c|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 必须同时支持可移动介质(所以你可以以 UEF I启动 System Rescue CD)以及固定介质(这样你才能启动 Funtoo Linux 开始安装)。该 BIOS 的新版(rev 3.0)完全支持 UEFI。这指出了第三个要点——了解你的硬件}}
 
==== 老式(BIOS/MBR)方法 ====
 
{{Note|如果 System Rescue CD 启动后菜单是浅蓝色则应该使用 BIOS 启动。如果你想使用新式方法, [[#School (UEFI/GPT) Method|点击此处跳转。]]}}
 
首先,你需要找到正确的硬盘来进行分区。尝试下列命令验证 {{f|/dev/sda}} 是要进行分区的硬盘:
{{console|body=
###i## 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
 
#        Start          End    Size  Type            Name
1        2048  1250263694  596.2G  Linux filesyste Linux filesystem
}}
建议删除现有磁盘上所有的 MBR 或者 GPT 分区表以防止混淆。我们将使用 {{c|sgdisk}} 完成此操作:
{{Warning|这将使现有分区不可访问,建议事先备份。}}
 
{{console|body=
###i## sgdisk --zap-all /dev/sda
 
Creating new GPT entries.
GPT data structures destroyed! You may now partition the disk using fdisk or
other utilities.
}}
如果输出这样的结果,不必担心,命令已有效运行
 
{{console|body=
***************************************************************
Found invalid GPT and valid MBR; converting MBR to GPT format
in memory.
***************************************************************
}}现在我们将使用 {{c|fdisk}} 创建 MBR 分区表和分区:
{{console|body=
###i## fdisk /dev/sda
}}
在{{c|fdisk}}下按照以下步骤操作:
 
'''清除分区表:'''
{{console|body=
Command (m for help): ##i##o ↵
}}
'''创建第一个分区:''' (boot):
 
{{console|body=
Command (m for help): ##i##n ↵
Partition type (default p): ##i##↵
Partition number (1-4, default 1): ##i##↵
First sector: ##i##↵
Last sector: ##i##+128M ↵
}}
'''创建第二个分区:''' (swap):
 
{{console|body=
Command (m for help): ##i##n ↵
Partition type (default p): ##i##↵
Partition number (2-4, default 2): ##i##↵
First sector: ##i##↵
Last sector: ##i##+2G ↵
Command (m for help): ##i##t ↵
Partition number (1,2, default 2): ##i## ↵
Hex code (type L to list all codes): ##i##82 ↵
}}
'''创建根目录分区:'''
 
{{console|body=
Command (m for help): ##i##n ↵
Partition type (default p): ##i##↵
Partition number (3,4, default 3): ##i##↵
First sector: ##i##↵
Last sector: ##i##↵
}}
'''验证分区表:'''
 
{{console|body=
Command (m for help): ##i##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
}}
'''将分区表写入磁盘:'''
 
{{console|body=Command (m for help): ##i##w}}
您的新MBR分区表已被写入你的系统磁盘。
 
{{Note|你现在已经完成了分区!现在,跳转至 [[#Creating filesystems|创建文件系统]]。}}
 
==== 新式(UEFI/GPT)方法 ====
 
{{Note|如果你想用 UEFI 启动,且 System Rescue CD 的启动介面是黑白的,则可以用该方式。如启动介面是蓝色,则该方式不会生效。}}
 
{{c|gdisk}} 命令可以用来创建一个 GPT 格式的分区。调整一个适合你自己的分区大小也是有必要的,但是对于新手来说,默认的分区设置就能够满足需求。运行 {{c|gdisk}} :
{{console|body=###i## gdisk /dev/sda}}
在 {{c|gdisk}} 中,按照以下步骤来操作:
 
'''创建一个新的分区表'''(这将会在保存时''擦除''掉当前磁盘上所有的数据):
{{console|body=
Command: ##i##o ↵
This option deletes all partitions and creates a new protective MBR.
Proceed? (Y/N): ##i##y ↵
}}
'''创建第一个分区'''(boot):
 
{{console|body=
Command: ##i##n ↵
Partition Number: ##i##1 ↵
First sector: ##i##↵
Last sector: ##i##+500M ↵
Hex Code: ##i##EF00 ↵
}}
'''创建第二个分区'''(swap):
 
{{console|body=
Command: ##i##n ↵
Partition Number: ##i##2 ↵
First sector: ##i##↵
Last sector: ##i##+4G ↵
Hex Code: ##i##8200 ↵
}}
'''创建第三个分区'''(root):
 
{{console|body=
Command: ##i##n ↵
Partition Number: ##i##3 ↵
First sector: ##i##↵
Last sector: ##i##↵##!i## (for rest of disk)
Hex Code: ##i##↵
}}
在安装的整个过程当中,您可以敲入 "{{c|p}}" 然后点击回车键来查看当前的分区表。如果犯了错误,您可以通过命令 "{{c|d}}" 来删除一个您建立的分区。当对分区满意时,使用 "{{c|w}}" 来将改动写入磁盘:
 
'''将分区表写入磁盘'''
{{console|body=
Command: ##i##w ↵
Do you want to proceed? (Y/N): ##i##Y ↵
}}分区表现在就将被写入磁盘,{{c|gdisk}} 也会关闭。
 
现在,你就创建了 GPT/GUID 分区,并且会在 Linux 中以 ''block devices'' 出现
 
* {{c|/dev/sda1}},被分配给 {{c|/boot}} 分区,
 
* {{c|/dev/sda2}},将被用作交换空间,并且
 
* {{c|/dev/sda3}},将被分配给 root 分区。
 
{{Tip|你可以通过运行 {{c|lsblk}} 命令来验证你正确地创建了块设备}}
==== Creating filesystems ====
 
{{Note|这个部分讲解了关于 BIOS '''和''' UEFI 的安装,一定不能跳过!}}
 
使用新建立的分区之前,在前面的步骤中创建的块设备需要用 ''metadata'' 文件系统来初始化。这个步骤被称为在块设备上'''创建文件系统'''。在块设备上创建了文件系统后,就可以挂载并且使用其来储存文件。
 
简单来说,你还在使用旧式的 MBR 分区吗?如果是这样,就让我们在 {{f|/dev/sda1}} 上创建一个 ext2 文件系统。
{{console|body=###i## mkfs.ext2 /dev/sda1}}
如果为 UEFI 使用新式 GPT 分区,则需要在 {{c|/dev/sda1}} 创建一 vfat 格式的分区,因为这是 UEFI 启动所必须的。
{{console|body=###i## mkfs.vfat -F 32 /dev/sda1}}
现在应当创建一个交换分区。Funtoo Linux 会将此分区用于基于硬盘的虚拟内存空间。
 
由于交换分区不是用来存储文件的,因此无需对于交换分区创建文件系统。但是需要使用 {{c|mkswap}} 将其初始化。由于之后的安装过程中需要交换分区,所以要运行 {{c|swapon}} 命令使交换分区立即在 Live CD 环境生效。
{{console|body=
# ##i##mkswap /dev/sda2
# ##i##swapon /dev/sda2
}}现在需要创建一个 root 文件系统。这是将要安装 Funtoo Linux 系统文件的位置。一般推荐使用 ext4 和 XFS 作为 root 分区的文件系统。如果不能确定使用哪一个,那就使用 ext4 。下面展示了如何创建一个 ext4 文件系统:
 
{{console|body=###i## mkfs.ext4 /dev/sda3}}
...现在,如果比起 ext4 你更喜欢使用 XFS 文件系统,可以使用下列命令创建 XFS root 文件系统:
 
{{console|body=###i## mkfs.xfs /dev/sda3}}
你的文件系统(包括交换分区)现在已经初始化了,这样就可以挂载他们(附加到现有的目录层次结构中)并且用来存储文件。我们已经准备好在崭新的分区上安装 Funtoo Linux。
 
{{Warning|当在部署一个 OpenVZ 架构的宿主机时,请'''仅'''使用 ext4 文件系统。Parallels 开发者团队对 ext4 和 {{c|openvz-rhel6-stable}} 的现代版本进行了大范围测试,发现前两者与 XFS '''不'''兼容,并且你可能会遇到内核层面的错误。}}
 
==== 挂载文件系统 ====
 
按照如下的步骤挂载新创建的文件系统,创建 {{c|/mnt/funtoo}} 作为安装的挂载点。
{{console|body=
###i## mkdir /mnt/funtoo
###i## mount /dev/sda3 /mnt/funtoo
###i## mkdir /mnt/funtoo/boot
###i## mount /dev/sda1 /mnt/funtoo/boot
}}
可选:当有一个独立的分区,例如 {{f|/home}} 或者其他时:
 
{{console|body=
###i## mkdir /mnt/funtoo/home
###i## mount /dev/sda4 /mnt/funtoo/home
}}
如要将 {{f|/tmp}} 或 {{f|/var/tmp}} 置于独立的文件系统中,需要确保在挂载后将挂载点的权限修改为全局可写,如下:
{{console|body=###i## chmod 1777 /mnt/funtoo/tmp}}
==== 设置日期  ====
 
{{Important|如果你的系统上的时间与实际的时间相差太远(特别是几月甚至是几年,)那么有可能会导致 Protage 无法正确的通过 https 下载源码包。原因是有一些源码会包会通过 https 下载,而 SSL 证书是具有一个完整的激活和过期时间的。但是,如果你的系统时间与正确的时间相差不多,目前是可以跳过这段的。}}
 
显示要验证日期和时间被正确的设定为 UTC 格式。使用 {{c|date}} 命令来校验日期和时间。
{{console|body=
###i## date
Fri Jul 15 19:47:18 UTC 2011
}}
如果需要矫正日期和/或时间,那么可以使用 {{c|date MMDDhhmmYYYY}} 命令,一定要记住 {{c|hhmm}} 是 24 小时的格式。下面的例子展示了把时间修改为 ”UTC 格式的 2011 年 7 月 16 日,下午 8:00“
 
{{console|body=
###i## date 071620002011
Fri Jul 16 20:00:00 UTC 2011
}}
系统时间设置完成之后,将时间同步到机器的硬件时钟上是一个好主意,这样就能保证在重启之后时间维持不变。
 
{{console|body=###i## hwclock --systohc}}
=== 安装 Stage 3 压缩包 ===
 
现在我们已经完成了创建分区以及设置系统时间这两个步骤,下一步便是下载 Stage 3 压缩包。Stage 3 压缩包是一个预编译的,可以作为安装 Funtoo Linux 的出发点的系统。 
 
请移步至 [[Subarches]] 来为你的系统下载最新版本的 Funtoo Linux。其他平台的分支(例如 arm 等)是为了让 Funtoo Linux 能在某一特定的 CPU 平台上有最好的表现而设计的。它们也对于每个 CPU 的指令集有不同的优势。
 
[[Subarches]] 页面列出了所有对于不同种类的 CPU 进行了特殊优化的 Funtoo Linux 版本。找出适合你的 CPU 种类的版本,然后在从左至右第一栏点击它的名字(比如 {{c|corei7}})。你将会进入一个主要介绍你选择的版本的页面,这个页面也会列出可用的 stage3 压缩包。如果你使用虚拟化技术来运行 Funtoo Linux,并且你的 VM 也能移植到不同类型的硬件上,建议使用对于最老式的 CPU 指令集进行过优化的 satge3 压缩包,或者是一个在 AMD 和 Intel 处理器上都能够运行的通用镜像。
 
对于大多数的子分支,有几个 stage3 可供选择。下面的部分可以帮助你了解要选择哪一个。
 
==== 哪个版本? ====
 
'''如果你不确定,就选择 {{c|funtoo-current}}'''
 
Funtoo Linux 有很多不同的 '版本':
 
{{TableStart}}
{{2ColHead|Build|Description}}
<tr><td>{{c|funtoo-current}}</td><td>The most commonly-selected build of Funtoo Linux. Receives rapid updates and preferred by desktop users.</td></tr>
<tr><td>{{c|funtoo-stable}}</td><td>Emphasizes less-frequent package updates and trusted, reliable versions of packages over the latest versions.</td></tr>
{{TableEnd}}
 
==== 哪个子版本? ====
 
'''如果你不确定,就选择 {{c|standard}}
 
'''通常'''情况下 stage3 由 {{c|standard}} 的许多变种组成,列表如下:
 
{{TableStart}}
{{2ColHead|Variant|Description}}
<tr><td>{{c|standard}}</td><td>Funtoo Linux 的"'标准'"版。</td></tr>
<tr><td>{{c|pure64}}</td><td>不提供 多位元支持(multilib,32-bit compatibility)的 64 位版本。是服务器系统的理想选择。</td></tr>
<tr><td>{{c|hardened}}</td><td>包含 PIE/SSP 工具链以提供增强的安全特性。PIE 需要使用支持 PaX 的 kernel。SSP 可以在任何 kernel 下运行,并且在用户空间提供增强安全性,避免积累性漏洞攻击。适合有经验的用户</td></tr>
{{TableEnd}}
 
==== 下载 Stage3 ====
 
选择好 Stage3 之后,就可以下载了。使用 {{c|wget}} 命令来下载将要作为基础系统的压缩包。它应当被保存在 {{f|/mnt/funtoo}} ,如下所示:
{{console|body=
###i## cd /mnt/funtoo
###i## 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 版本。如果你不确定,可以毫无顾虑地选择 {{c|generic_64}} 或者是 {{c|generic_32}} stage。参阅 [[Subarches]] 页面来获得更多信息。
 
Stage 文件下载完成之后,使用下列的命令来解压文件,记住需要用你下载的 Stage3 文件的名字来替换命令中文件的名字:
{{console|body=
###i## tar xpf stage3-latest.tar.xz
}}{{Important|在解压 Stage3 压缩包时,使用 {{c|tar}} 的 "{{c|'''p'''}}" 选项是很重要的,这将对 {{c|tar}} 声明要 '''保留''' 在压缩文件中所有的权限和所有权。若没有指明此选项,Funtoo Linux 文件系统的权限有可能会变得不正确。}}
 
=== chroot 进入 Funtoo  ===
安装 Funtoo Linux 前要使用 {{c|chroot}} 命令。chroot 将根目录 '''切换至''' 新的 Funtoo Linux 系统中,所以接下来运行的命令都将在新解压出的 Funtoo Linux 系统中运行。
 
在转换 root 环境之前,我们还需要做一些工作来将 chroot 环境完善。你需要将 {{f|/proc}}, {{f|/sys}} and {{f|/dev}} 挂载到新系统中。可以使用下述指令:
{{console|body=
# ##i##cd /mnt/funtoo
# ##i##mount -t proc none proc
# ##i##mount --rbind /sys sys
# ##i##mount --rbind /dev dev
}}同时也需要复制一份 {{f|resolv.conf}} 到新的 chroot 环境中,来获得对域名的正确解析:
{{console|body=
# ##i##cp /etc/resolv.conf /mnt/funtoo/etc/
}}现在就可以 chroot 进入新系统中了,注意需要先执行 {{c|env }} 再执行 {{ c|chroot }} 来确保安装介质中的环境变量不会进入你的新系统。
 
{{console|body=###i## env -i HOME=/root TERM=$TERM chroot . bash -l}}
{{Note|对于使用 64 位 Live CD 安装 32 位 系统用户请注意:一些软件使用 {{c|uname -r}} 来检查系统是 32 位或是 64 位。你可能需要将 linux32 指令附加在 chroot 指令中执行来解决这个问题,但通常情况下是不需要的。}}
{{Important|如果你得到了 "{{c|chroot: failed to run command `/bin/bash': Exec format error}}" 这个错误,多数情况是尝试在 32 位内核中执行 64 位指令。确保在启动 System Rescue CD 时选择了正确的内核类型。}}
 
在 chroot 环境下对默认的命令提示做一下改动也是一个好主意。这可以在你切换终端/终端模拟器时不至于搞混。使用下述指令:
{{console|body=# ##i##export PS1="(chroot) $PS1"}}
在 chroot 环境下测试域名解析:
{{console|body=###i## ping -c 5 google.com}}
如果你不能 ping 通,检查 {{f|/etc/resolv.conf}},看看其中是否有 {{c|127.0.x.x}} 的行,如果有上述的行,那就把 {{c|127.0.x.x}} 改为 {{c|8.8.8.8}} -- Google 的公共 DNS 服务器地址(对于中国大陆用户,可以将 DNS 地址设置为 202.38.95.110(教育网),202.141.160.110(电信),202.141.176.110(移动),2001:da8:d800:95::110(ipv6)(中科大 DNS)以便更好地解析)。在系统安装后,确保时用这个来替换掉 DNS 服务器地址。
 
 
乌拉!你现在已经 chroot 进入了一个新的 Funtoo Linux 系统中。是时候正确地配置 Funtoo Linux ,以便在没有任何手动设置的情况下,让它能正确的重启并且运行。
 
{{Note|参考 [[Installing Portage From Snapshot]] 来了解同步 Portage 的其他方式。}}
是时候安装一份 Portage 仓库的拷贝了,这其中包含了包脚本(ebuilds),即向 Portage 声明如何安装成千上万的软件包。只要在 chroot 环境下执行一句简单的指令 <code>emerge --sync</code> 就能创建 Portage 仓库。这个指令会自动地从  [https://github.com/funtoo/ports-2012 GitHub] clone 一份 Portage tree 到本地:
 
{{console|body=
(chroot) ###i## emerge --sync
}}
{{Important|若在初始化 {{c|emerge --sync}} 时遇到了由于 git 协议限制引起的错误,可在 {{c|/etc/portage/make.conf}} 中将 {{c|SYNC}} 变量设置为 {{c|"https://github.com/funtoo/ports-2012.git"}}
}}
 
=== 配置系统 ===
正如对任何一个 Linux 发行版期盼的那样,Funtoo Linux 有一份自己的配置文件。这份文件是 {{f|/etc/fstab}},需要编辑来确保 Funtoo Linux 来正确启动。其他都是可选的。
 
==== 使用 Nano ====
 
chroot 环境下包含的默认文本编辑器是 {{c|nano}}。若要编辑文本,可以按照下述方法使用 Nano:
 
{{console|body=
(chroot) ###i## nano /etc/fstab
}}
在编辑器中时,可以使用方向键移动光标,并且退格和删除这一类的按键都会像往常一样工作。可以按 Control-X 并且 用 {{c|y}} 来回答是否将改动保存到文件的提示来保存文件。
 
==== 配置文件 ====
 
下面是一个你可能会要编辑的文件的列表,按需编辑:
{{TableStart}}
{{3ColHead|File|是否需要编辑这个文件?|Description}}
<tr  class="danger">
<td>{{c|/etc/fstab}}</td>
<td>'''YES - required'''</td>
<td>在启动时对所有文件系统生效的挂载点。这个文件必须与你的磁盘分区设置相对应,接下来将示范如何修改此文件。</td>
</tr><tr>
<td>{{c|/etc/localtime}}</td>
<td>''Maybe - recommended''</td>
<td>你的时区。若没有设置,则默认为 UTC。这应该是指向 /usr/share/zoneinfo 下文件的一个符号链接。 (比如 /usr/share/zoneinfo/America/Montreal) </td>
</tr><tr>
<td>{{c|/etc/make.conf}} (symlink) - 也可以是: <br />{{c|/etc/portage/make.conf}}</td>
<td>''Maybe - recommended''</td>
<td>gcc (编译器)、portage、以及 make 会用到的参数。别忘记设置 MAKEOPTS。 之后在文档中会讲到这些。''注意在 Funtoo Linux 中,这个文件为空是很正常的。原因是为了加强系统,很多设置都被迁移了。''</td>
</tr><tr>
<td>{{c|/etc/conf.d/hostname}}</td>
<td>''Maybe - recommended''</td>
<td>要习惯给系统设置一个名字。如果你想好了一个名字,那就遵守(包括点号,即 {{c|foo.funtoo.org}})原则,设置 {{c|hostname}} 变量。除此之外设置本地系统名(避免使用点号,即 {{c|foo}})。若未指定,则默认为 {{c|localhost}}。</td>
</tr><tr>
<td>{{c|/etc/hosts}}</td>
<td>''No''</td>
<td> 你不必在这个文件中手动设置主机名。这个文件会由 {{c|/etc/init.d/hostname}} 自动生成。</td>
</tr><tr>
<td>{{c|/etc/conf.d/keymaps}}</td>
<td>Optional</td>
<td>键盘布局配置文件 (对于模拟终端)。如果使用非美国键盘布局,别忘了修改这个文件。参看 [[Funtoo Linux Localization]].</td>
</tr><tr>
<td>{{c|/etc/conf.d/hwclock}}</td>
<td>Optional</td>
<td>How the time of the battery-backed hardware clock of the system is interpreted (UTC 或当地时间)。在系统启动时 Linux 使用主板电池支持的硬件时钟初始化系统时钟 。</td>
</tr><tr>
<td>{{c|/etc/conf.d/modules}}</td>
<td>Optional</td>
<td>内核模块在系统启动时会自动加载。 一般不需要手动配置。参考 [[Additional Kernel Resources]] 获取更多信息。</td>
</tr><tr>
<td>{{c|/etc/conf.d/consolefont}}</td>
<td>Optional</td>
<td>允许你设置默认的控制台字体。如要应用此字体。使用 rc-update 命令启用 consolefont 服务和 consolefont。</td>
</tr><tr>
<td>{{c|profiles}}</td>
<td>Optional</td>
<td>一些有用的能帮助你更快初始化配置的 portage 设置。</td>
</tr>
{{TableEnd}}
 
如果你正在安装一个英文版的 Funtoo Linux,那就可以按照原样使用大部分的配置文件。如果你在安装其他语言的版本,不必担心,我们在 [[Funtoo Linux Localization]] 页面上写出了必要的准备步骤。如有需要,还有许多友好的帮助在等着你(请参考这个 [[#Community portal|Community]])。
 
让我们继续安装,看看还有什么需要做的。使用 {{c|nano -w <name_of_file>}} 来编辑文件-- "{{c|-w}}" 指令会禁用自动换行,这样让编辑配置配置文件更顺手。你可以从示例文件中复制粘贴。
 
{{Warning|在重启之前编辑 {{c|/etc/fstab}} 是很重要的!你需要修改 ''fs'' 和 ''type'' 栏,让他们与你使用 {{c|gdisk}} 或 {{c|fdisk}} 创建的文件系统和分区相匹配。跳过这个步骤有可能会让 Funtoo Linux 无法正确启动。}}
 
==== /etc/fstab ====
 
{{f|/etc/fstab}} 在系统启动时会被 {{c|mount}} 读取。这个文件中的每一行都会向 {{c|mount}} 声明需要挂载哪些文件系统以及如何挂载他们。为了让系统正常启动,你需要编辑 {{f|/etc/fstab}} 并且确保其中的配置与之前安装步骤中你对分区的修改一致,{{c|lsblk}} 会让这件事更容易:
{{console|body=
(chroot) ###i## nano -w /etc/fstab
}}
{{file|name=/etc/fstab|desc=An example fstab file|body=
# 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|目前,我们默认的 {{f|/etc/fstab}} 文件包含了在 {{c|/dev/sda4}} 的 root 文件系统,以及在 {{c|/dev/sda3}} 的交换分区。我们需要将这些设置分别改为 {{c|/dev/sda3}} 和 {{c|/dev/sda2}}。}}
 
{{Note|如果使用 UEFI 启动,将 {{f|/dev/sda1}} 稍加改动,把 {{c|ext2}} 改为 {{c|vfat}}。还记得在前面的步骤中我们是如何分区的吗?与前者相似,检查 {{f|/dev/sda3}} 是 {{c|xfs}} 或是 {{c|ext4}} 是否对应分区。}}
 
==== /etc/localtime ====
 
{{f|/etc/localtime}} 用来明确你的机器处于哪个时区,默认是 UTC。如果想让 Funtoo Linux 系统使用当地时间,你需要将 {{|/etc/localtime}} 用一个符号链接指向你想要使用的时区。
 
{{console|body=
(chroot) ###i## ln -sf /usr/share/zoneinfo/MST7MDT /etc/localtime
}}
上面的命令会将时区设置为  Mountain Standard Time(包括夏令时)。用 {{c|ls /usr/share/zoneinfo}} 命令来显示可用的时区。其中也有子目录包含了以地区描述的时区。
 
==== /etc/portage/make.conf ====
 
{{c|MAKEOPTS}} 可以用来指定在编译安装包时创建多少个并行的线程,这样可以显著地加速编译完成的速度。按照经验来讲,将 {{c|MAKEOPTS}}          设置为 CUP 数量的值(或 CPU 线程的值)+ 1 时比较好的。举个例子:如果你有一个不包含 [[wikipedia:Hyper-threading|hyper-threading]] 的双核CPU,你可以将 {{c|MAKEOPTS}} 设置为 3:
 
<pre>
MAKEOPTS="-j3"
</pre>
 
如果你不确定你有多少个 核心/线程,可以用 命令{{c|nproc}} 查看
{{console|body=
(chroot) ###i## nproc
16
}}
将 {{c|MAKEOPTS}} 设置为上面的数字加上一之后的值:
 
<pre>
MAKEOPTS="-j17"
</pre>
 
{{c|USE}} 字段指定了在软件包包安装时所启用的功能。在安装的过程中我们不推荐向 USE 标志中加入很多字段;在改变 USE 选项之前,你需要确定你有一个能正常启动、工作的系统。一个前面写着负号 ("{{c|-}}") 的 USE 标志会向 Portage 声明在编译时不要使用该选项。在不久的将来,会有一篇专门介绍 USE 的 Funtoo 指导手册。现在,你可以参考 [http://www.gentoo.org/doc/en/handbook/handbook-amd64.xml?part=2&chap=2 Gentoo Handbook] 来获得关于 USE 的更多信息。
 
{{c|LINGUAS}} 向 Portage 声明要将系统和应用 (就像使用 LINGUAS 作为环境变量的 OpenOffice) 编译为某个特定的语言。一般在使用英文的情况下是不需要这样做的。如果你需要另一种像法语(French,fr)或是德语(German,de)这样的语言,那需要合适地设置 LINGUAS:
 
<pre>
LINGUAS="fr"
</pre>
 
==== /etc/conf.d/hwclock ====
如果你想让 Funtoo  Linux 与 Windows 双系统启动,你需要编辑这个文件,把 '''clock''' 的值从 '''UTC''' 改为 '''local''',原因是 Windows 在每次启动时都会将硬件时钟设置为本地时钟。其他一般的情况下,是不需要编辑这个文件的。
{{console|body=
(chroot) ###i## nano -w /etc/conf.d/hwclock
}}
==== 本地化 ====
 
默认情况下,Funtoo Linux 使用 Unicode (UTF-8),并且对应了美国英语的本地化以及键盘分布。如果你想要将你的系统配置为非英语的环境和键盘布局,请参考[[Funtoo Linux Localization]]。
 
=== Portage 简介 ===
 
Portage,是 Funtoo Linux 的包管理器,其中包含了一个叫做 <code>emerge</code> 的命令,这个命令可以用来从源码构建并安装包。也能同时管理好所有的依赖关系。你可以按照下面的说明调用 emerge:
 
<console>
(chroot) # ##i##emerge packagename
</console>
 
当你在命令行中安装某一个特定的软件包时,Portage 会在 <code>/var/lib/portage/world</code> 文件中记录它的名字。这样做是因为 emerge 就是这样被设计的,因为你用名字来安装一个如阿健包,你就想这个软件包会是系统的一部分,并且也想在未来让这个软件包升级。因为我们将一个包添加到了 <code>world</code> 集,它就能自动升级,所以说这是一个方便的特性,我们可以用下面的命令来升级整个系统:
 
<console>
(chroot) # ##i##emerge --sync
(chroot) # ##i##emerge -auDN @world
</console>
 
这是升级你的 Funtoo Linux 系统的 ''官方'' 方式。作为开始,我们需要通过 git 拉取最新的 ebuilds (脚本)来更新 Portage 树,之后需要运行一个 emerge 指令来更新 <code>world</code> 包合集。这几个选项对 <code>emerge</code> 声明要做下列的事情:
 
* '''<code>a</code>''' - 会打印出将要被 emrge 的包,  '''ask''' 将会询问我们是否想要继续。
* '''<code>u</code>''' - '''update''' 升级我们指定的软件包 -- 将不会重复 emerge 一个已经安装的软件包.
* '''<code>D</code>''' - 将会在更新时考虑整个依赖数,换句话说,,就是做一个 '''deep'''(深层次的) 升级。
* '''<code>N</code>''' - 升级所有在 USE 中更改了('''new''')设置的软件包
 
在 emerge @world 合集时,你也需要考虑 <code>--with-bdeps=y</code> 这个参数,在一段时间要至少要使用一次。这将会同时升级依赖软件包。
 
当然了,有些时候我们想安装一些软件包,但是并不想把他们添加到 <code>world</code> 文件中。这样做通常是考虑到只需要临时安装这个软件包,或者这个有问题的软件包是另一个包的依赖。如果需要这样做,就按照下面的方法使用 emerge 命令:
 
<console>
(chroot) # ##i##emerge -1 packagename
</console>
 
高级用户可以看看 [[Emerge]] 的维基页面。
 
==== 更新 world 合集 ====
 
现在是时候更新整个系统了,并且推荐在第一次启动后先做这件工作。
 
<console>
(chroot) # ##i##emerge --sync
(chroot) # ##i##emerge -auDN @world
</console>
 
{{fancyimportant|1=
确保你读了所有 emerge 过去的消息并且遵照了它们的指示。在你升级了你的 Perl 或 Python 后这是非常重要的。}}
 
=== 内核 ===
 
从 2015 年 五月中旬开始,Funtoo Linux 的 stage3 文件中就包含了一个预编译的 {{c|debian-sources}} 内核,使得整个安装过更加简单和快速。使用下面的命令来检查 Debian 源是否安装:
{{console|body=
(chroot) # ##i##emerge -s debian-sources
Searching...   
[ Results for search key : ##b##debian-sources##!b## ]
[ Applications found : ##b##1##!b## ]
 
*  ##b##sys-kernel/debian-sources##!b##
      ##g##Latest version available:##!g## 3.19.3
      ##g##Latest version installed:##!g## 3.19.3
      ##g##Size of files:##!g## 81,292 kB
      ##g##Homepage:##!g##      http://www.debian.org
      ##g##Description:##!g##  Debian Sources (and optional binary kernel)
      ##g##License:##!g##      GPL-2
}}
如果在 {{c|Latest version installed}} 中列出了一个内核的版本,那就说明 Debian 源已经预编译好了,你就能跳过剩下的内核的部分,并且移步至 [[#Installing a Bootloader|Installing a Bootloader section]]。
 
==== 编译安装内核 ====
 
如果你需要为 Funtoo Linux 编译安装一个内核,请遵照以下步骤:
 
{{Fancynote|1=
参考 [[Funtoo Linux Kernels]] 来获得一份关于 Funtoo Linux 支持的内核的完整清单。对新用户来说,我们推荐 <code>debian-sources</code> for new users。}}
 
{{fancyimportant|1=
带有 <code>binary</code> USE 标志的 <code>debian-sources</code> 至少需要 <code>/var/tmp</code> 中有 14GB 的可用空间,并且在 英特尔 Core i7 上需要大约 1 小时来编译安装内核。}}
 
让我们 emerge 我们的内核:
 
<console>
(chroot) # ##i##emerge debian-sources
</console>
 
<code>emerge</code> 完成后,你需要将崭新的内核以及 initramfs 安装到 <code>/boot</code>,内核头文件安装到 <code>/usr/src/linux</code>,这样就做好了配置启动加载器(boot loader),准备让它来启动 Funtoo Linux
 
{{warning|如果你的机器上有磁盘阵列(RAID),在安装内核时,需要 <code>mdadm</code> 工具作为依赖。在重启之后首先编辑 <code>/etc/mdadm.conf</code> 文件,这样在内核尝试将磁盘阵列挂载到目录树之前,就能让机器正确地识别、配置它了。如果没有做这件工作,可能会导致系统不稳定甚至无法开机!如果要查询细节问题,请使用命令 <code>man mdadm</code> 参考 mdadm 的手册页或[[Package:Mdadm|mdadm]] ebuild page。}}
 
{{fancynote|NVIDIA 显卡用户请注意:<code>binary</code> USE 标记会安装 Nouveau 驱动,但是这个驱动不能与专有驱动一起加载,并且由于 KMS 的原因,在运行时也无法卸载。你需要在 <code>/etc/modprobe.d/</code> 中将它列入黑名单。}}
 
{{fancynote|如果你需要一个对于 Funtoo Linux 的其他内核选项的概览,请参阅 [[Funtoo Linux Kernels]]。Debian 内核不包含很多模块,这个站点 [http://www.funtoo.org/wiki/Funtoo_Linux_Kernels#Using_Debian-Sources_with_Genkernel genkernel] 可能会有帮助。也别忘记看看 [[:Category:Hardware Compatibility|hardware compatibility]] information。}}
 
=== 安装一个启动引导器 ===


下列的安装指南会向你展示如何在老式的 BIOS 或新式的 UEFI 上使用 GRUB 来启动 Funtoo Linux。下面的说明会以 Portage 中的 boot-update-1.7.2 为例,但其余的也是十分相似的。
{{#css:
 
firstHeading {
第一步,emerge <code>boot-update</code> 这个软件包。因为软件包的依赖关系,这也将同时 emerge <code>grub-2</code> 与 {{c|efibootmgr}}:
  display: none;
 
<console>
(chroot) # ##i##emerge boot-update
</console>
 
接下来,用 {{c|nano}} 编辑 <code>/etc/boot.conf</code>,在文件上面位置用 "<code>Funtoo Linux genkernel</code>" 替换掉 <code>"Funtoo Linux"</code>,并将 "<code>default</code>” 指明为 <code>Funtoo Linux genkernel</code>。
 
<code>/etc/boot.conf</code> 应如下所示:
{{file|name=/etc/boot.conf|body=
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
}
}
}}
}}
如果你需要自定义或者是从一个非默认的内核启动,请阅读 <code>man boot.conf</code> 来获得对你用帮助的信息。
==== 旧式的 (BIOS) MBR ====
当使用"旧式的" BIOS 引导启动时,运行下面的命令对 GRUB 声明让它安装到你的 MBR 中,并且生成 GRUB 引导启动时需要的 {{c|/boot/grub/grub.cfg}} 配置文件:
<console>
(chroot) # ##i##grub-install --target=i386-pc --no-floppy /dev/sda
(chroot) # ##i##boot-update
</console>
==== 新式的 (UEFI)Boot Entry ====
如果你在使用"新式的" UEFI 引导启动,你需要运行下面几个命令,这取决于你在安装一个 64 位还是 32位的系统。这将会把 GRUB 添加为一个 UEFI 的启动条目。
对于 x86_64 位系统:
<console>
(chroot) # ##i##grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id="Funtoo Linux [GRUB]" --recheck /dev/sda
(chroot) # ##i##boot-update
</console>
对于 x86_32 位系统:
<console>
(chroot) # ##i##grub-install --target=i386-efi --efi-directory=/boot --bootloader-id="Funtoo Linux [GRUB]" --recheck /dev/sda
(chroot) # ##i##boot-update
</console>
==== 第一次启动,以及之后...... ====
一切就绪--你已准备好启动!
在第一次安装 Funtoo Linux 时,你需要做的就是运行 <code>grub-install</code> 命令,但是每次你修改了 <code>/etc/boot.conf</code> 文件之后,都需要重新运行 <code>boot-update</code> 命令将新的内核添加进入系统。这个操作会重新生成 {{c|/boot/grub/grub.cfg}} 文件,这样,在下一次重启系统时,就可以把新的内核添加进入 GRUB 启动选单中了。
=== 网络配置 ===
在重启系统之前,确保能连接上网络是很重要的。你可以从 NetworkManager,dhcpcd,[[Funtoo Linux Networking]] 脚本这三个中自由选择。下面讲解了如何根据你想要设置的网络的类型来选择合适的方式。
==== Wi-Fi 配置 ====
对于在使用无线连接,移动数据等的笔记本电脑/移动用户来说,我们强烈推荐 NetworkManager。
因为无线网卡需要固件才能使用,所以也推荐 emerge linux-firmware ebuild。
{{console|body=(chroot) # ##i##emerge linux-firmware networkmanager
(chroot) ###i## rc-update add NetworkManager default
}}
上述指令可以确保在你启动进入 Funtoo Linux 之后 NetworkManager 能够启动。在完成了这些设置并启动进入 Funtoo Linux 之后,你可以使用 {{c|nmtui}} 命令(这个命令是使用起来简单方便,基于命令行界面的)来设置 NetworkManager ,这样,就能连接(并且能在重启之后自动连接)到无限网络:
{{console|body=# ##i##nmtui}}
如果想获得关于 NetworkManager 的更多的信息,请参考:
[[Package:NetworkManager|NetworkManager package page]]。
{{Note|wpa_supplicant 对无线连接来说也是一个不错的选择。参考这个软件包 {{package|net-wireless/wpa_supplicant}} 来找到有关设置 wpa_supplicant 的信息。}}
==== 桌面(有线 DHCP 连接) ====
对于一个使用 DHCP 进行有线网络连接的家庭电脑或者是工作站,最简单有效的启用网络方式,就是将 {{c|dhcpcd}} 添加至默认的 runlevel:
{{console|body=
(chroot) # ##i##rc-update add dhcpcd default}}
重启系统后,{{c|dhcpcd}} 会在后台运行,管理所有的网络接口,并且通过 DHCP 服务从 DHCP 服务器获得网络地址。
如果你的 DHCP 上游的服务器是 dnsmasq,那么他可以设置为通过 MAC 地址给终端分配地址,这样就能使用 DHCP 上的服务器。
==== 服务器(静态 IP)====
对于服务器,推荐使用 [[Funtoo Linux Networking]] 脚本。脚本对配置静态 IP 以及对于虚拟化使用的虚拟以太网桥接是有特殊的优化的。参看 [[Funtoo Linux Networking]] 了解如何使用Funtoo Linux 提供的模板配置网络。
==== 主机名(Hostname)====
Funtoo 使用 "localhost" 作为主机名。虽然系统用这个名字也能完美的运行,但是一些 ebuilds 若检测到主机名是 localhost ,则他们会拒绝安装。如果多个系统同时使用 localhost 作为主机名,也容易混淆他们。因此,建议起一个有意义的名字。主机名可以是任意的,这意味着只要对于系统的管理员来说,这名字看起来合理,你就可以使用任意的字母组合。如果要更改主机名,就编辑下列文件:
{{console|body=
(chroot) # ##i##nano /etc/conf.d/hostname
}}
找找看哪一行是以主机名开头的,然后将其中的条目修改。保存文件,下一次 Funtoo Linux 启动的时候就将使用新的主机名。
{{Warning|避免在主机名中使用特殊字符,原因是 shell 有可能会尝试解释这些特殊的字符,这样可能会到导致一些无法预测的结果,使用拉丁字母表:a-z, A-Z, 0-9 中的字符}}
{{Tip|为了避免主机名占满终端的屏幕,只给命令很小的空间,尽量使用简短的主机名(最多 8 至 10 个字符)。特别是在一些类似 Bash、Python、SQL 和 Perl 等语言中使用长字符串时。}}
=== 收尾工作 ===
==== 设置 root 密码 ====
在重启之前必须设置一个 root 密码,这样才能在重启后登陆
<console>
(chroot) # ##i##passwd
</console>
=== 重启系统 ===
现在我们应当退出 chroot 环境,卸载掉 Funtoo Linux 的分区和文件,并且重启电脑。重启后,GRUB 启动引导器会启动,它会加载 Linux 内核以及 initramfs,这之后你的系统就会开始启动。
离开 chroot 环境,将当前工作目录更改为 /mnt,卸载你的 Funtoo 分区,并且重启电脑。
<console>
(chroot) # ##i##exit
# ##i##cd /mnt
# ##i##umount -lR funtoo
# ##i##reboot
</console>
{{fancynote|系统恢复 CD 会将卸载新的 Funtoo 的分区的过程作为自身一般的关机步骤来处理。}}
现在,你就应该可以看到你的系统重启了,过几秒 GRUB 引导器就会出现,接下来就能看 Linux 内核以及 initramfs 在加载。这之后,就应该可以看到 Funtoo Linux 在启动了。并且这之后你也应该看到一个 <code>login:</code> 提示。到此为止,你已成功安装 Funtoo Linux。
=== Profiles ===
重启进入 Funtoo Linux 之后,就可以使用 [[Funtoo Profiles]] 来进一步地自定义你的系统。下面是一个对 Profiles 简短的介绍 -- 看看 [[Funtoo Profiles]] 来找到更详细的信息。基本的 Profile 类型有五种,分别是:arch, build, subarch, flavors and mix-ins:
{{TableStart}}
{{2ColHead|Sub-Profile Type|Description}}
{{2Col|{{c|arch}}|一般是 {{c|x86_32bit}} 或 {{c|x86_64bit}},这决定了系统的类型和支持方式。在你安装 Stage3 时,这就已经设定好了,并且不应修改。}}
{{2Col|{{c|build}}|决定了你的系统是 {{c|current}},{{c|stable}} 或 {{c|experimental}} 版本。与 {{c|stable}} 系统相比,{{c|current}} 系统将会包含更新的,unmask 的软件包。这是在 Stage 安装时决定的,并且通常不会改变。}}
{{2Col|{{c|subarch}}|决定了如何为你的系统 CPU 进行优化 。subarch 在 Stage3 安装的时候会设置,但若需要,可以在之后修改为更好的设置。谨记要选择一个和你的 CPU 架构相匹配的设置。}}
{{2Col|{{c|flavor}}|决定了系统的一般类型,例如 {{c|server}} 或是 {{c|desktop}},并且会根据你的需要适当地设置 USE 标志。}}
{{2Col|{{c|mix-ins}}|决定了一些你可能有兴趣启用的内容。}}
{{TableEnd}}
对于每一个 Funtoo Linux 系统,必须设置一个 Arch、build 以及 flavor。mix-in 是可选的,如果有需求,那么可以设置多个。多数情况下,flavor 和 mix-in 从其他的附属配置(sub-profiles)中继承设置。用 {{c|epro show}} 查看当前的 profile 设置,以及所有的设置继承信息:
{{console|body=
(chroot) # ##i## epro show
=== ##g##Enabled Profiles##!g##: ===
        arch: ##c## x86-64bit
      build: ##c## current
    subarch: ##c## intel64-haswell
      flavor: ##c## desktop
    mix-ins: ##c## gnome
=== ##g##All inherited flavors from desktop flavor##!g##: ===
                    ##c##workstation##!c## (from desktop flavor)
                            ##c##core##!c## (from workstation flavor)
                        ##c##minimal##!c## (from core flavor)
=== ##g##All inherited mix-ins from desktop flavor##!g##: ===
                              ##c##X##!c## (from workstation flavor)
                          ##c##audio##!c## (from workstation flavor)
                            ##c##dvd##!c## (from workstation flavor)
                          ##c##media##!c## (from workstation flavor)
      ##c##mediadevice-audio-consumer##!c## (from media mix-in)
                ##c##mediadevice-base##!c## (from mediadevice-audio-consumer mix-in)
      ##c##mediadevice-video-consumer##!c## (from media mix-in)
                ##c##mediadevice-base##!c## (from mediadevice-video-consumer mix-in)
        ##c##mediaformat-audio-common##!c## (from media mix-in)
          ##c##mediaformat-gfx-common##!c## (from media mix-in)
        ##c##mediaformat-video-common##!c## (from media mix-in)
                  ##c##console-extras##!c## (from workstation flavor)
                          ##c##print##!c## (from desktop flavor)
}}
{{c|epro}} 基本用法如下:
{{TableStart}}
{{2ColHead|Description|Command}}
{{2Col|查看可用的 profile。启用的 profile 将会以青色高亮显示。直接启用的以粗体显示并且有 {{c|*}} 附在最前。|{{console|body=(chroot) # ##i##epro list}}}}
{{2Col|改变系统的 flavor。|{{console|body=(chroot) # ##i##epro flavor desktop}}}}
{{2Col|添加一个 mix-in。|{{console|body=(chroot) # ##i##epro mix-in +gnome}}}}
{{TableEnd}}
===下一步===
如果你是从来没有接触过 Gentoo Linux 和 Funtoo Linux 的新手,请看看 [[Funtoo Linux First Steps]] ,这能帮助你初识你的新系统。我们对于 [[:Category:Official Documentation|official documentation]] 也有一个专门的类别,这个类别包含了所有官方维护的文档,这些文档主要讲解了 Funtoo Linux 的安装和操作。
我们也有许多讲解安装系统的页面,参考 [[:Category:First Steps|First Steps]] 来获得一份列表。
如果你的系统没有正确启动,参考 [[Installation Troubleshooting]] 来获得解决问题的方法。
[[Category:HOWTO]]
[[Category:Install]]
[[Category:Official Documentation]]

Latest revision as of 04:07, November 21, 2021

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

Translators: Thank you for your help! Please use the section-by-section guide as the basis for your translations. Thanks again!

Introduction

root # Welcome to Funtoo Linux!

欢迎走近 Funtoo Linux!本文档是为了帮助你在 PC 兼容的系统上安装 Funtoo Linux 而写的,同时将系统配置方面的干扰选项降到最低。

If you're new to installing a Gentoo-based Linux, or new to Linux entirely -- welcome! We have attempted to make these installation instructions understandable to new users as well. We encourage all new users to read Wolf Pack Philosophy to understand some of the distinctives of the Funtoo community.

在我们开始之前,请查看以下重要信息:

Our desktop environment stages (GNOME, Cinnamon, etc.) now support seamless installation on VMware Workstation Pro virtual machines. We highly recommend you enable 3D Accelerated Video for your VM, which is not enabled by default. Click here for more info.
当前版本
Funtoo Linux 的当前版本是 1.4,有时也被称为 1.4-release1.4-release-std
开发模式
Funtoo Linux 是一个“社区开发”的 Linux 元发行版。如果你使用 Funtoo Linux,可以通过 code.funtoo.org 对它的开发做出贡献,而不需要经过任何特殊的程序或复杂的审批过程。参见开发指南了解更多关于如何为 Funtoo 做贡献的信息。我们也有 YouTube 视频教程来帮助你入门。
Support Matrix
Please use our Support Matrix to familiarize yourself with the technologies we do -- and do not -- support.
文档样式
我们现在提供了逐节阅读和浏览安装指南的功能。在线用户可能会觉得这样更方便。
运行 Steam
我们最近发布了官方的 Steam Docker 镜像以及对 Flatpak 上 Steam 的支持——这些是官方支持的在 Funtoo 上运行 Steam 的方式。更多信息参阅 Steam
容器
官方支持 LXD 容器管理以及 Docker。请参阅 Chroot 与容器,了解一个不完整但不断增加的可用容器技术列表,以及更多文档的链接。
新的 Fchroot 工具
我们新的 fchroot 工具现在可以让你在 PC 兼容的硬件上运行 ARM 和 RISCV 环境。这是一个非常有效的工具,可以加速在资源有限的 ARM 系统上构建大型软件。参阅 code.funtoo.org pageFrankenchrootFrankenchroot/Live_NFS_Frankenchroot 了解设置信息。

现在我们已经涵盖了所有的重要信息,是时候开始安装 Funtoo Linux 了!

安装概述

这是 Funtoo 安装过程的基本概述:

Download LiveCD

为了安装 Funtoo Linux,首先需要使用基于 Linux 的 Live CD 或 U 盘来启动计算机。我们目前推荐使用 Gentoo 最小化安装 CD,因为它包含了现代的内核和最新的 UEFI 系统的启动,并且可以快速下载。它可以被刻录成 CD/DVD 或安装在 U 盘上。在这里下载它:

When installing Funtoo Linux on x86-64bit, we highly recommend the official Funtoo Linux LiveCD/LiveUSB, which can always be downloaded here:

While any modern bootable Linux image should be sufficient to install Funtoo Linux, the Funtoo LiveCD has several advantages over other options. Because it natively runs Funtoo Linux, and includes our official debian-sources kernel with very good hardware support, the hardware it supports is going to match the hardware that Funtoo Linux supports -- thus allowing you to identify any hardware compatibility issues immediately.

In addition, our LiveCD is regularly updated, and includes NetworkManager which allows the use of the easy nmtui command to configure your network. It also includes our innovative Fchroot tool, which allows you to use QEMU to "chroot" into non-x86 systems such as arm-64bit and riscv-64bit. This allows the Funtoo LiveCD to be used to even rescue and set up systems with different instruction sets!

要将其复制到 U 盘上进行启动,使用以下命令:

root # dd if=install-amd64-minimal-20210103T214503Z.iso of=/dev/sdx bs=4k status=progress

当然,需要将 /dev/sdx 改为指向系统中 U 盘的块设备。

接入网络

关于从 LiveCD 设置接入网络的步骤,请参见 Funtoo:New Install Experience/LiveCD 页面。

远程安装

Alternatively, you can log into your bootable environment over the network via SSH to perform the install from another computer, and this may be more convenient way to install Funtoo Linux.

First ensure that sshd is running. You may need to start sshd as follows:

root # /etc/init.d/sshd start

如果要远程完成安装,方法如下。首先,需要确保可启动 CD/USB 镜像已正常连接网络。然后,需要设置一个root密码:

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


输入密码后,现在需要确定可启动系统的 IP 地址,然后就可以使用 ssh 连接到它。要确定 LiveCD 当前使用的 IP 地址,输入 ifconfig

root # ifconfig

另外,还可以通过 iproute2 ip 工具确定 IP 地址:

root # ip addr show

One of the interfaces should have an IP address (listed as inet addr:) from your LAN. You can then connect remotely, from another system on your LAN, your bootable environment, and perform steps from the comfort of an existing OS. On your remote system, type the following, replacing 1.2.3.4 with the IP address of the LiveCD. Connecting from an existing Linux or MacOS system would look something like this:

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

如果想从现有的微软 Windows 系统进行远程连接,则需要下载一个 Windows 的 SSH 客户端,比如 OpenSSH

通过 SSH 登录后,现在已经远程连接到 LiveCD,可以进行安装步骤。

Prepare Disk

在本节中,需要选择一种用于启动和分区的磁盘格式—— MBR 或 UEFI/GPT。如果你不熟悉这些选项之间的差异,请查看我们的磁盘格式页面,了解每个选项的概述和权衡。一般来说,对于 2TB 以下的系统盘,选择传统的 MBR 方法通常是安全的,而且大多数现代 PC 系统既支持 MBR 也支持 UEFI 启动。

MBR is the traditional way of booting a PC. It works by installing executable code on the boot sector of your hard drive, which starts the boot process. When you use MBR to boot, you must have BIOS booting enabled in your BIOS, use traditional MBR partitions on your disk which are created using the fdisk tool.

UEFI is the more modern way to boot a PC. It works using a boot loader that is built into your computer. Boot entries are created and stored in your computer's non-volatile memory. When you use UEFI to boot, you must have UEFI enabled in your BIOS, and use more modern GPT partitions which are created using the gdisk tool.

Generally, it's usually safe to pick the legacy MBR method for system disks under 2TB in size and most modern PC systems support MBR as well as UEFI booting.

   Note

For more information on differences between MBR and UEFI, see our Disk Formats page for an overview of each option and the trade-offs.

但首先......

在对磁盘进行任何操作之前,请确保你的分区是正确的。使用 lsblk 命令查看系统中所有块设备的列表,以及这些块设备上的分区:

root # lsblk
NAME          MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda             8:0    0  1.8T  0 disk 
├─sda1          8:1    0  512M  0 part 
├─sda2          8:2    0    8G  0 part [SWAP]
└─sda3          8:3    0  1.8T  0 part 
  ├─main-root 254:0    0  500G  0 lvm  /
  └─main-data 254:1    0  1.3T  0 lvm  /home
   Note

If you're not sure which disks are which, you can use lsblk -o MODEL,NAME,SIZE to show the device models matching the /dev/sd? names.

Make sure you will not be overwriting any important data and that you have chosen the correct /dev/sd? device. Above, you can see that SATA disk sda contains three partitions, sda1, sda2 and sda3, and that sda3 contains LVM volumes. If you are using an NVME disk, then you may see nvme0n1 as your disk, and your partitions (if any exist yet) will be named nvme0n1p1, nvme0n1p2, etc. If you are installing on microSD Card for Raspberry Pi, your disk will likely be mmcblk0 and partitions will have suffixes p1, p2, etc.

一旦你仔细检查了目标块设备,并确定将会对磁盘进行正确的分区,就继续下一步。

MBR Partitioning

传统(BIOS/MBR)方法

   Note

如果使用 BIOS 启动,并且 Funtoo LiveCD 初始启动菜单是浅蓝色的,就使用这个方法。如果要使用 UEFI/GPT 磁盘格式,那么请至下一节继续。

首先,需要找到正确的硬盘来进行分区。尝试下列命令验证 /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

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

现在,建议擦除磁盘上任何现有的 MBR 或 GPT 分区表,否则可能会在启动时混淆系统的 BIOS。我们使用 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

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

清空分区表:

Command (m for help): o ↵

创建分区 1(引导)

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

创建分区 2(交换)

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

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

GPT Partitioning

UEFI/GPT 方法

   Note

如果对使用 UEFI 启动感兴趣,并且 Funtoo LiveCD 初始启动菜单是黑白的,或者系统启动时没有启动菜单,请使用此方法。如果是淡蓝色的,这个方法将不起作用。相反,使用上一节的说明,然后跳过这一节,或者先在 UEFI 模式下重新启动 LiveCD。

   Note

你可以在 GPT 分区表中建立传统模式,但它需要一个 BIOS 启动分区,参见Talk:Install/GPT_Partitioning

创建 GPT 分区表的 gdisk 命令如下。根据需要调整大小,尽管这些默认值对大多数用户都适用。启动 gdisk

root # gdisk /dev/sda

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

创建一个新的空分区表(这将会在保存时擦除磁盘上的所有数据):

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

创建分区 1 (引导)

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

创建分区 2(交换):

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

创建分区 3(根目录):

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

(可选)如果希望使用磁盘标签而不是 /dev/sdXX(其中 XX 是磁盘和分区编号),请这样做:

Command: c ↵
Partition Number: 1
Enter name: BOOT 
Command: c ↵
Partition Number: 2
Enter name: swap
Command: c ↵
Partition Number: 3
Enter name: ROOT

Along the way, you can type "p" and hit Enter to view your current partition table. If you make a mistake, you can type "d" to delete an existing partition that you created. When you are satisfied with your partition setup, type "w" to write your configuration to disk:

将分区表写入磁盘:

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

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

现在,GPT/GUID 分区已经创建,并将在 Linux 下显示为以下“块设备”:

  • /dev/sda1,将用于存放 /boot 文件系统,
  • /dev/sda2,将用于交换空间,以及
  • /dev/sda3,将存放根文件系统。
   Tip

可以通过运行命令 lsblk 来验证上面的块设备是否正确创建。

Creating Filesystems

   Note

本节同时覆盖 BIOS 和 UEFI 安装两种方法。不要跳过!

Before your newly-created partitions can be used, the block devices that were created in the previous step need to be initialized with filesystem metadata. This process is known as creating a filesystem on the block devices. After filesystems are created on the block devices, they can be mounted and used to store files.

Let's keep this simple. Are you using legacy MBR partitions? If so, let's create an ext2 filesystem on /dev/sda1:

root # mkfs.ext2 /dev/sda1

如果在 UEFI 中使用 GPT 分区,或者为 Raspberry Pi 安装,需要在第一个分区上创建一个 vfat 文件系统。在 Raspberry Pi 的情况下,这将是 mmcblk0p1

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

现在,创建一个交换分区。Funtoo Linux 会将此分区用于基于磁盘的虚拟内存空间。

由于交换分区不是用来存储文件的,因此无需对于交换分区创建文件系统。但是需要使用 mkswap 将其初始化。由于之后的安装过程中需要交换分区,所以要运行 swapon 命令使交换分区立即在 Live CD 环境生效:

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

根目录文件系统

Now, we need to create a root filesystem. This is where Funtoo Linux will live. We generally recommend ext4 or XFS root filesystems. Keep in mind that some filesystems will require additional filesystem tools to be emerged prior to rebooting. Please consult the following table for more information:

文件系统推荐作为根文件系统?安装所需的额外工具
ext4
XFSsys-fs/xfsprogs
reiserfs是——可能需要启用内核支持sys-fs/reiserfsprogs
zfs - 仅限高级用户sys-fs/zfs
btrfs - 仅限高级用户sys-fs/btrfs-progs
   Important

我们不建议用户将 ZFS 或 BTRFS 设置为他们的根文件系统。这会复杂得多,而且通常没有 必要。相反,选择 XFS 或 ext4。我们确实支持 ZFS 或 BTRFS 作为非 root 文件系统,这在配置上要简单得多。在完成设置 Funtoo Linux 系统后,看 ZFSBTRFS 来配置 ZFS 或 BTRFS,用于 额外的二级存储。

如果不确定,就选择 ext4。下面是如何创建一个根目录 ext4 文件系统:

root # mkfs.ext4 /dev/sda3

……这里是如何创建一个 XFS 根目录文件系统,如果你喜欢使用 XFS 而不是 ext4:

root # mkfs.xfs /dev/sda3

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

Additional Filesystems

   Note

这对树莓派系统非常有用!

You may want to create additional filesystems for various parts of your Funtoo filesystem tree. It is not uncommon to place /home or /var on separate filesystems.

For Raspberry Pi, you may not have a lot of spare room on the card depending on the capacity of your microSD card, and it may make a lot of sense to put the entire /var filesystem on an external hard drive or solid state disk. This will not only ensure you don't run out of disk space, but can also improve performance since writes to the microSD card typically aren't that fast.

To do this, you will want to use fdisk or gdisk to create a partition on your external drive, and then use the mkfs.xfs or mkfs.ext4 commands to create a filesystem on the new partition. We will mount this new filesystem in the next step prior to extracting the stage3 tarball.

Mounting Filesystems

按照如下的步骤挂载新创建的文件系统,创建 /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/var),应该现在就挂载它们,以便在解压 stage3 时(将在稍后的步骤中进行)这些文件系统将被填充必要的文件。这可以通过以下方式完成:

root # mkdir /mnt/funtoo/var
root # mount /dev/sdb1 /mnt/funtoo/var

Setting the Date

   Important

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

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

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

If the date and/or time need to be corrected, do so using date MMDDhhmmYYYY, keeping in mind hhmm are in 24-hour format. The example below changes the date and time to "July 16th, 2011 @ 8:00PM" UTC:

root # date 071620002011
Fri Jul 16 20:00:00 UTC 2011

Once you have set the system clock, it's a very good idea to copy the time to the hardware clock, so it persists across reboots:

root # hwclock --systohc

Download and Extract Stage3

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

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

What Subarch?

From the subarch list at Subarches, choose your desired level of optimization. A system built specifically for your CPU will run faster than a less-optimized system. For a modern Intel or AMD system, it is safe to pick the exact optimization level for your particular family of CPU. This will offer the best possible performance.

If you are using a virtualization technology to run Funtoo Linux and your VM may be used on 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 more generic image if it may run on both AMD and Intel processors.

Once you have found the appropriate subarch at Subarches, you will likely have a few installation images to choose from. This next section will help you understand which one to pick.

Which Image?

Our desktop environment stages (GNOME, Cinnamon, etc.) now support seamless installation on VMware Workstation Pro virtual machines. We highly recommend you enable 3D Accelerated Video for your VM, which is not enabled by default. Click here for more info.

You can always manually choose an installation image via https://build.funtoo.org as well as using the Subarches page. Here is some guidance on choosing the best .tar.xz image for download. When choosing an image:

Pick next.
This is next release of Funtoo Linux, our current release.
Pick the subarch for the CPU family of the system you are installing on.
This will provide the best performance.
Choose stage3 for...
The stage3 is a more traditional, minimal and non-graphical installation of Funtoo. You will then build your system up to your desired state using emerge.
Choose gnome for...
The gnome installation image, if available, includes the full GNOME environment as well as Firefox already optimized for your hardware. You can then continue to further customize your system after installation. See the Desktop Environments section of our Support Matrix for more desktop options.
The lxd image for...
The lxd image is for use with LXD, and is not used for installing directly on a desktop or laptop, so you should not select this option for regular installs. To install, first download and then lxc image import <name>.tar.xz --alias funtoo and then you can lxc launch funtoo my_container.

下载 Stage3

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

   Note

If you are using the Funtoo LiveCD, you can use a text-based browser to download your preferred stage. Type links https://build.funtoo.org rather than the wget command below. Hit enter to select the appropriate directories and stage3.

root # cd /mnt/funtoo
root # wget https://build.funtoo.org/1.4-release-std/x86-64bit/generic_64/stage3-latest.tar.xz

验证下载的压缩包

Funtoo Linux 的 stage 压缩包是由构建服务器使用 GPG 签署的。在可能的情况下,验证下载文件的真实性和完整性是一个好的做法。关于如何导入和信任 GPG 密钥的说明,查看our wiki page about GPG signatures

然后,你可以下载 stage3 的 GPG 签名,并使用 gpg --verify 命令来验证压缩包:

root # wget https://build.funtoo.org/1.4-release-std/x86-64bit/generic_64/stage3-latest.tar.xz.gpg
root # gpg --verify stage3-latest.tar.xz.gpg stage3-latest.tar.xz

一旦下载并验证了 stage,用下面的命令解压缩内容,并代入 stage 3 压缩包的实际名称:

root # tar --numeric-owner --xattrs --xattrs-include='*' -xpf stage3-latest.tar.xz
   Important

使用上述所有选项是非常重要的。详情请看下文。

下面是 tar 的选项的作用:

--numeric-owner
Without this option, tar will map ownership and group ownership based on the UID to user and GID to group mappings as defined on the LiveCD. We don't want this -- we want the numeric values of the UIDs and GIDs in the tarball to be preserved on disk, so when your Funtoo Linux system boots, the UIDs and GIDs are set correctly for Funtoo. That is what this option tells tar to do.
--xattrs --xattrs-include='*'
Funtoo Linux uses filesystem extended attributes to set Linux capabilities, which allow for certain programs such as ping to have enhanced privileges without having to be fully 'suid root'. Even with the -p option, tar will not restore extended attributes we need unless these two options are specified.
-xpf
This instructs tar to extract (x), preserve regular permissions and ownership (p), and use the filename (f) specified.

Chroot into Funtoo

要安装 Funtoo Linux,首先要使用 chroot 命令。Chroot 命令将“切换到”新的 Funtoo Linux 系统中,所以你在运行 "chroot" 后执行的命令将在你新提取的 Funtoo Linux 系统中运行。

root # fchroot /mnt/funtoo
fchroot #

The fchroot command will take care of all necessary steps to enter into your new Funtoo Linux system, as well as clean up things when you exit the fchroot by typing exit or ctrl-D.

If you are using another LiveCD or USB media to install Funtoo, you can manually chroot by using the following set of commands:

在进行 chroot 之前,需要做一些设置 chroot 环境的工作,你需要在新系统中挂载 /proc/sys/dev。使用以下命令来完成:

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

对于使用 64 位 Live CD 安装 32 位系统用户请注意:一些软件使用 uname -r 来检查系统是 32 位或是 64 位。你可能需要将 linux32 指令附加在 chroot 指令中执行来解决这个问题,但通常情况下是不需要的。

   Important

如果你得到了 "chroot: failed to run command `/bin/bash': Exec format error" 这个错误,多数情况是尝试在 32 位内核中执行 64 位指令。确保在启动临场 CD 时选择了正确的内核类型。

在 chroot 中更改默认的命令提示符也是一个好主意。这样可以避免在你必须更换终端时出现混乱。使用这个命令:

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

在 chroot 中测试互联网名称的解析:

chroot # ping -c 5 google.com

如果不能 ping,请确保 /etc/resolv.conf 在其 nameserver 设置中为可到达的命名服务器指定一个有效的 IP 地址。

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

Download Portage Tree

现在是时候安装 Portage 仓库了,它包含了包脚本 (ebuilds),告诉 portage 如何构建和安装成千上万个不同的软件包。要创建 Portage 仓库,只需在 chroot 中运行 ego sync。这将会自动克隆 GitHub 中的 portage 树和所有工具包:

chroot # ego sync

Configuration Files

正如对任何一个 Linux 发行版期盼的那样,Funtoo Linux 有一套自己的配置文件。为了确保 Funtoo Linux 成功启动,你必须编辑的文件是 /etc/fstab。其他的文件是可选的。

使用 Nano

Chroot 环境下包含的默认文本编辑器是 nano。若要编辑文本,可以按照下述方法使用 Nano:

chroot # nano -w /etc/fstab

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

When in the editor, you can use arrow keys to move the cursor, and common keys like backspace and delete will work as expected. To save the file, press Control-X, and answer y when prompted to save the modified buffer if you would like to save your changes.

We will edit the /etc/fstab file later, when we set up the boot loader.

配置文件

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 NO - not required or recommended Unlike Gentoo, it is normal and correct for this file to be empty in Funtoo Linux, as settings have been migrated to our enhanced profile system. Adding settings from this file will cause your system to be considered a non-standard setup and not officially supported. If you feel you need to add something to this file, be sure to ask on Discord for guidance. You probably don't.
/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/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/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.
/etc/conf.d/swap Optional When using a swap file that is not on the root filesystem, localmount service must be configured to be a dependency of swap service.
profiles Optional Some useful portage settings that may help speed up intial configuration.

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

继续安装步骤。使用 nano -w <name_of_file> 来编辑文件 -- "-w" 指令会禁用自动换行,这样让编辑配置配置文件更顺手。你可以从示例文件中复制粘贴。

   Warning

在重启之前编辑 /etc/fstab 是很重要的!你需要修改 fstype 栏,让他们与你使用 gdiskfdisk 创建的文件系统和分区相匹配。跳过这个步骤有可能会让 Funtoo Linux 无法正确启动。

/etc/localtime

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

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

上面的命令会将时区设置为 Mountain Standard Time(包括夏令时)。用 ls /usr/share/zoneinfo 命令来显示可用的时区。其中也有子目录包含了以地区描述的时区。

/etc/conf.d/hwclock

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

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

本地化

默认情况下,Funtoo Linux 被配置为启用 Unicode (UTF-8) ,并且对应了美国英语的本地化以及键盘布局。如果你想要将你的系统配置为非英语的环境和键盘布局,参见 Funtoo Linux 本地化

Introducing Portage

Portage,是 Funtoo Linux 的包管理器,其中包含了一个叫做 emerge 的命令,这个命令可以用来从源码构建并安装包。也能同时管理好所有的依赖关系。你可以按照下面的说明调用 emerge:

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 # ego 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.

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 dependency of another package. If this behavior is desired, you call emerge like this:

chroot # emerge -1 packagename

高级用户可以看看 Emerge 的维基页面。

Prepare Disk

Funtoo Linux stage3 包含一个预建的 debian-sources 内核,使安装更快,更容易。要查看预装的内核版本,输入:

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

*  sys-kernel/debian-sources
      Latest version available: 5.9.6_p1
      Latest version installed: 5.9.6_p1
      Size of files: 118,723 kB
      Homepage:      https://packages.debian.org/unstable/kernel/
      Description:   Debian Sources (and optional binary kernel)
      License:       GPL-2

固件

此时,安装最新的 sys-kernel/linux-firmware 包是明智之举,因为各种驱动都依赖于固件 blobs 和指令。如果没有固件,Wi-Fi 卡、图形卡、网卡等硬件将无法正常工作或根本无法工作。如果使用 stage3 镜像,请执行以下步骤进行安装。如果使用 linux-firmware 镜像,则 linux-firmware 已经安装完毕。

chroot # emerge -av linux-firmware

Bootloader

How Booting Works

In order for Funtoo Linux to boot, it must detect the boot filesystem, root filesystem and swap. The most reliable way to do this is to use the UUID, or unique identifier, of the partitions holding these filesystems. We will use these UUID values in the /etc/fstab, which we will set up next.

The UUID allows Linux to find the right filesystem, even if it detects the disks differently or you move them around in your computer. Funtoo Linux uses a Linux kernel and initial RAM disk to boot, and to get everything set up, we need to set up /etc/fstab correctly, and then install the GRUB boot loader -- and there are two different commands for this, depending on whether you are using MBR or UEFI. Then, finally, we run ego boot update which is a Funtoo command that configures everything for us.

Label partitions

To see the UUIDs for your existing filesystems, type the following command:

root # ls -l /dev/disk/by-uuid/
total 0
lrwxrwxrwx 1 root root 10 Jan 27 13:42 6883428138129353569 -> ../../sdb1
lrwxrwxrwx 1 root root 15 Jan 27 13:42 CE4B-855D -> ../../nvme0n1p1
lrwxrwxrwx 1 root root 15 Jan 27 13:42 ac280eb5-1ea7-4742-9e71-9c7addd35c54 -> ../../nvme0n1p2
lrwxrwxrwx 1 root root 15 Jan 27 13:42 e5a76428-8b3f-4349-81af-cbe29c7f7d09 -> ../../nvme0n1p3

The UUIDs are listed to the left-hand side of the ->. Use these values for setting up the /etc/fstab file, below.

/etc/fstab

/etc/fstab is used by the mount command which is run when your system boots. Lines in this file inform mount about filesystems to be mounted and how they should be mounted. In order for the system to boot properly, you must edit /etc/fstab and ensure that it reflects the partition configuration you used earlier in the install process. If you can't remember the partition configuration that you used earlier:

chroot # nano -w /etc/fstab
   /etc/fstab - An example fstab file
UUID=CE4B-855D                                  /boot         vfat    noauto,noatime  1 2
UUID=ac280eb5-1ea7-4742-9e71-9c7addd35c54       none          swap    sw              0 0
UUID=e5a76428-8b3f-4349-81af-cbe29c7f7d09       /             ext4    noatime         0 1
   Important

Be sure to use the actual UUIDs from your system, not the example values above!

   Note

If you mounted a /var or /home partition, add them to your fstab, or your system may not boot correctly.

boot.conf

/etc/boot.conf controls boot loader configuration in Funtoo and is used by ego boot. The default configuration is probably fine for you, so most can skip to the appropriate "GRUB Install" section, later on this page.

Here is what is in the file by default:

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

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

"Funtoo Linux (nomodeset)" {
	kernel kernel[-v]
	initrd initramfs[-v]
	params += real_root=auto rootfstype=auto nomodeset
}

如果你需要自定义或者是从一个非默认的内核启动,请阅读 man boot.conf 来获得对你用帮助的信息。

nomodeset

You will notice after booting that you there will be a boot option in the GRUB menu for a "nomodeset" mode. We don't recommend you use this mode by default but it is available to you for a couple of good reasons:

  • For users with HiDPI (4K+) displays, especially laptops: If you have not set up a graphical environment, when the kernel automatically changes graphics modes, the console font can be tiny and unreadable.
  • For users with incompatible graphics cards: Some graphics cards don't handle mode setting properly and this can result in a blank screen after reboot. Use this boot option as a temporary workaround.

To use the nomodeset option, simply select that option from the GRUB menu when your system boots.

rootwait

If you are using a root partition on an nvme device, add the rootwait kernel parameter to force the kernel to wait for it to asynchronously initialize or the kernel will panic on some hardware.

Intel Microcode

ego boot will ensure that you have the most recent Intel CPU microcode installed on your system if you emerge the following packages. These will be merged for you already if you are using a desktop stage3:

chroot # emerge -av intel-microcode iucode_tool

This is not necessary for AMD systems.

GRUB Install: Old School (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/sdX

GRUB Install: New School (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.

For x86-64bit systems:

chroot # mount -o remount,rw /sys/firmware/efi/efivars
chroot # grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id="Funtoo Linux [GRUB]" --recheck

For x86-32bit systems:

chroot # mount -o remount,rw /sys/firmware/efi/efivars
chroot # grub-install --target=i386-efi --efi-directory=/boot --bootloader-id="Funtoo Linux [GRUB]" --recheck

Ego!

Now, let's run Funtoo's ego boot update command to get everything configured. This will detect the current kernel(s) on your system and create the necessary GRUB boot entries to get your system booted:

chroot # ego boot update

You only need to run grub-install when you first install Funtoo Linux, but you need to re-run ego boot update every time you modify your /etc/boot.conf. When you emerge updated kernels, ego boot update will be run automatically as part of the install process. This will regenerate /boot/grub/grub.cfg so that you will have new kernels available in your GRUB boot menu upon your next reboot.

Post reboot UEFI troubleshooting

In case UEFI NVRAM boot entry is missing in BIOS and grub does not start you can try moving an already installed GRUB EFI executable to the default/fallback path

chroot # mv -v '/boot/EFI/Funtoo Linux [GRUB]' /boot/EFI/BOOT
chroot # mv -v /boot/EFI/BOOT/grubx64.efi /boot/EFI/BOOT/BOOTX64.EFI

First Boot, and in the future...

OK -- you are almost ready to boot!

Network

重启系统之前,要确保能够连接网络。可以从 NetworkManager,dhcpcd,Funtoo Linux Networking 脚本这三个中自由选择。下面讲解如何通过想要设置的网络类型选择合适的方式。

Wi-Fi

   Note

If using the gnome or other desktop install image, linux-firmware and NetworkManager are already installed and available. You can use nmtui to get Wi-Fi going if you need network connectivity prior to getting X and GNOME fully up and running. In addition, desktop stage3's have ZeroConf/Bonjour multicast DNS lookups enabled by default. Both these things will not be set up yet if you are using the basic stage3 image.

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 if you have not done so already:

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:

chroot # nmtui

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

桌面(有线 DHCP 连接)

对于一个使用 DHCP 进行有线网络连接的家庭电脑或者是工作站,最简单有效的启用网络方式,就是将 dhcpcd 添加至默认的 runlevel:

chroot # rc-update add dhcpcd default

重启系统后,dhcpcd 会在后台运行,管理所有的网络接口,并且通过 DHCP 服务从 DHCP 服务器获得网络地址。

如果你的 DHCP 上游的服务器是 dnsmasq,那么它可以设置为通过 MAC 地址给终端分配地址,这样就能使用 DHCP 上的服务器。

服务器(静态 IP)

For servers, the Funtoo Linux Networking scripts are the supported option for network configuration, and they have their own documentation. 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

修改以主机名开头的行。保存文件,下一次 Funtoo Linux 启动的时候就将使用新的主机名。

   Warning

Hostnames can be up to 63 characters long and may use the following characters: a-z, 0-9 and hyphens (-). However, the hyphen may not be the first or last character.

Finishing Up

设置根用户密码

重启前一定要设置好 root 密码,这样才能登录。

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

创建常规用户

It's also a good idea to create a regular user for daily use. If you're using GNOME, this is a requirement as you cannot log in to GDM (The GNOME Display Manager) as root. This can be accomplished as follows:

chroot # useradd -m drobbins

You will also likely want to add your primary user to one or more supplemental groups. Here is a list of important groups and their effect:

GroupDescription
wheelAllows your user account to 'su' to root. Recommended on your primary user account for easy maintenance. Also used with sudo.
audioAllows your user account to directly access audio devices. Required if using ALSA; otherwise optional.
videoAllows your user account to directly access video devices. Required for certain video drivers and webcams.
plugdevAllows your user account work with various removable devices. Allows adding of a WiFi network in GNOME without providing root password. Recommended for desktop users.
portageAllows extended use of Portage as regular user. Recommended.

To add your user to multiple groups, use the usermod command, specifying a complete group list:

chroot # usermod -G wheel,audio,plugdev,portage drobbins

和 root 账户一样,不要忘记设置密码。

chroot # passwd drobbins
New password: **********
Retype new password: **********
passwd: password updated successfully

安装熵发生器

Linux 内核使用各种来源,如用户输入来产生熵,而熵又用于产生随机数。加密通信可能会使用大量的熵,往往你的系统产生的熵量是不够的。这通常是无头服务器系统上的问题,其中也可以包括 Raspberry Pi 等 ARM 系统,并可能导致比正常的 ssh 连接更慢等问题。

To compensate for this, a user-space entropy generator can be emerged and enabled at boot time. We will use haveged in this example, although others are available, such as rng-tools.

chroot # emerge haveged
chroot # rc-update add haveged default

Haveged will now start at boot and will augment the Linux kernel's entropy pool.

重启系统

现在退出 chroot 环境,卸载 Funtoo Linux 分区和文件,重启电脑。重启后,GRUB 启动引导器会启动,并加载 Linux 内核及 initramfs,之后系统会开始启动。

离开 chroot 环境,将当前工作目录更改为 /mnt,卸载 Funtoo 分区,并且重启电脑。

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

If you used manual chroot steps, you can use the following sequence of commands prepare to restart:

chroot # exit
root # cd /mnt
root # umount -lR funtoo

Now, you are ready to reboot into Funtoo:

root # reboot

现在应该可以看到已经系统重启,过几秒 GRUB 引导器界面会显示,接下来能看到 Linux 内核以及 initramfs 加载。之后,应该可以看到 Funtoo Linux 启动。并且应该看到 login: 提示。至此即成功安装了 Funtoo Linux。

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. At the moment, all Funtoo Linux builds use the funtoo-current build profile.
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.

   Note

It's recommended that your run this command now, particularly if you are using the gnome install image, in order to familiarize yourself with the current profile settings on your system.

root # 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.epro list
Change the system flavor.epro flavor desktop
Add a mix-in.epro mix-in +gnome

Graphics Settings

   Note

The gnome install image will have additional graphic support already enabled for you, but you will still need to set up X and your display manager (covered in the next section.)

Funtoo Linux 1.4 features the following mix-ins to allow simplified configuration of your graphics settings. It's recommended to use these mix-ins rather than manually placing USE and VIDEO_CARDS settings in /etc/make.conf. You can learn more about Funtoo's graphics configuration and the design approach of these settings at the make.conf/VIDEO_CARDS page.

Funtoo Graphics Mix-Ins

gfxcard-intel
This mix-in is equivalent to gfxcard-intel-classic or gfxcard-intel-iris, depending on the release you're running. Currently, it defaults to gfxcard-intel-classic on 1.4-release and to gfxcard-intel-classic on Next release. Do not enable more than 1 gfxcard-intel* mix-in at the same time. The result is not what you might expect.
gfxcard-intel-classic
This mix-in enables Intel graphics support based on the older i915 mesa driver (not to be confused with the i915 kernel driver). Choose this if you have a Gen3 or older chipset.
gfxcard-intel-iris
This mix-in enables Intel graphics support for cards with glamor modesetting support (drivers i965 or iris), including support OpenGL ES (>=Gen4) and OpenCL and Vulkan (>=Gen7) and video acceleration where available. If your card is >=Gen5, do an emerge libva-intel-driver or emerge media-libs/libva-intel-media-driver (for >=Gen8) afterwards to ensure you have full video acceleration support.
gfxcard-amdgpu
This mix-in enables support for modern Radeon cards, Southern Islands -- GFX Core 6 (see this x.org reference) and greater. Includes Vulkan and video acceleration where available. Drivers are built for both the Gallium framework (modern replacement for DRI framework) and DRI framework. Glamor is used to accelerate 2D operations.
gfxcard-radeon
This mix-in enables support for modern Radeon cards, R600 through Northern Islands -- GFX Core 4 and 5 (see this x.org reference). Drivers are built for the Gallium framework (modern replacement for DRI framework) as well as DRI framework. Glamor is used to accelerate 2D operations.
gfxcard-older-ati
Use this mix-in to enable support for R300 up to (but not including) R600 Radeon cards -- -- GFX Core 3 (see this x.org reference). DRI as well as Gallium-based drivers are enabled.
gfxcard-ancient-ati
Use this mix-in to enable support pre-R300 cards -- GFX Core 1 and 2 (see this x.org reference). These drivers are DRI-based.
gfxcard-nvidia
Use this to enable support for proprietary NVIDIA drivers. You will also need to emerge nvidia-kernel-modules, blacklist nouveau and add yourself to the video group. See this documentation for more details. Note that Funtoo now has two catpkgs for NVIDIA proprietary graphics -- nvidia-drivers and nvidia-kernel-modules -- to aid the use of NVIDIA acceleration on containers.
gfxcard-nvidia-legacy
Proprietary NVIDIA drivers like above, but the legacy version of the driver that supports older hardware. See https://www.nvidia.com/en-us/drivers/unix/ and browse the specific driver version that emerge is installing to get detailed compatibility information.
gfxcard-nouveau
Use this mix-in to enable support for Open Source nouveau drivers.

Enable the appropriate graphics options for your hardware as follows:

root # epro mix-in +gfxcard-intel

完成后,继续在系统上根据需要设置 X、KDE、GNOME 或其他桌面环境。更多信息参见下一节。

All Done!

如果你是第一次接触 Funtoo Linux 和 Gentoo Linux,请查看 Funtoo Linux First Steps,它将帮助你熟悉你的新系统。

   Important

If you are using the gnome install image, please see the "A few finishing touches" section of the GNOME setup docs in order to continue setting up your graphical environment.

你可能还对以下资源感兴趣:

  • Chroot_and_Containers setting up 32 bit containers to run wine, and STEAM.
  • Security - tips for securing your system
  • Btrfs - a simple guide for setting up btrfs on your new Funtoo Linux system.
  • official documentation, which includes all docs that we officially maintain for installation and operation of Funtoo Linux.

We also have a number of pages dedicated to setting up your system. See the First Steps Category for a list of these pages.

If your system did not boot correctly, see Installation Troubleshooting for steps you can take to resolve the problem.