Difference between revisions of "Local Mirror (简体中文)"

From ArchWiki
Jump to: navigation, search
(Setting up pacman to use the local mirror)
m (OJZ)
(42 intermediate revisions by 11 users not shown)
Line 1: Line 1:
 
[[Category:Package management (简体中文)]]
 
[[Category:Package management (简体中文)]]
[[Category:HOWTOs (简体中文)]]
+
[[en:Local Mirror]]
[[Category:简体中文]]
+
[[ru:Local Mirror]]
 +
{{TranslationStatus (简体中文)|Local_Mirror|2013-05-26|258420}}
 +
{{警告|如果你想创建一个官方镜像,参考 [https://wiki.archlinux.org/index.php/DeveloperWiki:NewMirrors 这个页面]。}}
  
{{i18n_links_start}}
+
== 稍等 ==
{{i18n_entry|English|Local Mirror}}
+
{{i18n_entry|简体中文|本地镜像 (简体中文)}}
+
{{i18n_links_end}}
+
  
 +
{{警告|通常不赞成创建一个本地镜像,因为需要很大的带宽。其中一个替代的方法也许会满足你的要求。请查看下面的替代方法。}}
  
{{translateme}}
+
==== 替代方法 ====
 +
*[[Pacman_Tips_(简体中文) #.E5.9C.A8.E7.BD.91.E7.BB.9C.E4.B8.8A.E5.85.B1.E4.BA.ABpacman.E7.BC.93.E5.AD.98|在网络上共享 pacman 缓存]]
  
'''注意:''' 95%的用户不需要这么做。同步core和extra上的所有软件包会带来许多你所不需要的东西。Only follow these instructions if you are running a very large site of Arch machines or want to create an official mirror. Perhaps using a [[Network Shared Pacman Cache]] would serve you better.
+
==本地镜像==
  
'''NOTE:''' Due to traffic issues rsyncing from rsync.archlinux.org is allowed only for official mirrors. If you want to create an official mirror - write to the mailing list about this and entries in /etc/pacman.d/* will be added and your IP address will be allowed.
+
=== 需要牢记的事实 ===
 +
* 镜像的带宽不是免费的,镜像必须为提供给你的数据付费
 +
** 尽管你已经为你的 ISP 付费,这也是成立的。
 +
* 有很多你可能下载了却永远用不到的包
 +
* 镜像的管理员会更喜欢让你仅下载需要的包
 +
* 再次请求仔细查看上面的替代方案
  
If you want to get a full mirror for personal use only, you may rsync from '''rsync://distro.ibiblio.org/distros/archlinux/'''
+
'''如果你完全确定本地镜像是唯一合适的解决方案,那么按照下面的指引操作。'''
  
This document describes how to create a mirror on your local machine of all the packages and iso files on the Arch mirrors, how to update it using cron, how to serve the mirror with vsftpd, and how to set up pacman to use the local mirror.
+
=== 服务器设置 ===
 +
==== 编写 Rsync 命令 ====
 +
* 参照 [https://wiki.archlinux.org/index.php/DeveloperWiki:NewMirrors DeveloperWiki:NewMirrors] 使用 rsync 参数
 +
* 从上文中选择一个服务器
 +
* 在 rsync 参数中包含 {{Ic|1=--exclude-from="/path/to/exclude.txt"}} 以排除那些你不想包含的目录或文件。示例内容可能包括:
 +
<pre>
 +
iso
  
== 安装准备 ==
+
#Exclude i686 Packages
 +
*/os/i686
 +
pool/*/*-i686.pkg.tar.xz
 +
pool/*/*-i686.pkg.tar.gz
  
首先,更新或是安装安装必要的工具:
+
#Exclude x86_64 Packages
pacman -Sy rsync vsftpd
+
*/os/x86_64
 +
pool/*/*-x86_64.pkg.tar.xz
 +
pool/*/*-x86_64.pkg.tar.gz
 +
</pre>
  
现在,我们要创建一个用于同步镜像的新用户('''没有登录特权'''),使用FTP获取文件。用户名“mirror”只是一个例子,你可以使用其他任何名称。请'''不要'''使用root或是其他能登录系统的帐号。安全起见,我们使用的帐号只能拥有尽可能少的权限。
+
* 所有软件包都位于 pool 目录。然后从 pool 创建符号到 to core/extra/testing/etc。
 +
** 截至 9/21/2010 此迁移仍没有完成。
 +
*** 在 ${repo}/os/${arch} 中应该有确切的软件包,而不是符号链接
 +
* 排除那些你不需要的顶极目录
  
useradd -m -s /bin/false mirror
+
例如: {{Ic|1=rsync ''$rsync_arguments'' --exclude="/path/to/exclude.txt" ''rsync://example.com/'' /path/to/destination}}
  
现在,我们将继续创建镜像。
+
==== 示例脚本 ====
  
== 创建本地镜像目录 ==
+
{{警告|除非你阅读了本文开头的警告,否则不要使用本脚本}}
我们将使用 <tt>/home/mirror</tt>,刚才所创建的非特权用户的主目录,用于存储脚本,日志以及软件包。
+
{{警告|仅使用本脚本同步 Core/Extra/Community! 如果你需要 Testing,gnome-unstable 或是任何其他软件库,另外使用 rsync --exclude!}}
  
首先要做的是在 /home/mirror 下创建几个目录 :
+
是的,为了避免人们以复制粘贴的形式搭建他们自己的镜像,本脚本 '''故意''' 缺失了部分内容。如果你确实想要搭建一个镜像,错误是很容易修补的。
 
+
cd /home/mirror
+
sudo -u mirror mkdir {scripts,files,logs}
+
 
+
== 同步脚本 ==
+
 
+
现在让我们用最喜爱的编辑器创建实际的 rsync 脚本, <tt>scripts/mirrorsync.sh</tt> 。
+
  
 
  #!/bin/bash
 
  #!/bin/bash
#
 
# The script to sync a local mirror of the Arch Linux repositories and ISOs
 
#
 
# Copyright (C) 2007 Woody Gilk <woody@archlinux.org>
 
# Modifications by Dale Blount <dale@archlinux.org>
 
# and Roman Kyrylych <roman@archlinux.org>
 
# Licensed under the GNU GPL (version 2)
 
 
   
 
   
  # Filesystem locations for the sync operations
+
  #################################################################################################
  SYNC_HOME="/home/mirror"
+
### It is generally frowned upon to create a local mirror due the bandwidth that is required.
  SYNC_LOGS="$SYNC_HOME/logs"
+
### One of the alternatives will likely fulfill your needs.
  SYNC_FILES="$SYNC_HOME/files"
+
### REMEMBER:
  SYNC_LOCK="$SYNC_HOME/mirrorsync.lck"
+
###  * Bandwidth is not free for the mirrors. They must pay for all the data they serve you
 +
  ###      => This still applies although you pay your ISP
 +
  ###      => There are many packages that will be downloaded that you will likely never use
 +
  ###      => Mirror operators will much prefer you to download only the packages you need
 +
  ###  * Really please look at the alternatives on this page:
 +
###      https://wiki.archlinux.org/index.php?title=Local_Mirror
 +
### If you are ABSOLUTELY CERTAIN that a local mirror is the only sensible solution, then this
 +
### script will get you on your way to creating it.
 +
#################################################################################################
 
   
 
   
  # Select which repositories to sync
+
  # Configuration
  # Valid options are: core, extra, testing, community, iso
+
  SOURCE='rsync://mirror.example.com/archlinux'
  # Leave empty to sync a complete mirror
+
  DEST='/srv/mirrors/archlinux'
  # SYNC_REPO=(core extra testing community iso)
+
  BW_LIMIT='500'
  SYNC_REPO=()
+
REPOS='core extra'
 +
  RSYNC_OPTS="-rtlHq --delete-after --delay-updates --copy-links --safe-links --max-delete=1000 --bwlimit=${BW_LIMIT} --delete-excluded --exclude=.*"
 +
LCK_FLE='/var/run/repo-sync.lck'
 
   
 
   
  # Set the rsync server to use
+
  # Make sure only 1 instance runs
# Only official public mirrors are allowed to use rsync.archlinux.org
+
  if [ -e "$LCK_FLE" ] ; then
# SYNC_SERVER=rsync.archlinux.org::ftp
+
OTHER_PID=`/bin/cat $LCK_FLE`
SYNC_SERVER=distro.ibiblio.org::distros/archlinux
+
echo "Another instance already running: $OTHER_PID"
+
exit 1
# Set the format of the log file name
+
# This example will output something like this: sync_20070201-8.log
+
LOG_FILE="pkgsync_$(date +%Y%m%d-%H).log"
+
+
# Do not edit the following lines, they protect the sync from running more than
+
# one instance at a time
+
  if [ ! -d $SYNC_HOME ]; then
+
  echo "$SYNC_HOME does not exist, please create it, then run this script again."
+
  exit 1
+
 
  fi
 
  fi
 +
echo $$ > "$LCK_FLE"
 
   
 
   
  [ -f $SYNC_LOCK ] && exit 1
+
  for REPO in $REPOS ; do
touch "$SYNC_LOCK"
+
echo "Syncing $REPO"
  # End of non-editable lines
+
echo /usr/bin/rsync $RSYNC_OPTS ${SOURCE}/${REPO} ${DEST}
 +
  done
 
   
 
   
  # Create the log file and insert a timestamp
+
  # Cleanup
  touch "$SYNC_LOGS/$LOG_FILE"
+
  /bin/rm -f "$LCK_FLE"
echo "=============================================" >> "$SYNC_LOGS/$LOG_FILE"
+
echo ">> Starting sync on $(date --rfc-3339=seconds)" >> "$SYNC_LOGS/$LOG_FILE"
+
echo ">> ---" >> "$SYNC_LOGS/$LOG_FILE"
+
 
   
 
   
if [ -z $SYNC_REPO ]; then
 
  # Sync a complete mirror
 
  rsync -rptLv --delete-after --delay-updates $SYNC_SERVER "$SYNC_FILES" >> "$SYNC_LOGS/$LOG_FILE"
 
else
 
  # Sync each of the repositories set in $SYNC_REPO
 
  for repo in ${SYNC_REPO[@]}; do
 
    repo=$(echo $repo | tr [:upper:] [:lower:])
 
    echo ">> Syncing $repo to $SYNC_FILES/$repo" >> "$SYNC_LOGS/$LOG_FILE"
 
 
    # If you only want to mirror i686 packages, you can add
 
    # " --exclude=os/x86_64" after "--delete-after"
 
    #
 
    # If you only want to mirror x86_64 packages, use "--exclude=os/i686"
 
    # If you want both i686 and x86_64, leave the following line as it is
 
    #
 
    rsync -rptlv --safe-links --delete-after --delay-updates $SYNC_SERVER/$repo "$SYNC_FILES" >> "$SYNC_LOGS/$LOG_FILE"
 
 
    # Create $repo.lastsync file with timestamp like "2007-05-02 03:41:08+03:00"
 
    # which may be useful for users to know when the repository was last updated
 
    # date --rfc-3339=seconds > "$SYNC_FILES/$repo.lastsync"
 
 
    # Sleep 5 seconds after each repository to avoid too many concurrent connections
 
    # to rsync server if the TCP connection does not close in a timely manner
 
    sleep 5
 
  done
 
fi
 
 
# Insert another timestamp and close the log file
 
echo ">> ---" >> "$SYNC_LOGS/$LOG_FILE"
 
echo ">> Finished sync on $(date --rfc-3339=seconds)" >> "$SYNC_LOGS/$LOG_FILE"
 
echo "=============================================" >> "$SYNC_LOGS/$LOG_FILE"
 
echo "" >> "$SYNC_LOGS/$LOG_FILE"
 
 
# Remove the lock file and exit
 
rm -f "$SYNC_LOCK"
 
 
  exit 0
 
  exit 0
  
这并不是什么十分精美的,而只是一个能完成我们所需的稍微高级的bash脚本。让我们使其具有可执行权限。
+
==== 另外一个使用 lftp 的脚本 ====
 
+
lftp 可以通过许多不同的协议来做镜像,如: ftp,http。它会在出错时重启,而且可以在后台运行。把如下代码放置到你的 $PATH 可以方便地使你在登出后镜像仍正常工作。
chmod +x scripts/mirrorsync.sh
+
 
+
现在你已经有一个很容易修改的脚本。不过你可能不是很愿意每次都手动执行,我们可以设置一个cron任务来运行它。
+
 
+
在进行下一步前注意:你的 logs 目录将会逐渐增大。确保定期检查目录大小以防你的服务器因此崩溃。推荐设置 [[LogRotate]] 或者写一些清理脚本以处理。
+
 
+
== 运行  cron 任务 ==
+
 
+
首先,确保具有必须的 cron 工具 (大多数的Archlinux都有):
+
 
+
pacman -S dcron
+
 
+
我们将用 <tt>crontab</tt> 运行 cron 任务。详情,参见 <tt>man crontab</tt>。用 crontab 而不是散落在 <tt>/etc/cron.*</tt> 各处的文件,来执行 sync 的好处是更高的安全性。它也使脚本运行有了更高级的控制。
+
 
+
以如下内容创建 <tt>scripts/mirror.cron</tt> :
+
 
+
0 3 * * * /home/mirror/scripts/mirrorsync.sh
+
 
+
现在我们要激活我们的 crontab:
+
 
+
sudo -u mirror crontab scripts/mirror.cron
+
 
+
确认该 crontab 得到了我们的任务:
+
 
+
sudo -u mirror crontab -l
+
 
+
你将会看到 <tt>scripts/mirror.cron</tt> 的内容被显示出来。如果没有重新运行以上命令并检查。
+
 
+
这个 cron 设置将会在每天凌晨3点运行我们的 sync.sh 脚本。你可以随意调整这个时间,参见 http://www.adminschoice.com/docs/crontab.htm 了解更多 crontab 语法。
+
 
+
=== 修改 cron 任务 ===
+
如果你需要修改 <tt>mirror.cron</tt>,使用以下命令:
+
 
+
sudo -u mirror crontab -e
+
 
+
如果你手动修改了这个文件,使用以下命令更新 crontab:
+
 
+
sudo -u mirror crontab scripts/mirror.cron
+
 
+
现在我们开始设置 pacman 来使用这个本地镜像。
+
 
+
== 设置 pacman 使用本地镜像 ==
+
 
+
如果只想在一台计算机上访问镜像,按照如下步骤进行。
+
 
+
=== 单台计算机 ===
+
 
+
'''注意:''' 如果你只是为一台计算机准备本地镜像,那就是毫无意义地占用了大量的带宽。为需要的人节约带宽吧。应用本节需同样遵循以下各节。
+
 
+
这种情况下你无需 vsftpd,因为我们将使用 file:// 定位符访问文件,而不是 ftp:// 定位符。
+
 
+
Add the following line to the top of <tt>/etc/pacman.d/core</tt>, at the top of the Servers list:
+
 
+
Server = file:///home/mirror/files/core/os/i686
+
 
+
You should also add this line, substituting <tt>/core/</tt> for the name of the repository you are mirroring (e.g.: for community, the line should look like this):
+
 
+
Server = file:///home/mirror/files/community/os/i686
+
 
+
Also be sure to change <tt>i686</tt> to <tt>x86_64</tt> if you are using a 64bit version of Arch.
+
 
+
=== 多台计算机 ===
+
 
+
Syncing this way will allow you to use FTP to access your local mirror from other machines. You can also use this method to sync to your local machine (more details on this later).
+
 
+
==== FTP服务器配置 ====
+
 
+
The first thing we need to do is configure vsftpd. Edit <tt>/etc/vsftpd.conf</tt> to look like this:
+
 
+
# vsftpd config file /etc/vsftpd.conf
+
#
+
# Setup for a secure anonymous FTP server
+
#
+
# Listen (non-xinetd) mode
+
listen=YES
+
# Use tcp_wrappers to control connections
+
tcp_wrappers=YES
+
# Use localtimes instead of GMT for files
+
use_localtime=YES
+
# Hide the true user/group ID of files
+
hide_ids=YES
+
#
+
# Enable anonymous access (pacman requires this)
+
anonymous_enable=YES
+
# Use this user for anonymous logins
+
ftp_username=mirror
+
# Chroot directory for anonymous user
+
anon_root=/home/mirror/files
+
# Don't require a password for anonymous access (pacman requires this)
+
no_anon_password=YES
+
#
+
# User to run vsftpd as (same as ftp_username)
+
nopriv_user=mirror
+
# Enable recursive "ls" listing
+
ls_recurse_enable=YES
+
#
+
# Forcefully destroy sessions after X seconds of inactivity
+
# (It is highly recommended to not set this above 300)
+
idle_session_timeout=120
+
# Forcefully stop sending data after X seconds of inactivity during a transfer
+
# (It is highly recommended to not set this higher than idle_session_timeout)
+
data_connection_timeout=30
+
 
+
This setup will offer a very secure FTP server, tailored specifically for our needs. Note that this setup does '''not''' require a password, and should not be used in a publicly accessible network (unless that's what you want). ''Password protecting the FTP and still allowing it to work with pacman is beyond the scope of this document.''
+
 
+
If you are going to connect to this machine from the outside, you will need to add the following line to <tt>/etc/hosts.allow</tt>:
+
 
+
vsftpd : ALL : ALL
+
 
+
Note that this will allow '''anyone''' to download from the mirror. If you want to control downloads more tightly, and don't know how to do so, see [http://linux.about.com/od/commands/l/blcmdl5_hostsal.htm linux.about.com] on the subject.
+
 
+
Let's make sure vsftpd starts:
+
 
+
sudo /etc/rc.d/vsftpd start
+
 
+
If vsftpd does not start, check that the options are set correctly in your <tt>/etc/vsftpd.conf</tt> file.
+
 
+
==== Enabling the mirror for pacman ====
+
 
+
Now let's edit <tt>/etc/pacman.d/*</tt> files to use our shiny new mirror. Add the following line to the top of <tt>/etc/pacman.d/core</tt>, at the top of the Servers list:
+
 
+
Server = ftp://192.168.1.21/core/os/i686
+
 
+
Note that <tt>192.168.1.21</tt> is the IP address of my test machine. Your address will most likely be different. (Remember that you can get the current IP of an Arch box with <tt>ifconfig -a</tt> or <tt>ifconfig eth0</tt>.)
+
 
+
If you want to use this same mirror on the local machine, use the following Server line:
+
 
+
Server = ftp://localhost/core/os/i686
+
 
+
Repeat this same process for the other repositories you are mirroring. Non-local machines will need to use an IP address to access the repository. Also make sure that the machine serving the mirror has a static IP address.
+
  
== Synchronizing for the first time ==
+
#!/usr/bin/lftp -f
 +
lcd /local/path/to/your/mirror
 +
open ftp.archlinux.org (or whatever your favorite mirror is)
 +
# Use 'cd' to change into the proper directory on the mirror, if necessary.
 +
mirror -cve -x '.*i686.*' core &
 +
mirror -cve -x '.*i686.*' extra &
 +
mirror -cve -x '.*i686.*' community &
 +
mirror -cve -x '.*i686.*' multilib &
 +
lcd pool
 +
cd pool
 +
mirror -cve -x '.*i686.*' community &
 +
mirror -cve -x '.*i686.*' packages &
  
Here comes the pain! Run the following command to start the sync:
+
如果你想要查看当前镜像的状态,在终端打开 lftp ,输入 'attach <PID>'
  
sudo -u mirror ./scripts/mirrorsync.sh
+
==== 部分镜像 ====
  
This won't give you any kind of output, but you probably want some. You can use something like this (correct for the name of log file) to monitor the sync progress:
+
由于大多数软件包集中在 `pool/`,仅镜像部分软件库显然不容易。
 +
[http://blog.invokk.net/2012/01/mirroring-only-some-repositories-of-archlinux/ 这篇博文] 提供了一个脚本用于完成此任务。
  
tail -f logs/pkgsync_20070203-9.log
+
==== 服务 ====
 +
*HTTP (LAN)
 +
**[[LAMP]]
 +
**[[Lighttpd]]
 +
*FTP (LAN)
 +
**[[vsftpd]]
 +
*物理媒介
 +
**闪存
 +
**移动硬盘
  
This process will usually take a few hours, depending on the speed of your internet connection and how many repositories you are mirroring. After the first sync, only new packages will be sync'ed, so it will be m
+
=== 客户端配置 ===
 +
*在 /etc/pacman.d/mirrorlist 添加合适的 Server = variable
 +
*对于物理媒介 (例如闪存),可以输入如下内容: Server = file:///mnt/media/repo/$repo/os/$arch (''/mnt/media/repo 是本地镜像位于的目录'')

Revision as of 19:33, 25 May 2013

翻译状态: 本文是英文页面 Local_Mirror翻译,最后翻译时间:2013-05-26,点击这里可以查看翻译后英文页面的改动。
警告: 如果你想创建一个官方镜像,参考 这个页面

稍等

警告: 通常不赞成创建一个本地镜像,因为需要很大的带宽。其中一个替代的方法也许会满足你的要求。请查看下面的替代方法。

替代方法

本地镜像

需要牢记的事实

  • 镜像的带宽不是免费的,镜像必须为提供给你的数据付费
    • 尽管你已经为你的 ISP 付费,这也是成立的。
  • 有很多你可能下载了却永远用不到的包
  • 镜像的管理员会更喜欢让你仅下载需要的包
  • 再次请求仔细查看上面的替代方案

如果你完全确定本地镜像是唯一合适的解决方案,那么按照下面的指引操作。

服务器设置

编写 Rsync 命令

  • 参照 DeveloperWiki:NewMirrors 使用 rsync 参数
  • 从上文中选择一个服务器
  • 在 rsync 参数中包含 --exclude-from="/path/to/exclude.txt" 以排除那些你不想包含的目录或文件。示例内容可能包括:
iso

#Exclude i686 Packages
*/os/i686
pool/*/*-i686.pkg.tar.xz
pool/*/*-i686.pkg.tar.gz

#Exclude x86_64 Packages
*/os/x86_64
pool/*/*-x86_64.pkg.tar.xz
pool/*/*-x86_64.pkg.tar.gz
  • 所有软件包都位于 pool 目录。然后从 pool 创建符号到 to core/extra/testing/etc。
    • 截至 9/21/2010 此迁移仍没有完成。
      • 在 ${repo}/os/${arch} 中应该有确切的软件包,而不是符号链接
  • 排除那些你不需要的顶极目录

例如: rsync $rsync_arguments --exclude="/path/to/exclude.txt" rsync://example.com/ /path/to/destination

示例脚本

警告: 除非你阅读了本文开头的警告,否则不要使用本脚本
警告: 仅使用本脚本同步 Core/Extra/Community! 如果你需要 Testing,gnome-unstable 或是任何其他软件库,另外使用 rsync --exclude!

是的,为了避免人们以复制粘贴的形式搭建他们自己的镜像,本脚本 故意 缺失了部分内容。如果你确实想要搭建一个镜像,错误是很容易修补的。

#!/bin/bash

#################################################################################################
### It is generally frowned upon to create a local mirror due the bandwidth that is required.
### One of the alternatives will likely fulfill your needs.
### REMEMBER:
###   * Bandwidth is not free for the mirrors. They must pay for all the data they serve you
###       => This still applies although you pay your ISP 
###       => There are many packages that will be downloaded that you will likely never use
###       => Mirror operators will much prefer you to download only the packages you need
###   * Really please look at the alternatives on this page:
###       https://wiki.archlinux.org/index.php?title=Local_Mirror
### If you are ABSOLUTELY CERTAIN that a local mirror is the only sensible solution, then this
### script will get you on your way to creating it. 
#################################################################################################

# Configuration
SOURCE='rsync://mirror.example.com/archlinux'
DEST='/srv/mirrors/archlinux'
BW_LIMIT='500'
REPOS='core extra'
RSYNC_OPTS="-rtlHq --delete-after --delay-updates --copy-links --safe-links --max-delete=1000 --bwlimit=${BW_LIMIT} --delete-excluded --exclude=.*"
LCK_FLE='/var/run/repo-sync.lck'

# Make sure only 1 instance runs
if [ -e "$LCK_FLE" ] ; then
	OTHER_PID=`/bin/cat $LCK_FLE`
	echo "Another instance already running: $OTHER_PID"
	exit 1
fi
echo $$ > "$LCK_FLE"

for REPO in $REPOS ; do
	echo "Syncing $REPO"
	echo /usr/bin/rsync $RSYNC_OPTS ${SOURCE}/${REPO} ${DEST}
done

# Cleanup
/bin/rm -f "$LCK_FLE"

exit 0

另外一个使用 lftp 的脚本

lftp 可以通过许多不同的协议来做镜像,如: ftp,http。它会在出错时重启,而且可以在后台运行。把如下代码放置到你的 $PATH 可以方便地使你在登出后镜像仍正常工作。

#!/usr/bin/lftp -f
lcd /local/path/to/your/mirror
open ftp.archlinux.org (or whatever your favorite mirror is)
# Use 'cd' to change into the proper directory on the mirror, if necessary.
mirror -cve -x '.*i686.*' core &
mirror -cve -x '.*i686.*' extra &
mirror -cve -x '.*i686.*' community &
mirror -cve -x '.*i686.*' multilib &
lcd pool
cd pool
mirror -cve -x '.*i686.*' community &
mirror -cve -x '.*i686.*' packages &

如果你想要查看当前镜像的状态,在终端打开 lftp ,输入 'attach <PID>'

部分镜像

由于大多数软件包集中在 `pool/`,仅镜像部分软件库显然不容易。 这篇博文 提供了一个脚本用于完成此任务。

服务

客户端配置

  • 在 /etc/pacman.d/mirrorlist 添加合适的 Server = variable
  • 对于物理媒介 (例如闪存),可以输入如下内容: Server = file:///mnt/media/repo/$repo/os/$arch (/mnt/media/repo 是本地镜像位于的目录)