镜像 kernel.org 仓库

如果您想镜像 kernel.org 的全部或部分 git 仓库,请使用我们为此目的编写的工具,称为 grokmirror。 Grokmirror 具有 git 感知能力,将创建 kernel.org 仓库的完整镜像,并使其自动更新,而无需您进一步参与。

Grokmirror 的工作原理是下载并比较主清单文件,从而跟踪正在更新的仓库。 仅当服务器上的文件更新时才会下载此文件,并且仅通过 "git remote update" 更新已更改的仓库。

您可以阅读 README 文件,了解有关 grokmirror 的更多信息。

获取 grokmirror

如果 grokmirror 尚未为您的发行版打包,您可以从 git 仓库获取它

git clone git://git.kernel.org/pub/scm/utils/grokmirror/grokmirror.git

除了 git 之外,您还需要在镜像服务器上安装以下 Python 依赖项

设置 kernel.org 镜像

建议您创建一个专用的 "mirror" 用户,该用户将拥有所有内容并运行所有 cron 作业。 通常不鼓励以 "root" 用户身份运行此程序。

默认的 repos.conf 已经预配置为 kernel.org。 我们在此处重现最小配置

[kernel.org]
site = git://git.kernel.org
manifest = http://git.kernel.org/manifest.js.gz
default_owner = Grokmirror User
#
# Where are we going to put the mirror on our disk?
toplevel = /var/lib/git/mirror
#
# Where do we store our own manifest? Usually in the toplevel.
mymanifest = /var/lib/git/mirror/manifest.js.gz
#
# Where do we put the logs?
log = /var/log/mirror/kernelorg.log
#
# Log level can be "info" or "debug"
loglevel = info
#
# To prevent multiple grok-pull instances from running at the same
# time, we first obtain an exclusive lock.
lock = /var/lock/mirror/kernelorg.lock
#
# Use shell-globbing to list the repositories you would like to mirror.
# If you want to mirror everything, just say "*". Separate multiple entries
# with newline plus tab. Examples:
#
# mirror everything:
#include = *
#
# mirror just the main kernel sources:
#include = /pub/scm/linux/kernel/git/torvalds/linux.git
#          /pub/scm/linux/kernel/git/stable/linux-stable.git
#          /pub/scm/linux/kernel/git/next/linux-next.git
#
# mirror just git:
#include = /pub/scm/git/*
include = *
#
# This is processed after the include. If you want to exclude some specific
# entries from an all-inclusive globbing above. E.g., to exclude all
# linux-2.4 git sources:
#exclude = */linux-2.4*
exclude =

将此配置文件安装在您的环境中合理的任何位置。 您需要确保以下目录(或您更改为的任何目录)可由 "mirror" 用户写入

  • /var/lib/git/mirror
  • /var/log/mirror
  • /var/lock/mirror

镜像 kernel.org git 仓库

现在,您需要做的就是添加一个 cronjob,该作业将检查 kernel.org 镜像以进行更新。 以下条目在/etc/cron.d/grokmirror.cron中,将每 5 分钟检查一次镜像

# Run grok-pull every 5 minutes as "mirror" user
*/5 * * * * mirror /usr/bin/grok-pull -p -c /etc/grokmirror/repos.conf

(您需要相应地调整 grok-pull 命令和 repos.conf 的路径以反映您的环境。)

初始运行将需要数小时才能完成,因为它需要下载大约 50 GB 的数据。

镜像仓库的子集

如果您只对携带 git 仓库的子集而不是全部仓库感兴趣,欢迎您调整include (包含)exclude (排除)参数。

其他资源

社交