# AT3: Can I exclude parts of the Portage tree?

## curtis119

Navigation: [Advanced Topics] [Table of Contents]

Question: The portage tree takes up too much space with stuff I won't ever install and takes a long time to sync. What can I do?

The time Portage takes to download and process the tree (/usr/portage) can be decreased very easily by excluding parts of it. This will also free up valuable disk space since the portage tree is now over 400MB. This feature is available in portage-2.0.47-r3 and higher.

First add or uncomment the following line to /etc/make.conf

```

# For portage-2.0.x

RSYNC_EXCLUDEFROM=/etc/portage/rsync_excludes

# For portage-2.1

PORTAGE_RSYNC_EXTRA_OPTS="--exclude-from=/etc/portage/rsync_excludes"

```

Next create the rsync_exludes file in /etc/portage and add the categories you want to exclude. Here is an example file that excludes all of the games categories, kde and media-sound.

```

games-*/

kde-*/

media-sound/

```

Portage will not delete these directories if they already exist so you must manually remove them. Once removed portage will not recreate them. For example:

```

rm -rf /usr/portage/games-action

```

Adding "--delete-excluded" to PORTAGE_RSYNC_EXTRA_OPTS, which will automatically delete directories added to the "--exclude-from" file on the next emerge --sync, will also delete all the files in distdir, since portage already excludes that directory. Deleting all the files in distdir on every emerge --sync is probably not what you want so manual deletion, as shown above, is recommended.

If you are attempting to emerge a package and get an error about missing dependencies check that it is not included in a category you excluded. You may add or remove categories from the rsync_exludes file at any time but it will not take effect until your next sync. To regain the entire portage tree simply comment out the RSYNC_EXCLUDEFROM or PORTAGE_RSYNC_EXTRA_OPTS line in /etc/make.conf and emerge --sync. Be careful not to exclude needed categories such as sys-apps.

For advanced information on directory/file pattern matching in your rsync_exludes file read the section "include/exclude pattern rules" in the rsync manpage. You can also try the script in this post (use at your own risk).

2006-06-16: Portage-2.1 changes, minor touch up.  --kallamej

2006-07-05added note about "--delete-excluded" --curtis119[/i]

----------

