用aria2c替换wget工作,提升pacman性能

移除未安装的包和未使用的仓库

1
pacman -Sc

优化数据库

1
pacman-optimize

使用aria2 代码 wget(其实先前我一直在用axel的,无奈有时候axel半天下载不来一个几M的东西(卡住不动))

1
2
3
pacman -S aria2
vim /etc/pacman.conf
XferCommand = /usr/bin/aria2c --allow-overwrite=true -c --file-allocation=none --log-level=error -m2 --max-connection-per-server=6 --max-file-not-found=5 --min-split-size=5M --no-conf --remote-time=true --log=- --summary-interval=60 -t5 -d / -o %o %u

Option Details

/usr/bin/aria2c
The full PATH to the aria2 executable.
–allow-overwrite=true
Restart download if a corresponding control file does not exist. (Default: false)
-c, –continue
Continue downloading a partially downloaded file if a corresponding control file exists.
–file-allocation=none
Do not pre-allocate file space before download begins. (Default: prealloc) 1
–log-level=error
Set log level to output errors only. (Default: debug)
-m2, –max-tries=2
Make 2 maximum attempts to download specified file(s) per mirror. (Default: 5)
–max-connection-per-server=2
Set a maximum of 2 connections to each mirror per file. (Default: 1)
–max-file-not-found=5
Force download to fail if a single byte is not received within 5 attempts. (Default: 0)
–min-split-size=5M
Only split the file if the size is larger than 2;5MB = 10MB. (Default: 20M)
–no-conf
Disable loading an aria2.conf file if it exists. (Default: ~/.aria2/aria2.conf)
–remote-time=true
Apply timestamps of the remote file(s) and apply them to the local file(s). (Default: false)
–summary-interval=60
Output download progress summary every 60 seconds. (Default: 60) 2
-t5, –timeout=5
Set a 5 second timeout per mirror after a connection is established. (Default: 60)
-d, –dir
The directory to store the downloaded file(s) as specified by pacman.
-o, –output
The output file name(s) of the downloaded file(s).
%o
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.

相关文档:
https://wiki.archlinux.org/index.php/Improve_Pacman_Performance
另外,pacman 官网也有一个 Pacman Mirrorlist Generator http://www.archlinux.org/mirrorlist/

更多
3 Responses Post a comment
  1. 依云

    我以前也用过一次,发现硬盘灯不停地闪啊闪啊,就去看了看它的原理,然后就再也不用了~

  2. 荒野无灯

    首先我没看它的解释。。。经你提醒,发现使用它相当的不好

  3. 依云

    pacman-optimize 完全是让磁盘受罪,不如 dd 个几十 M 的文件系统放数据库,一直很迅速,从不需优化。

Leave a Reply

Note: You may use basic HTML in your comments. Your email address will not be published.

Subscribe to this comment feed via RSS