常见问题

From Gentoo Wiki
Jump to:navigation Jump to:search
This page is a translated version of the page FAQ and the translation is 60% complete.
Outdated translations are marked like this.

常见问题页面汇集了许多关于Gentoo的常见问题,以及它们相应的答案。

请注意,本文档只是一些常见问题的“快速参考”——其中许多问题在官方Gentoo 文档中已经有了更详细的答案。

提示
阅读Gentoo 文档,你会了解到如何使用Gentoo,甚至推广到所有的GNU/Linux。主体的Gentoo 文档在首页百科手册上。更加详细的内容请见man页面info 页面/usr/share/doc/和上游消息。许多指令支持--help 或者 -h 帮助指令。

这些问题收集于 gentoo-dev 邮件列表和 Internet Relay Chat (IRC) 上的 Gentoo 相关频道。

另请参阅
See also the Portage FAQ for frequently asked questions about the package manager. There is also a FAQ section in the Handbook. For frequently asked questions relating to the documentation wiki and editing the wiki, see the wiki FAQ. There are also some architecture-specific FAQs, such as: AMD64/FAQ, PPC/FAQ, MIPS/FAQ, and Alpha/FAQ.
另请参阅
See the benefits of Gentoo article, to see what makes Gentoo stand out from other distributions. See the cheat sheet for information about common usage. See the help pages for information on editing and contributing to the wiki.

关于 Gentoo

另请参阅
Please note that there are several pages that provide information about Gentoo Linux. See the page on the website about Gentoo, the philosophy of Gentoo, and the article on the benefits of Gentoo. The handbook also has a section about Gentoo.

Gentoo如何发音,它是什么意思?

Gentoo (/ˈdʒɛntuː/) 发音为 "gen-too",其中的"g"发清辅音,与单词 "gentle" 一样。

Gentoo Linux 发行版的名字来自于Gentoo 企鹅,它的学名是 Pygoscelis papuaPygoscelis papua 这个名字是福克兰群岛的居民给企鹅起的。

什么使 Gentoo 与众不同?

Gentoo使用了与bsd的ports系统类似的portage系统 Portage 。Portage是一种软件包管理 系统,它使得在Gentoo系统中软件的安装与维护以及更新十分灵活。Portage提供了编译时选项(通过 USE标志 ),条件依赖,通过沙盒安全地安装软件包,可按需求更改的默认值(得益于system profiles),以及许多 特性 中的 配置文件保护 功能。所有这些功能结合在一起,使 Gentoo 成为一个适应性很强的操作系统,可以在需要时方便地针对任何特定用途进行定制,但是当使用默认配置时,将产生一个简单的、“有合理默认值”的环境。

默认情况下,Gentoo 从源代码构建(编译)和安装系统软件包,特别是用户选择的配置和优化 - 其中许多仅在“编译时”可用。 Gentoo 提供对低级参数(编译器编译参数、体系结构选择、基本子系统选择等)的非常精细的控制,无论是全局系统还是单个包(如果需要)。

Gentoo 提供许多核心(系统)软件替代方案,允许用户根据自己的需要和偏好轻松调整安装 - 事实上,用户几乎可以完全控制安装或忽略哪些软件包。 这是与许多其他发行版的关键区别,这些发行版通常围绕特定子系统构建,无法被替换。因为Gentoo 的灵活性,其没有“变种”、“版本”、“特供版”之说。——因为并不需要,所有东西都可以在默认安装时根据USE 变量而调整。

附注
The depth of choice of core software, target architectures, and low-level optimization configuration, is why Gentoo is called a meta-distribution.

Gentoo strives to do things in the simplest possible way, and core Gentoo principles and procedures are easy to understand and master, given just a little effort. The relatively small investment to learn how to use Gentoo will reap dividends for anyone who is to become a substantial user of a Unix(like) operating system. Gentoo may require some reading and a little thought to understand how to use it, but the payoff from the power gained by the new user is considerable.

