升级Gentoo
emerge — configuration — ebuild repository — dispatch-conf
world file — USE flags — ebuilds — profiles
upgrades — using testing packages — binary packages
tools — gentoolkit — eselect
Portage FAQ — cheat sheet — FAQ
all articles
本文档解释了新的 Gentoo 版本如何影响现有安装。
It is important to keep Gentoo up to date. In addition to the need to have the latest security patches, Gentoo installations can get too out of sync with the current version and sometimes become complex to update.
Update Gentoo Linux between daily or weekly to keep a Gentoo Linux installation running smoothly with the latest security updates. Waiting more than a few weeks to update may make things a little more complicated when the update is attempted. Please don't synchronize more than once daily, to avoid strain on the servers.
Any instructions that only affect ten or more year old systems will not be retained here. See page history for previous versions.
关于 Gentoo 的架构和升级
Gentoo differs from most other Linux distributions when it comes to updates. Most distributions have regular releases, every few months or years, which can be anticipated events for some distributions.
Gentoo, by contrast, is a rolling release distribution. There is no need to wait for a release to come out in order to get the latest version of packages - software can be installed as soon as it becomes stable. Gentoo was designed from the beginning around this concept of fast, incremental updates, and there are frequent updates to Gentoo software, with new and updated packages most days. Further information on Gentoo specifics can be found in the FAQ, about releases and Gentoo and what makes Gentoo different.
理想情况下,用户安装一次软件,从不担心发布:只需按照 Gentoo 手册 中的 Portage 介绍 中的说明进行操作,该说明解释了如何保持系统处于最新状态。虽然这是通常的方式,但有时会对核心系统进行更改,这需要手动完成更新。
In rare cases, changes made to the core system, to certain packages, profile changes, or certain updates of Portage, may require manual intervention during or after an update. A news item will be published in such critical cases and/or will be signaled after a Gentoo repository synchronization. Always read and follow the news items and Portage messages.
Profiles are central to a Gentoo system because they can define core system functionality, and new profiles are made available when there are fundamental changes to the way Gentoo works. A profile is selected at install time, according to the intended use of the system and is usually only changed if necessary, or for an update.
升级软件包
The Handbook has detailed information on updating the Gentoo repository and on updating the system. See man emerge for more detailed information. See repository synchronization for complete information on how to use emaint to synchronize repositories.
It is important to read and follow any and all news items that may be listed after performing a repository sync.
To update all installed packages to the latest available versions, first update the Gentoo repository with emaint:
root #
emaint --auto sync
或者,使用短选项:
root #
emaint -a sync
This may output messages that should be read and followed, notably the news items previously mentioned. If config file updates are pending from a previous update, it may remind to update the config files.
运行 emerge 连带依赖一起升级整个系统:
root #
emerge --ask --verbose --update --deep --newuse @world
或者,使用短选项:
root #
emerge -avuDN @world
--changed-use
may be used in place of --newuse
, though with this option some USE flags may no longer reflect the current state of those in the Gentoo repository. --with-bdeps=y
can be used to update build time dependencies also.
Pay attention to any information provided by Portage at the end of the update. Some of this information may be available in the Portage log.
If Portage reports dependency issues, sometimes using the --backtrack=30
(or an even higher number) can help. By default, Portage has a relatively low limit on how far it tries to resolve dependencies (for performance reasons), occasionally it is not enough.
Any configuration file changes should be addressed, this can be managed by dispatch-conf:
root #
dispatch-conf
升级之后的清理
After the update, Portage recommends running emerge --depclean. Be very careful running emerge --depclean, it can remove important packages (e.g. kernel sources or virtual package optional dependencies when an alternative gets merged).
See remove orphaned packages for information on how to use emerge --depclean to remove potentially unused packages safely. See also the Portage FAQ.
配置文件更新说明
在执行任何配置文件的更改之前需要阅读相关文档。
Make sure the main Gentoo repository (the Portage tree) has been synced before performing any profile changes.
When a new profile is available, Portage will inform the user with a news item (recent news items are listed on the website).
If a system is too old, it may be non trivial to get the system up to date, it may even be easier to start from scratch.
Generally, it is not mandatory to switch to a new profile when one comes out. Systems can continue to use their old profile, they won't stop working by staying on an old profile. However, Gentoo strongly recommends updating the profile if it becomes deprecated, as this means that Gentoo developers no longer plan on supporting it.
Profile updates are executed manually. The way to update may vary significantly from profile to profile; it depends on how deep the modifications introduced in the new profile are. In the simplest case, users only have to use the eselect tool to change the /etc/portage/make.profile symlink, the worst case could be having to recompile the entire system from scratch, with significant reconfiguration (though changes are usually not too hard, and are well explained - the main thing to remember is to properly follow the instructions).
Exactly what is required to migrate to a new profile is detailed in the relevant news item.
通用信息
This is a generic outline of what is done to update a profile. As stated previously, specific instructions will be provided in a news item, for each new profile. A profile update often requires manual intervention, beyond just switching the profile version.
There are desktop subprofiles for most architectures. Examine these profiles carefully, as they may serve the requirements better than the extremely minimal default profiles.
The developer subprofile is specifically for Gentoo Linux development tasks. It is not meant to help set up general development environments.
使用 eselect 切换配置文件
Make sure warnings in parent section have been read.
首先,运行 emerge eselect。eselect 程序使查看和选择配置文件简单更,无需手工创建或删除符号链接。
root #
eselect profile list
root #
eselect profile set <number>
手动切换配置文件
确保已经阅读上面章节的警告信息。
Gentoo 也支持通过以下命令手动更改配置文件:
root #
rm /etc/portage/make.profile
root #
cd /etc/portage
root #
ln -s ../../var/db/repos/gentoo/profiles/<selected profile> make.profile
更新到 17.1 配置文件
See the appropriate news item. At this point all installations should already be using the 17.1 profile, and migration could be difficult.
更新到 17.0 配置文件
See the appropriate news item. At this point all installations should be using the 17.1 profile, and migration could be difficult.
升级旧系统
Sometimes, systems are too old to easily upgrade. It may be possible to manually update a very old system, but it may be better to start from scratch and copy system configuration an files from the old system to the new one.
Here is a rough guide to updating an old system. Another method can be found here.
概述
The idea with this upgrade approach is that we create an intermediate build chroot in which a recent stage3 is extracted. Then, using the tools available in the stage3 chroot we upgrade the packages on the live system.
The commands below might be incomplete and serve more as a guidance rather than work instructions. Unless the approach is clear, it might be faster to just backup the important files and re-install Gentoo.
Preparing the intermediate build chroot
Let's first create the intermediate build chroot location, say /mnt/build, and extract a recent stage3 archive into it.
root #
mkdir -p /mnt/build
root #
tar -xf /path/to/stage3-somearch-somedate.tar.bz2 -C /mnt/build
root #
mount --rbind /dev /mnt/build/dev
root #
mount --rbind /proc /mnt/build/proc
root #
mount --rbind /sys /mnt/build/sys
Next, we create a mount point inside this chroot environment, on which we then bind-mount the live (old) environment.
root #
mkdir -p /mnt/build/mnt/host
root #
mount --rbind / /mnt/build/mnt/host
So now the live (old) system is also reachable within /mnt/build/mnt/host. This will allow us to reach the live (old) system and update the packages even when chrooted inside the intermediate build chroot.
网络、chroot 和更新
新安装需要访问网络,因此复制网络相关的信息:
root #
cp -L /etc/resolv.conf /mnt/build/etc/
Now chroot into the intermediate build location, and start updating vital packages on the live system, until the live system can be updated from within the live system (rather than through the intermediate build chroot):
root #
chroot /mnt/build
root #
source /etc/profile
root #
export PS1="(chroot) ${PS1}"
(chroot) root #
emerge --sync
It may be a good idea to check that the profile and Portage configuration are compatible between the (old) live system and the chroot.
Now start building packages into the (old) live system. If Portage is old or missing, it is a good idea to start with that:
(chroot) root #
emerge --root=/mnt/host --config-root=/mnt/host --verbose --oneshot sys-apps/portage
Keep this chrooted session open and try to update the (old) live system. When failures occur, use this chrooted session to update packages using the build tools available in the intermediate build chroot (which includes recent sys-libs/glibc, sys-devel/gcc, etc.). Tools can be added as needed to the build chroot.
在 chroot 中执行的所有 emerge 命令别忘了添加
--root=/mnt/host --config-root=/mnt/host
!否则,将更新 chroot 本身,而不是(旧的)live 系统。For some installations it may be necessary to update configuration files in order to install new software. Make the changes in the chroot environment.
To get the system fully up-to-date before exiting the root, build the @world
set (all packages) into the (old) live system:
(chroot) root #
emerge --root=/mnt/host --config-root=/mnt/host --update --newuse --deep --ask @world
这些都完成后,现在使用的应该就是最新的系统!
另请参阅
- Updating old Gentoo installations.
- Can I upgrade Gentoo from one release to another without reinstalling
- Cheat Sheet on updates.
- Handbook on updates.
- Installation — an overview of the principles and the practice of installing Gentoo on a running system.
This page is based on a document formerly found on our main website gentoo.org.
The following people contributed to the original document: Gregorio Guidi, Chris Gianelloni, Joshua Saddler
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.