linux ubuntu 本地镜像 软件源 制作方法

时间:2023-03-10 06:54:19
linux ubuntu 本地镜像 软件源 制作方法

1、配置当前软件源,镜像非常大,所以首先要配置一下载速度快的软件源http://fffo.blog.163.com/blog/static/2119130682014322104136601/2、安装镜像软件 并 修改镜像参数文件
1)、安装apt-mirror
sudo apt-get install apt-mirror
2)、修改mirror.list

http://www.linuxidc.com/Linux/2014-08/105415.htm

sudo gedit /etc/apt/mirror.list
文件内容如下:
 ——————————————引用开始——————————————————
############# config ##################
#
# set base_path /var/spool/apt-mirror [镜像存放目录位置,可根据磁盘容量情况进行更改]
#
# if you change the base path you must create the directories below with write privileges
#
# 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 nthreads 3 [下载进程,默认20,建议3]
set _tilde 0
#
############# end config ##############

deb http://archive.ubuntu.com/ubuntu jaunty main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu jaunty-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu jaunty-backports main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu jaunty-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu jaunty-proposed main restricted universe multiverse
deb http://archive.ubuntu.org.cn/ubuntu-cn/ jaunty main restricted universe multiverse

[需要进行镜像的APT软件源地址,选择速度较快的官方源或国内源]

#deb-src http://archive.ubuntu.com/ubuntu jaunty main restricted universe multiverse
#deb-src http://archive.ubuntu.com/ubuntu jaunty-updates main restricted universe multiverse
#deb-src http://archive.ubuntu.com/ubuntu jaunty-backports main restricted universe multiverse
#deb-src http://archive.ubuntu.com/ubuntu jaunty-security main restricted universe multiverse
#deb-src http://archive.ubuntu.com/ubuntu jaunty-proposed main restricted universe multiverse

[不需要源代码,用#进行地址屏蔽]

clean http://archive.ubuntu.com/ubuntu

clean http://archive.ubuntu.org.cn/ubuntu-cn

[镜像完成后对本地镜像和软件源进行比较]

——————————————引用结束——————————————————
3、创建镜像根目录
mkidr /var/spool/apt-mirror
4、开始镜像(支持断点续传,任何中断都不会照成影响)
1)sudo apt-mirror
定时执行上面的命令,可以达到定时同步远程仓库的效果
2)完成镜像后进行清理多余文件
sudo /var/spool/apt-mirror/var/clean.sh

5、使用本地源
cd /etc/apt
sudo mv source.list source.list.bak
sudo vim source.list
加入如下内容
deb file:///var/spool/apt-mirror/mirror/archive.ubuntu.com/ubuntu/ jaunty main restricted universe multiverse
deb file:///var/spool/apt-mirror/mirror/archive.ubuntu.com/ubuntu/ jaunty-backports restricted universe multiverse
deb file:///var/spool/apt-mirror/mirror/archive.ubuntu.com/ubuntu/ jaunty-proposed main restricted universe multiverse
deb file:///var/spool/apt-mirror/mirror/archive.ubuntu.com/ubuntu/ jaunty-security main restricted universe multiverse
deb file:///var/spool/apt-mirror/mirror/archive.ubuntu.com/ubuntu/ jaunty-updates main restricted universe multiverse

deb file:///var/spool/apt-mirror/mirror/archive.ubuntu.org.cn/ubuntu-cn/ jaunty main restricted universe multiverse

6、发布到局域网
1)安装Apache2
sudo apt-get install apache2

linux ubuntu 本地镜像 软件源 制作方法
2)建立符号连接,将镜像与Apache虚拟目录联系起来
sudo ln -s /var/spool/apt-mirror/mirror/archive.ubuntu.com/ubuntu/ /var/www/html/ubuntu
linux ubuntu 本地镜像 软件源 制作方法

linux ubuntu 本地镜像 软件源 制作方法
3)局域网中每个用户,修改sources.list文件
cd /etc/apt
sudo cp sources.list sources.list.bak
sudo vim source.list
加入如下内容
deb http://192.168.0.10/ubuntu jaunty main restricted universe multiverse
deb http://192.168.0.10/ubuntu jaunty-backports restricted universe multiverse
deb http://192.168.0.10/ubuntu jaunty-proposed main restricted universe multiverse
deb http://192.168.0.10/ubuntu jaunty-security main restricted universe multiverse
deb http://192.168.0.10/ubuntu jaunty-updates main restricted universe multiverse

deb http://192.168.0.10/ubuntu-cn jaunty main restricted universe multiverse