apt-mirror Ubuntu APT 包镜像/同步工具
安装
$ sudo apt-get install apt-mirror
使用
apt-mirror 配置
sudo mkdir /ubuntu-apt
cat << EOF > /etc/apt/mirror.list
############# config ##################
#
# set base_path /var/spool/apt-mirror
set base_path /ubuntu-apt
#
# 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 jammy main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu jammy-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu jammy-updates main restricted universe multiverse
#deb http://archive.ubuntu.com/ubuntu jammy-proposed main restricted universe multiverse
#deb http://archive.ubuntu.com/ubuntu jammy-backports main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu jammy main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu jammy-security main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu jammy-updates main restricted universe multiverse
#deb-src http://archive.ubuntu.com/ubuntu jammy-proposed main restricted universe multiverse
#deb-src http://archive.ubuntu.com/ubuntu jammy-backports main restricted universe multiverse
clean http://archive.ubuntu.com/ubuntu
EOF
同步
apt-mirror
# 或通过 crontab 定时同步
$ sudo crontab -e
# 增加一行,每天凌晨两点同步
0 2 * * * apt-mirror /usr/bin/apt-mirror > /var/spool/apt-mirror/var/cron.log
Nginx 代理配置
docker run \
--name apt-repository \
--restart unless-stopped \
-p 80:80 \
-v /ubuntu-apt/skel/archive.ubuntu.com/:/usr/share/nginx/html \
-d nginx:latest
客户端配置
- 客户端配置
/etc/apt/source.list
deb http://<apt-ip>/ubuntu jammy main restricted universe multiverse
deb http://<apt-ip>/ubuntu jammy-security main restricted universe multiverse
deb http://<apt-ip>/ubuntu jammy-updates main restricted universe multiverse
其他思路
扩展
ubuntu 使用 iso 软件包
# 挂载
sudo mount -o loop usb/ubunto.iso /media/cdrom
# 添加源,-m 参数使用 /media/cdrom 作为节点添加到 /etc/apt/sources.list 中
sudo apt-cdrom add -m
# 使用
apt-get update
其他
deb https://nvidia.github.io/libnvidia-container/ubuntu16.04/amd64 /
deb https://nvidia.github.io/nvidia-container-runtime/ubuntu16.04/amd64 /
deb https://nvidia.github.io/nvidia-docker/ubuntu16.04/amd64 /
clean https://nvidia.github.io/libnvidia-container/ubuntu16.04/amd64/
clean https://nvidia.github.io/nvidia-container-runtime/ubuntu16.04/amd64/
clean https://nvidia.github.io/nvidia-docker/ubuntu16.04/amd64/