gentoo开发活跃,整个开发采用快速的开发模式:软件包补丁被迅速集成到主线开发树;文档基本每天更新;portage特性添加频繁;官方发布一年更新两个版本。

提示
Do not confuse rolling release with bleeding edge. Gentoo updates may be fast-paced, but Gentoo is a stable distribution, with exceptional reliability. All packages are fully tested, and must meet high standards. Quality control is a fundamental priority for the project at large.

安装

另请参阅
参见installation一文了解安装流程。

使用'-O9 -ffast-math -fomit-frame-pointer' 优化选项后系统变得不可用,发生了什么?

While Portage optimizes compilation to a specific processor according to the CFLAGS/CXXFLAGS setting, anything other than the defaults for a given processor risk issues and even performance loss. The goal of the Gentoo project has never specifically been to permit low level optimization, even if its architecture does lend itself to this.

Any required CFLAGS should be set on a per-package basis, system-wide optimization above defaults is not recommended.

-O2 标志是可以一直使用的最高标志。当前版本的 gcc 不支持任何 -O3 标志。过于激进的优化选项会使编译器将汇编代码精简至无法正常工作的地步。

在报告bug前,尝试对 CFLAGS/CXXFLAGS 使用 -O2 -march=native 重新编译。

更多细节请参照 GCC 优化 文章。

如何修改root或其它用户的密码?

使用passwd命令修改当前登录用户的密码,root用户通过passwd username可修 改其它用户的密码,man passwd查看手册了解其它选项和设置。

如何添加普通用户?

命令"useradd larry"将添加普通用户larry。然而,这种方法没有赋予用户足够 的权力来正常使用系统,推荐使用:

root #useradd -m -G users,audio,wheel larry

此步骤将会创建名为 "larry" 的用户。-m 选项会创建 home 目录。-G 选项会将用户加入到制定组里:

  • users which is the standard group for interactive users on the system
  • audio which allows the user to access sound devices
  • wheel which allows the user to execute the su command to gain root privileges (if they know the root password)

为什么用户不能 su 到 root?

出于安全考虑,只有属于 wheel 用户组的用户才能使用 su 切换至 root。以 root 身 份执行以下命令,将用户添加到 wheel 用户组:

root #gpasswd -a <username> wheel

不重装系统,如何将 Gentoo 从一个版本升级至另一个版本?

There are no Gentoo releases, packages are updated continually: it is a rolling release distribution (not to be confused with "bleeding edge" - Gentoo is stable by default).

Gentoo packages get updates every day, and though important core packages will be updated from time to time, and new profiles created, there are no specific events that could be termed versions, releases, editions, variants etc. Each time the system is upgraded, everything will be "up to date".

A well-maintained, regularly-updated, installation should never need reinstalling.

提示
Gentoo should be updated regularly (updating daily or every few days is not unreasonable) for security reasons, and to avoid updates becoming complex. See the Gentoo Upgrading Guide for how to keep things in order.
附注
Gentoo requires Internet access, with sufficient stability and capacity, for both installation and updates.
提示
The Release Engineering Project page, the gentoo-announce mailing list, and the Gentoo ebuild repository news items provide information on important changes.

安装后内核启动失败,怎么办?

这并不意味着要重做安装中的每一个步骤,审查编译内核及内核相关的安装步骤 却是必要的。假设gentoo安装在/dev/sda1 (/boot) 和/dev/sda3 (/) with /dev/sda2(swap)用作交换分区。

从 live 环境中启动,然后升为超级用户权限权限(需要挂载文件系统)。

首先,挂载所有分区:

