Upgrading Gentoo

From Gentoo Wiki
Jump to:navigation Jump to:search
This page contains changes which are not marked for translation.
Other languages:
Deutsch • ‎English • ‎español • ‎français • ‎italiano • ‎português do Brasil • ‎русский • ‎中文(中国大陆)‎ • ‎日本語 • ‎한국어

This document explains how to upgrade (update) Gentoo.

Gentoo has its own approach to updates: this will be explained here, as well as how to proceed for a well maintained system.

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.

Any instructions that only affect ten or more year old systems will not be retained here. See page history for previous versions.

About Gentoo architecture and upgrades

Gentoo differs from most other Linux distributions when it comes to updates. Most distributions have regular releases, every few months or years, which are often published without too much fanfare.

Gentoo, by contrast, is a rolling release distribution. There is no need to wait for a release to come out to get the latest version of packages: software can be installed as soon as it becomes stable, with frequent updates. Gentoo was designed from the beginning around this concept of fast, incremental updates, and there are updates to its software nearly every day.

Once software is installed, regular system updates will keep all packages on the latest available version. Only in very rare cases are changes made to the core system which require updates to be done manually. This typically involves switching to a new profile.

A news item will be published in such critical cases.

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.

Updating packages

The Handbook has detailed information on updating the Gentoo repository and on updating the system. See man emerge for more detailed information.

Important
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

Or, for short:

root #emaint -a sync

This may output messages that should be read and followed.

Run emerge to update the whole system, with dependencies:

root #emerge --ask --verbose --update --deep --newuse @world

Pay attention to any information provided by Portage at the end of the update.

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.

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 pakage optional dependencies when an alternative gets merged). Always use --ask or --pretend options and carefully review output:

root #emerge --ask --verbose --depclean

If emerge --depclean would remove packages that should not be removed, the --exclude option could temporally be used, or they can be added to the world set (preferred), for example:

root #emerge --noreplace <atom>

Any configuration file changes should be addressed, this can be managed by dispatch-conf:

root #dispatch-conf

Profile updating instructions

Important
Read relevant documentation before performing any profile changes.
Warning
Read the systemd documentation before changing to a systemd profile.
Important
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.

General instructions

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.

Note
There are desktop subprofiles for most architectures. Examine these profiles carefully, as they may serve the requirements better than the extremely minimal default profiles.
Important
The developer subprofile is specifically for Gentoo Linux development tasks. It is not meant to help set up general development environments.

Switch profiles with eselect

Make sure warnings in parent section have been read.

To switch profiles with the automatic tool, app-admin/eselect must be installed. The eselect utility makes viewing and selecting profiles easy, without needing to create or remove symlinks by hand:

root #eselect profile list
root #eselect profile set <number>

Switch profiles manually

Make sure warnings in parent section have been read.

Changing profiles manually is still supported:

root #rm /etc/portage/make.profile
root #cd /etc/portage
root #ln -s ../../var/db/repos/gentoo/profiles/<selected profile> make.profile

Updating to 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.

Updating to 17.0

See the appropriate news item. At this point all installations should be using the 17.1 profile, and migration could be difficult.

Updating old systems

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.

Synopsis

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.

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

Network, chroot, and update

The new install needs to access the network, so copy over the network related information:

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.

Important
Do not forget to add --root=/mnt/host --config-root=/mnt/host to all emerge commands executed within the chroot! Otherwise the chroot itself is updated rather than the (old) live system.

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

Once finished the system should now be up to date!


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.