{{Note|pacman-cage is now not needed anymore, as pacman 3.5 sync DBs read directly from the database tarball. See [[https://bbs.archlinux.org/viewtopic.php?pid=907253#p907253]].}}

−

'''pacman-cage''' is a script that puts the pacman database, {{Filename|/var/lib/pacman}}, in a single loop file containing its own file-system that can speed up access times. This very simple alteration that improves pacman's speed for tasks like searching and updating. The script makes a backup (at installation only) in case something goes wrong but has caused some users to lose their database (e.g. when used in a chroot). Use with caution.

−

−

{{Package AUR|pacman-cage}} can be found in [[AUR]].

== Improving Download Speeds ==

== Improving Download Speeds ==

Revision as of 16:31, 14 June 2011

This template has only maintenance purposes. For linking to local translations please use interlanguage links, see Help:i18n#Interlanguage links.

Improving Database Access Speeds

Pacman stores all package information in a collection of small files, one for each package. Improving database access speeds reduces the time taken in database-related tasks, e.g. searching packages and resolving package dependencies. The safest and easiest method is to run as root:

# pacman-optimize

This will attempt to put all the small files together in one (physical) location on the hard disk so that the hard disk head does not have to move so much when accessing all the packages. This method is safe, but is not foolproof. It depends on your filesystem, disk usage and empty space fragmentation. Another more aggressive option would be to first remove uninstalled packages from cache and to remove unused repositories before database optimization:

# pacman -Sc && pacman-optimize

Improving Download Speeds

Note: If your download speeds have been reduced to a crawl, ensure you are using one of the many mirrors and not ftp.archlinux.org, which is throttled since March 2007.

Pacman's speed in downloading packages can be improved by using a different application to download packages instead of Pacman's built-in file downloader.

In all cases, make sure you have the latest Pacman before doing any modifications.

# pacman -Syu

Using wget

This is also very handy if you need more powerful proxy settings than pacman's built-in capabilities.

To use wget, first install it with pacman -S wget and then modify /etc/pacman.conf by adding the following line to the [options] section:

Using aria2

aria2 is a lightweight download utility with support for resumable and segmented HTTP/HTTPS and FTP downloads. aria2 allows for multiple and simultaneous HTTP/HTTPS and FTP connections to an Arch mirror, which should result in an increase in download speeds for both file and package retrieval.

Variable which represents the local filename(s) as specified by pacman.

%u

Variable which represents the download URL as specified by pacman.

Additional Notes

1--file-allocation=falloc

Recommended for newer file systems such as ext4 (with extents support), btrfs or xfs as it allocates large files (GB) almost instantly. Do not use falloc with legacy file systems such as ext3 as prealloc consumes approximately the same amount of time as standard allocation would while locking the aria2 process from proceeding to download.

2--summary-interval=0

Supresses download progress summary output and may improve overall performance. Logs will continue to be output according to the value specified in the log-level option.

Using airpac

In a nutshell, airpac is an aria2c wrapper for pacman. Unlike powerpill, which acts as a frontend to pacman, airpac serves as a backend downloader for pacman. On the other hand, however, it behaves similarly to powerpill, as far as downloading is concerned, since both use aria2c to actually download the files. Because it is a backend though, it cannot download multiple packages simultaneously as powerpill can.

Essentially, airpac is the Python implementation of the pacget script below. However, the main difference lies in the handling of aria2c output. airpac shows only the most relevant info, i.e., the download progress, although it currently doesn't use a progressbar (maybe in the near future). Also, airpac caches the db files so that they won't be downloaded for every pacman -Sy. On the downside, this breaks pacman -Syy since airpac has no way of knowing the options pacman is executed with. As a workaround, however, one can use pacman -Sc to delete the cached files in /var/lib/pacman/.airpac.

The configuration file is located in /etc/airpac.conf. This is actually an aria2c config file. Because of this, the user can directly configure how aria2c is used by airpac without meddling with airpac's code. For more info about the available options, consult the aria2c manpage.

airpac also uses the Server Performance Profile feature of aria2c by default. The statistics file is located in /var/lib/airpac.stats. The default URI selector is adaptive.

Usage in /etc/pacman.conf

XferCommand = /usr/bin/airpac %u %o

pacget (aria2) Mirror Script

This script will greatly improve the download speed for broadband users. It uses the servers in /etc/pacman.d/mirrorlist as mirrors in aria2. What happens is that aria2 downloads from multiple servers simultaneously which gives a huge boost in download speed.

Take note that you have to put 'exec' before /usr/bin/pacget in the XferCommand. This is needed so that when you terminate pacget or aria2 (with process id used by pacget), pacman would also terminate. This would prevent inconvenience because Pacman would not persist downloading a file when you tell it not to.

WARNING: You may experience some problems if the mirrors used are out-of-sync or are simply not up-to-date. Just use the Reflector script to generate a list of up-to-date and fast mirrors. Also, ftp.archlinux.org resolves to two IPs. You may want to choose only one of them and hard code ftp.archlinux.org and the chosen IP address to /etc/hosts.

In /etc/pacman.conf, in the [options] section, the following needs to be added:

XferCommand = exec /usr/bin/pacget %u %o

PS: If you use ftp.archlinux.org as the first server listed in your include files (/etc/pacman.d/*), some problems may occur when the mirrors you are using have not yet synced. To make great use of this script, choose a mirror (that syncs in a timely manner) that is more appropriate for you, then put that on top of the server lists. This is to prevent downloading only from ftp.archlinux.org when the mirrors have not yet synced. The rankmirrors script can be useful in this case.

Using other applications

There are other downloading applications that you can use with Pacman. Here they are, and their associated XferCommand settings:

snarf: XferCommand = /usr/bin/snarf -N %u

lftp: XferCommand = /usr/bin/lftp -c pget %u

axel: XferCommand = /usr/bin/axel -n 2 -v -a -o %o %u

Choosing the fastest mirror

When downloading packages pacman uses the mirrors in the order they are in /etc/pacman.d/mirrorlist.The mirror which is at the top of the list by default however may not be the fastest for you.

Choosing a local mirror

The simple way is to edit mirrorlist file by placing a local mirror at the top of the list. pacman will then use this mirror for preference.

Alternativley the pacman.conf file can be edited by placing a local mirror before the line sourcing the mirrorlist file, i.e. where it says "add your preferred servers here". It is safer if you use the same server for each repository.

Using rankmirrors

You can use rankmirrors to rank pacman mirrors by their connection and opening speed.

After changing mirrors

After changing your mirror it is a good idea to refresh the pacman database. Using two y's forces a download of a fresh copy of the master package list from the server even if they are thought to be up to date.

# pacman -Syy

Sharing packages over your LAN

If you happen to run several Arch boxes on your LAN, you can share packages so that you can greatly decrease your download times. Keep in mind you should not share between different architectures (i.e. i686 and x86_64) or you'll get into troubles.