root #mount /dev/sda3 /mnt/gentoo # Mount rootfs (/)
root #mount /dev/sda1 /mnt/gentoo/boot # Mount boot partition
root #swapon /dev/sda2 # Activate swap
root #mount --types proc /proc /mnt/gentoo/proc
root #mount --rbind /sys /mnt/gentoo/sys
root #mount --make-rslave /mnt/gentoo/sys
root #mount --rbind /dev /mnt/gentoo/dev
root #mount --make-rslave /mnt/gentoo/dev
root #mount --bind /run /mnt/gentoo/run
root #mount --make-slave /mnt/gentoo/run

chroot至gentoo环境配置内核:

root #chroot /mnt/gentoo /bin/bash
root #env-update && source /etc/profile
root #cd /usr/src/linux
root #make menuconfig

现在选择(或取消)在之前安装(或取消)时错误的选项,重新编译,然后重新安装内核:

root #make $(portageq envvar MAKEOPTS) && make install modules_install

如果是用 LILO 作启动器,请重新运行 liloGRUB 用户可跳过此步骤。

root #/sbin/lilo

退出 chroot ,重启:

root #exit
root #umount -l /mnt/gentoo/dev /mnt/gentoo/sys
root #umount /mnt/gentoo/proc /mnt/gentoo/boot /mnt/gentoo
root #reboot #systemctl reboot for systemd users

Please see this article from the Knowledge Base for further details.

请从 Knowledge Base 查看这篇文章了解更多详细信息

如果是启动器的问题,一样地步骤,只不过是对启动器重新配置,而不是对内核 重新配置与编译。一般启动器并不需要重新编译。

网络代理需要需要授权,怎么办?

让portage自动使用方案,在/etc/portage/make.conf中定义代理:

文件 /etc/portage/make.conf设置 Portage 代理访问
http_proxy="http://username:password@yourproxybox.org:portnumber"
ftp_proxy="ftp://username:password@yourproxybox.org:portnumber"
RSYNC_PROXY="rsync://username:password@yourproxybox.server:portnumber"

记住代理服务器必需支持用于rsync端口的连接方法。

警告
Beware of the risks of storing passwords in configuration files. It is bad practice in general, and in some situations can be a huge security problem. Alternative, more secure methods, are advised.

如何刻录ISO文件?

