ubuntu配置本地apt仓库
发行信息
- 代号取
Code name
前一个单词缩写 - 官方版本信息
apt-mirror
-
作用:同步工具
-
安装:
apt install apt-mirror -y
-
安装完成后,会生成文件
/etc/apt/mirror.list
,最好备份一份
mirror.list配置
默认配置:
############# config ##################
#
# set base_path /var/spool/apt-mirror
#
# set mirror_path $base_path/mirror
# set skel_path $base_path/skel
# set var_path $base_path/var
# set cleanscript $var_path/clean.sh
# set defaultarch <running host architecture>
# set postmirror_script $var_path/postmirror.sh
# set run_postmirror 0
set nthreads 20
set _tilde 0
#
############# end config ##############
deb http://archive.ubuntu.com/ubuntu artful main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu artful-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu artful-updates main restricted universe multiverse
#deb http://archive.ubuntu.com/ubuntu artful-proposed main restricted universe multiverse
#deb http://archive.ubuntu.com/ubuntu artful-backports main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu artful main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu artful-security main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu artful-updates main restricted universe multiverse
#deb-src http://archive.ubuntu.com/ubuntu artful-proposed main restricted universe multiverse
#deb-src http://archive.ubuntu.com/ubuntu artful-backports main restricted universe multiverse
clean http://archive.ubuntu.com/ubuntu
自用ubuntu1804使用的配置:
-
请确认默认的
base_path
空间足够,否则请更换路径 -
增加
arch
字段,这样下载的包更全,如有需要,可再添加arm64
,用以下载arm
包,对应的地址也需要修改为http://archive.ubuntu.com/ubuntu-ports/
-
默认使用官方源,使用
nload
命令可以查看网速,如果速度慢的话可以尝试替换为下方国内源。建议还是使用官方源,实测即使换成国内源将线程改大,下载速度依然是
20MB
左右,且国内源会报一些错误mirrors.tuna.tsinghua.edu.cn
mirrors.ustc.edu.cn
############# config ##################
#
# set base_path /var/spool/apt-mirror
#
# set mirror_path $base_path/mirror
# set skel_path $base_path/skel
# set var_path $base_path/var
# set cleanscript $var_path/clean.sh
# set defaultarch <running host architecture>
# set postmirror_script $var_path/postmirror.sh
# set run_postmirror 0
set nthreads 20
set _tilde 0
#
############# end config ##############
deb [arch=amd64] http://archive.ubuntu.com/ubuntu bionic main restricted universe multiverse
deb [arch=amd64] http://archive.ubuntu.com/ubuntu bionic-security main restricted universe multiverse
deb [arch=amd64] http://archive.ubuntu.com/ubuntu bionic-updates main restricted universe multiverse
deb [arch=i386] http://archive.ubuntu.com/ubuntu bionic main restricted universe multiverse
deb [arch=i386] http://archive.ubuntu.com/ubuntu bionic-security main restricted universe multiverse
deb [arch=i386] http://archive.ubuntu.com/ubuntu bionic-updates main restricted universe multiverse
deb-src [arch=amd64] http://archive.ubuntu.com/ubuntu bionic main restricted universe multiverse
deb-src [arch=amd64] http://archive.ubuntu.com/ubuntu bionic-security main restricted universe multiverse
deb-src [arch=amd64] http://archive.ubuntu.com/ubuntu bionic-updates main restricted universe multiverse
deb-src [arch=i386] http://archive.ubuntu.com/ubuntu bionic main restricted universe multiverse
deb-src [arch=i386] http://archive.ubuntu.com/ubuntu bionic-security main restricted universe multiverse
deb-src [arch=i386] http://archive.ubuntu.com/ubuntu bionic-updates main restricted universe multiverse
clean http://archive.ubuntu.com/ubuntu
开始同步
使用screen命令,开启会话,放至中断,然后执行apt-mirror
即可,大概需要300GB左右的数据
客户端配置
- 根据自己的下载路径,替换
file:///root/mirror/archive.ubuntu.com/ubuntu
deb [arch=amd64] file:///root/mirror/archive.ubuntu.com/ubuntu bionic main restricted universe multiverse
deb-src [arch=amd64] file:///root/mirror/archive.ubuntu.com/ubuntu bionic main restricted universe multiverse
deb [arch=amd64] file:///root/mirror/archive.ubuntu.com/ubuntu bionic-security main restricted universe multiverse
deb-src [arch=amd64] file:///root/mirror/archive.ubuntu.com/ubuntu bionic-security main restricted universe multiverse
deb [arch=amd64] file:///root/mirror/archive.ubuntu.com/ubuntu bionic-updates main restricted universe multiverse
deb-src [arch=amd64] file:///root/mirror/archive.ubuntu.com/ubuntu bionic-updates main restricted universe multiverse
deb [arch=amd64] file:///root/mirror/archive.ubuntu.com/ubuntu bionic-backports main restricted universe multiverse
deb-src [arch=amd64] file:///root/mirror/archive.ubuntu.com/ubuntu bionic-backports main restricted universe multiverse