User:0xdc/Drafts/Portage Sync RCU

From Gentoo Wiki
Jump to:navigation Jump to:search

Portage can change the storage method is uses to hold a portage repository/overlay[1][2].

Note
This is only applicable for rsync repositories

Why

Historically, portage updated the portage tree in-place. This meant the files user /usr/portage (as it was then) were directly modified by rsync and used in its difference calculations. This is fast but if the synchronisation failed for any reason, the portage tree may be left in a non-working state.

With the advent of the GPG-signed portage tree, there is an additional check that increases the chances of a failed sync.

More recently, portage has decided to take a copy of the existing repository and quarantine the new updates. If the update passes verification, they are copied into the working location.

Read, Copy, Update

Portage has an alternative storage method called RCU (read, copy, update). Here, the working portage tree is resolved via a symlink; future and past trees can sit next to the working tree, and the portage tree is updated by changing the symlink atomically.

This can be desirable in I/O constrained environments or when the portage tree is shared with a number of consumers. However, care must be taken when using the portage tree when using bind-mounts or in chroot/systemd-nspawn.

Enable RCU

To enable RCU behaviour, add the following to your repos.conf entry for any rsync repository:

FILE /etc/portage/repos.conf/gentoo.conf
sync-rcu = yes
sync-rcu-store-dir = /var/lib/portage/rcu

Adjust the sync-rcu-store-dir appropriately. It must not be the same as the location directory and must be a directory solely used for the purposes of RCU.

Sync

Once set up. sync your rsync tree. This will migrate any existing checkout and set up the RCU symlink.

root #emaint sync -r gentoo

Symlink

Once complete, symlink the original location to the latest symlink in the sync-rcu-store-dir; e.g.

root #ln -s /var/lib/portage/rcu/latest /var/db/repos/gentoo

See Also