另请参阅
See recommended GUI burners for applications to create optical disks from a running Gentoo installation. See the CD/DVD/BD writing article for information on burning optical media from Gentoo on the command line (article doesn't currently cover iso burning).
提示
This section covers burning an ISO file to optical media - see the LiveUSB article for information on writing ISO files to USB storage devices as bootable media.

ISO文件必须以raw模式进行刻录。这意味着该文件应该不会被放置在CD上,而是被解释为整个CD。

There are lots of optical media burning tools available to make a disk from an ISO file, here is a small selection of a few popular tools, on different platforms, with a short description of how to use them:

  • With EasyCD Creator, on MS Windows: select File, Record CD from CD image. Then change the Files of type to ISO image file. Then locate the ISO file and click Open. After clicking Start recording the ISO image will be burned correctly onto the CD/DVD.
  • With Nero Burning ROM, on MS Windows: cancel the wizard which automatically pops up and select Burn Image from the File menu. Select the image to burn and click Open. Now click the Burn button and watch the brand new Gentoo Live CD being burnt.
  • With cdrecord, part of cdrtools (app-cdr/cdrtools) - a multi platform project (works on Linux, among others): simply type cdrecord dev=/dev/cdrom (replace /dev/cdrom with the CDROM drive's device path) followed by the path to the ISO file.
  • With K3B, on Unix(like) OSs: select ToolsBurn Image. Then locate the ISO file within the 'Image to Burn' area, and select the target medium within the 'Burn Medium' area. Click Start to begin the burn process.
  • With Mac OS X Panther, and later, launch Disk Utility from Applications/Utilities, select Open from the Images menu, select the mounted disk image in the main window and select Burn in the Images menu.

CPU 应该使用什么 ISO 或 stage 文件

First find out what CPU is in the system Gentoo is to be installed on (for instance a Pentium-M). Next find out what CPU type it is compatible with (instruction-wise) to find a proper match with Gentoo's ISO or stages. Consulting the CPU's vendor website for this information usually works, although querying a search engine of choice is usually more efficient.

When uncertain, take a "lower" ISO or stage file, for instance a i686 or even generic x86 (or the equivalent in the system's arch). This will ensure that the system will work, but may not be as fast as further optimizations.

Please note that many more options exist than those for which Gentoo builds binary stages. Please see the GCC guide for setting the -march flag.

The Handbook has further information on selecting the correct stage file and choosing the right installation medium.

重新启动后,连接不上互联网了,哪里不对?

First follow standard troubleshooting practices (cables, routers working etc.).

Verify that the network card is discovered properly by the kernel. Run ip link and look for network interfaces. Something such as eth0, eno1, enp2s0, enp0s8, wlan0, wlp5s6 (in case of certain wireless network cards) should be present. Specific kernel modules may be required for the kernel to properly detect the network card. If that is the case, make sure that the required kernel modules are listed via a file ending in .conf in /etc/modules-load.d.

如果内核中遗漏了对系统网卡的支持,则需要重新配置,在某些情况下需要重新编译。

If the network card is found by the kernel, but the network configuration has been set to use DHCP, a DHCP client might not have been installed on the system. There are many DHCP clients available in Gentoo, a common one being dhcpcd. If necessary to get the connection to the Internet working, reboot to the installation CD and install net-misc/dhcpcd.

Information on how to rescue the system using the installation CD is available here as well.

The Handbook contains information on network setup, while the wiki has information on Ethernet, WiFi, and network management.

可以使用Windows或其他操作系统进行双引导吗?

当然可以! 可能最快的方法是使用 sys-boot/os-prober 安装 GRUB。 在 GRUB 文章,以及特别对使用 GRUB 进行双启动的用户在这里阅读有关信息。

尝试从GRUB Legacy或LILO启动Windows仅显示黑屏时该怎么办?

This is a known problem and only applies to older bootloaders such as GRUB Legacy and LILO. Windows refuses to boot when it is not installed on the first hard drive and shows a black/blank screen. To handle this, it is necessary to "fool" Windows into believing that it is installed on the first hard drive with a little tweak in the boot loader configuration. Please note that in the below example, Gentoo is installed on /dev/sda (first disk) and Windows on /dev/sdb (second disk). Adjust the configuration as needed:

文件 /boot/grub/grub.confgrub.conf 的 Windows 双系统启动示例
title Windows XP
     map (hd1) (hd0)
     map (hd0) (hd1)
     rootnoverify (hd1,0)
     chainloader +1
附注
The above example is for GRUB Legacy bootloader, not GRUB2. For information on how to dual boot Windows with GRUB see the GRUB article.
文件 /etc/lilo.conflilo.conf Windows 双系统启动示例
other=/dev/sdb1
     label=WindowsXP
     table=/dev/sdb
     map-drive = 0x80
     to = 0x81
     map-drive = 0x81
     to = 0x80

This will make Windows believe it is installed on the first hard drive and boot without problems. More information can be found in official GRUB documentation and in man lilo.conf.

如何使用stage1或stage2 tarball安装Gentoo?

The Gentoo Handbook only describes a Gentoo installation using a stage3 file. Stage1 and stage2 files are for development purposes only (the Release Engineering team starts from a stage1 file to obtain a stage3) and should not be used by users. A stage3 file can very well be used to bootstrap the system. A working Internet connection is a requirement.

Bootstrapping means building the toolchain (the C library and compiler) for the system after which all core system packages are installed. To bootstrap the system, perform a stage3 installation. Before starting the chapter on Configuring the Kernel, it might be necessary to modify the bootstrap.sh script to match personal requirements:

root #cd /var/db/repos/gentoo/scripts
root #vi bootstrap.sh

修改后,运行脚本。

root #./bootstrap.sh

接下来,使用新构建的工具链重建所有核心系统包。我们需要重建它们,stage3 压缩包提供了它们:

root #emerge -e @system

现在继续 配置内核

包管理

另请参阅
参见Portage 文档以及emerge 指令。

软件包里储存着什么 ?

Packages are not "stored" per se. Instead, Gentoo provides a set of scripts which can resolve dependencies, fetch source code, and compile a version of the package tailored to the user's needs. Generally Gentoo only builds binaries for releases and snapshots. The Gentoo Developer Manual covers the contents of an ebuild script in detail.

For full ISO releases, a full suite of binary packages will be created using an enhanced .tbz2 format, which is .tar.bz2 compatible with meta-information attached to the end of the file. These can be used to install a working (though not fully optimized) version of the package quickly and efficiently.

It is possible to create RPMs (Red Hat package manager files) using Gentoo's Portage, but it is not currently possible to use existing RPMs to install packages.

是否可以手动执行 ./configure 步骤

Yes, but it is not trivial, nor is it recommended. Since the method to do this requires a good understanding of Portage internals and commands, it is instead recommended that the ebuild is patched to do whatever it is that the user wants and place it in a Portage overlay (that is why overlays exist). This is much better for maintainability, and usually easier. See the Gentoo Developer Manual for more information.

无法使用 rsync 时怎么办?

When behind a firewall that does not permit rsync traffic through port 873, the emerge-webrsync command can be used to fetch and install a Portage snapshot through regular HTTP. See this section for information on downloading source files and Portage snapshots via a proxy.

我家里的网络连接很慢(或没有网络)。我可以在其他地方下载源并把他们添加到系统中吗?

It is possible to download packages manually and copy them to an appropriate location to be used for installation, however this can be a very tedious process.

Run emerge --pretend package/atom to see what programs are going to be installed. To find out the sources for those packages, and where to download the sources from, run emerge -fp package/atom. Download sources and bring them on any media home. Put the sources into the /var/cache/distfiles/ folder and then simply run emerge package/atom.

源的 tarball 在 /var/cache/distfiles/ 中,删除这些文件安全么?

Deleting these files will have no negative impact on day-to-day performance. However, it might be wise to keep the most recent version of the files; often several ebuilds will be released for the same version of a specific piece of software. If the archive is deleted and the software is upgraded or rebuilt it will be necessary to download them from the Internet again.

Use the eclean script from app-portage/gentoolkit to manage the contents of /var/cache/distfiles/ and a few other locations. Please read eclean(1) man-page to learn more about its usage, as well as the Gentoolkit article.

/var/tmp/portage 中是什么? 删除在 /var/tmp/portage 的文件和目录安全么?

During compilation, Gentoo saves the sources of the package in /var/tmp/portage (or in $PORTAGE_TMPDIR/portage if the default is changed). These files and folder are usually deleted upon a successful emerge, but this sometimes fails. It is safe to clean out all contents of this directory if the emerge command is not running. Be sure to always pgrep emerge before cleaning out this directory.

用法

如何设置国际键盘布局?

Edit the keymap variable in /etc/conf.d/keymaps. To have console working correctly with extended characters in the keymap, it might be necessary to set the consolefont and consoletransation variables in the /etc/conf.d/consolefont file (for further information on localizing the environment, refer to the localization guide). Then, issue a reboot, or restart the keymaps and consolefont scripts:

root #/etc/init.d/keymaps restart
root #/etc/init.d/consolefont restart

See keyboard layout switching for more information.

限制仅 root 用户使用 DNS 解析

/etc/resolv.conf 权限错误,把它修复为允许:

root #chmod 0644 /etc/resolv.conf

另请参阅 resolv.conf

为什么我的用户不能使用他们自己的 crontab?

将用户添加到 cron 组:

root #gpasswd -a <username> cron

如何让数字锁定键在启动时开启?

下列命令将把 numlock 服务添加到 default runlevel, 在启动时启用 numlock

root #rc-update add numlock default
root #/etc/init.d/numlock start

每个 GUI 程序都为这类事情提供了不同的工具;请查看帮助部分或所使用 GUI程序 的在线手册以获得进一步的帮助。

登出时,如何清除终端屏幕?

清除终端屏幕只需把 clear 命令添加到用户的 ~/.bash_logout 脚本中:

user $echo clear >> ~/.bash_logout

若想在添加新用户时自动设置,在 /etc/skel/.bash_logout 也这样做即可:

root #echo clear >> /etc/skel/.bash_logout

开发

在哪里可以报告错误?

Use the Bugzilla site to report bugs. Visit #gentoo (webchat) on the Libera.Chat IRC network and ask around if it is unclear whether an issue is really a bug or not.

There are a couple of guides for reporting bugs on the wiki: Bugzilla/Bug report guide and Bugzilla/Guide. See also the support article.

多久发布一次新版本?

Gentoo's packages are usually updated shortly after the upstream authors release new code, see this section for more information.

The Release Engineering Project page, the gentoo-announce mailing list, and the Gentoo ebuild repository news items provide information on important changes to Gentoo Linux.

附注
This section concerns releases of packages. Gentoo itself is on a rolling release model and does not have releases, see the What makes Gentoo different? section.

扬声器疯狂发出嘟嘟声。如何禁用控制台哔声?

可以使用 setterm 关闭控制台提示音,如下所示:

root #setterm -blength 0

To turn off the console beeps on boot, put the following command in the /etc/conf.d/local.start file. However, this only disables beeps for the current terminal. To disable beeps for other terminals, pipe the command output to the target terminal, like this:

root #setterm -blength 0 > /dev/vc/1

Replace /dev/vc/1 with the terminal for which console beeps need to be disabled.

更多细节请查看这篇文章

冷知识

为什么许多 Gentoo 特定的工具和函数的名称中都有字母 ‘e’ ?

‘e’ 之所以成为开头,是因为 Gentoo 最初的名字是 Enoch Linux。因此 Gentoo 的许多工具和函数名都维持前缀 ‘e’。

这是来自 Daniel Robbins (Daniel Robbins) 的引文:“我认为 'e' 可能来自于 enoch,并且被选为 'iMac' 缩写中的单字符前缀,该词最初于 1998 年 8 月发布,Enoch 始于 1999 年初。”(请参阅 https://www.funtoo.org/Funtoo_Linux_History )。

资源

是否可以购买 Gentoo Linux 发行的 CD 和 DVD?

绝大部分的商店已经停止提供CD或DVD了。随着Gentoo ISO的间隔很短地、快速地释出以及科技的进步(尤其是为大众提供的更高的网络带宽),这类安装介质已然成为了过去时。你永远可在在下载界面找到可启动介质的镜像。

其他类型的官方产品授权商店在 商店页列出。

这个FAQ没有回答我的问题。现在该怎么做?

第一步推荐浏览相关的文档,如Gentoo wikiman pagesInfo/usr/share/doc/。许多指令同时支持 --help 或者 -h。

The various Gentoo Linux mailing lists, or the forums could help. Queries may be put to the Gentoo community on IRC - ask questions directly in the #gentoo (webchat) Libera.Chat IRC channel.

The Gentoo bug tracking system contains information on many issues. Searching the web may yield good results for some questions. If having trouble with a particular package, check upstream documentation.

另请参阅
参见 帮助一文如果有特别的需求。

This page is based on a document formerly found on our main website gentoo.org.
The following people contributed to the original document: Daniel Robbins (Daniel Robbins) , Colin Morey, John P. Davis, Eric Stockbridge, Stoyan Zhekov, Carl Anderson, Jorge Paulo, Benny Chuang, Jonathan Smith,
They are listed here because wiki history does not allow for any external attribution. If you edit the wiki article, please do not add yourself here; your contributions are recorded on each article's associated history page.