先介绍一下条件,翻译得不得了还请大家见谅

 

转:http://forum.ubuntu.org.cn/viewtopic.php?t=41791

先介绍一下条件:

先是次翻译,翻译得不得了还请我们见谅,多多提出错误~!:)
初稿能够见如下的贴子:http://forum.ubuntu.org.cn/viewtopic.php?t=40082&highlight=%E7%BF%BB%E8%AF%91
运用apt-mirror建立法局域网内的Debian/Ubuntu源镜像
Version 1.0
Author: Falko Timme <ft [at] falkotimme [dot] com>
Last edited 12/26/2006
翻译:icyfire (icyfire0105@gmail.com)
本课程将教导你什么样使用apt-mirror建立法局域网内的Debian/Ubuntu源镜像。即使您须求在局域网内安装多套系统,那么建立二个当地的Debian/Ubuntu源镜像将会便宜,在您更新系统的时候将收获比网络连接快得多的速度,而且还可以省掉您的网络带宽。
自家先是想说的是本文所讲的方法并不是唯第1建工公司立Debian/Ubuntu源镜像的法子。有那三个主意能够达到规定的标准那一个指标,可是这却是作者使用的点子。笔者并不保障这一个方法适用于你。
1 中期准备
您能够在debian和ubuntu系统上树立Debian/Ubuntu源镜像,也正是说,debian系统能够创设Debian和Ubuntu源镜像,ubuntu系统上也能树立Debian和Ubuntu源镜像。
急需留意的是要树立3个源镜像你要求有二个快一些的总是和丰硕大的硬盘空间。在自家的测试进度中本人做了四个Debian
Sarge的main,contrib 和non-free部分的镜像和 Ubuntu 艾德gy Eft的 main,
restricted,
universe部分的镜像,这一起占用了差不离25G的硬盘空间,在16M的DSL的带宽下,花了6钟头的时刻才下载完。
自家从没成立安全体分的镜像,因为自个儿认为一直从互连网上下载安全更新会更好一些,因为那样能够保障你总能得到最新的本子。
本测试基于 Debian Sarge 和Ubuntu 艾德gy
Eft操作系统,如若您选取的是别的的版本,那么那几个手续或者会有微小的距离。你须要设置3个为主的
Debian Sarge 系统(安装步骤
http://www.howtoforge.com/perfect_setup_debian_sarge)或许 Ubuntu 艾德gy
Eft系统(安装步骤http://www.howtoforge.com/perfect\_setup\_ubuntu\_6.10)
以此例子中本地源镜像的ip是192.168.0.100.
2,1安装apt-mirror
修改/etc/apt/sources.list(Debian Sarge必须)
借使您安装的是 Debian Sarge,你无法不要修改sources.list.作者不清楚Debian
Etch 只怕 Sid是不是必需求修改,你能够友善尝尝一下。对Ubuntu 艾德gy Eft.
这一步不适必须的。

主机:Win7

代码:

虚拟机:VirtualBox + Debian7

vi /etc/apt/sources.list

鉴于软件源的容量相比大,所以本身又给虚拟机添加了一块50GB的虚拟硬盘(给虚拟机添加虚拟硬盘的法子参见:http://www.cnblogs.com/pengdonglin137/p/3366589.html

当中介绍了哪些在Vmware和VirtualBox中给Linux虚拟机添加虚拟硬盘),然后修改/etc/fstab,使在系统运行的时候将其活动挂载到/home/pengdl/debian_source目录下。

投入上边怪这一行。

上边步入正题:

代码:

第一步、安装apt-mirror工具

实践如下命令:

sudo apt-get install
apt-mirror

deb http://apt-mirror.sourceforge.net/ apt-mirror/

第二步、配置apt-mirror

sudo vim /etc/apt/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://ftp.us.debian.org/debian unstable main contrib non-free
deb-src http://ftp.us.debian.org/debian unstable main contrib non-free

# mirror additional architectures
#deb-alpha http://ftp.us.debian.org/debian unstable main contrib non-free
#deb-amd64 http://ftp.us.debian.org/debian unstable main contrib non-free
#deb-armel http://ftp.us.debian.org/debian unstable main contrib non-free
#deb-hppa http://ftp.us.debian.org/debian unstable main contrib non-free
#deb-i386 http://ftp.us.debian.org/debian unstable main contrib non-free
#deb-ia64 http://ftp.us.debian.org/debian unstable main contrib non-free
#deb-m68k http://ftp.us.debian.org/debian unstable main contrib non-free
#deb-mips http://ftp.us.debian.org/debian unstable main contrib non-free
#deb-mipsel http://ftp.us.debian.org/debian unstable main contrib non-free
#deb-powerpc http://ftp.us.debian.org/debian unstable main contrib non-free
#deb-s390 http://ftp.us.debian.org/debian unstable main contrib non-free
#deb-sparc http://ftp.us.debian.org/debian unstable main contrib non-free

clean http://ftp.us.debian.org/debian

将其修改为对友好比较快的源,这里自个儿用的是 
http://ftp.cn.debian.org/debian/ wheezy main contrib non-free

因为本身要将今后下载的源放到/home/pengdl/debian_source上边,所以未来该目录下创办多少个文本夹(具体是那么些文件夹,能够参见上边的布署文件):

/home/pengdl/debian_source/mirror

/home/pengdl/debian_source/skel

/home/pengdl/debian_source/var

上面是本身的安排文件:

############# config ##################
#
# set base_path    /var/spool/apt-mirror
  set base_path    /home/pengdl/debian_source
#
  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-i386 http://ftp.cn.debian.org/debian/ wheezy main contrib non-free

#deb http://ftp.us.debian.org/debian unstable main contrib non-free
#deb-src http://ftp.us.debian.org/debian unstable main contrib non-free

# mirror additional architectures
#deb-alpha http://ftp.us.debian.org/debian unstable main contrib non-free
#deb-amd64 http://ftp.us.debian.org/debian unstable main contrib non-free
#deb-armel http://ftp.us.debian.org/debian unstable main contrib non-free
#deb-hppa http://ftp.us.debian.org/debian unstable main contrib non-free
#deb-i386 http://ftp.us.debian.org/debian unstable main contrib non-free
#deb-ia64 http://ftp.us.debian.org/debian unstable main contrib non-free
#deb-m68k http://ftp.us.debian.org/debian unstable main contrib non-free
#deb-mips http://ftp.us.debian.org/debian unstable main contrib non-free
#deb-mipsel http://ftp.us.debian.org/debian unstable main contrib non-free
#deb-powerpc http://ftp.us.debian.org/debian unstable main contrib non-free
#deb-s390 http://ftp.us.debian.org/debian unstable main contrib non-free
#deb-sparc http://ftp.us.debian.org/debian unstable main contrib non-free

#clean http://ftp.us.debian.org/debian
clean http://ftp.cn.debian.org/debian

接下来实施:

其三步、同步镜像

sudo apt-mirror

联手完结后,大家能够利用clean.sh清理无用软件包(本文书档案以set base_path  
/home/pengdl/debian_source为例):
$sudo sh /home/pengdl/debian_source/var/clean.sh

在平凡的晋升中,我们能够定期执行apt-mirror命令:
$sudo apt-mirror

或许将这几个命令写进crontab中:
30 5    * * *    root    /usr/bin/apt-mirror >>
/var/spool/apt-mirror/var/cron.log
每一天五点25分进行,并在/var/spool/apt-mirror/var/文件夹中生成cron.log日志文件,以有益查看更新情况。

代码:

第5步、访问镜像

apt-get update

壹 、本地访问

sudo vim /etc/apt/sources.list

修改成如下内容:

deb file:/home/pengdl/debian_source/mirror/ftp.cn.debian.org/debian wheezy main contrib non-free

履新软件源:

sudo apt-get update

2.2安装apt-mirror
这一步对Debian和Ubuntu都以必须的,安装apt-mirror,执行

2、通过http访问

想要通过http的格局取伏贴地Debian/Ubuntu的源镜像,由此须求设置apache
web服务器

安装Apache

sudo apt-get install apache2

Apache私下认可的根目录是/var/www,可是软件仓库却在/home/pengdl/debian_source/mirror
为了能够由此 http://192.168.0.100/debian 
走访到相应的软件库,大家能够symlinks /var/www/debian 到真正的库地址。

ln -s
/home/pengdl/debian_source/mirror/ftp.de.debian.org/debian
/var/www/debian
 

修改sources.list
sudo vim /etc/apt/sources.list

修改成如下内容:

deb http://192.168.0.100/debian wheezy main contrib non-free 

或者

deb http://127.0.0.1/debian wheezy main contrib non-free 

执行

sudo apt-get update

要么不行使建立软连接的点子,而是径直修改apatch2的安插文件/etc/apache2/sites-enabled/000-default,把DocumentRoot /var/www改为:

DocumentRoot /home/pengdl/debian_source/mirror/ftp.de.debian.org/debian

接下来重启apache

sudo /etc/init.d/apache2 start

修改sources.list
sudo
vim /etc/apt/sources.list

修改成如下内容:

deb http://192.168.0.100 wheezy main contrib non-free 

或者

deb http://127.0.0.1 wheezy main contrib non-free 

执行

sudo apt-get update

 

完!!

 

参考:

http://forum.ubuntu.org.cn/viewtopic.php?t=41791

http://forum.ubuntu.org.cn/viewtopic.php?t=40082&highlight=%E7%BF%BB%E8%AF%91

http://rex.zhang.name/index.php/2011/05/506

http://www.linuxeden.com/html/sysadmin/20090518/65717.html

http://www.2cto.com/os/201311/254830.html

http://www.linuxidc.com/Linux/2008-09/15841.htm

http://popey.com/blog/2006/10/24/creating_an_ubuntu_repository_mirror_with_apt-mirror/

http://www.debianadmin.com/debian-apt-source-mirror-using-apt-mirror.html#more-50

 

==================================================================================

树立地点ubuntu仓库源
首先,我们要设置apt-mirror
$sudo apt-get install apt-mirror
借使大家将镜像等公事放在 /service/ubuntu文件夹下:
请事先新建以下文件夹(mirror.list里面提醒要大家先行新建文件夹的):
/service/ubuntu
/service/ubuntu/mirror
/service/ubuntu/skel
/service/ubuntu/var
配置apt-mirror:

代码:

$sudo vi /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 privlages
#
# 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 base_path    /service/ubuntu
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 nthreads     20
set _tilde 0
#
############# end config ##############
#咱俩把常用的软件同步过来就丰裕了
deb-i386 http://archive.ubuntu.com/ubuntu hardy main restricted universe
multiverse
deb-i386 http://archive.ubuntu.com/ubuntu hardy-updates main restricted
universe multiverse
deb-i386 http://archive.ubuntu.com/ubuntu hardy-backports main
restricted universe multiverse
deb-i386 http://archive.ubuntu.com/ubuntu hardy-security main restricted
universe multiverse
deb-i386 http://archive.ubuntu.com/ubuntu hardy-proposed main restricted
universe multiverse
#
当有些软件包在服务器端实行了晋级,恐怕服务器端不再要求那一个软件包时,我们运用了apt-mirror与服务器同步后
#会在地面的$var_path/下生成一个clean.sh的台本,列出了遗留在当地的旧版本和失效的软件包,你能够手动运维这么些
#脚本来删除遗留在地头的且不供给用的软件包

apt-get install apt-mirror

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

一旦用amd63位架构下的包,能够添加deb-amd64的号子
设若什么都不加,直接动用deb
http…..那种格式,则在一块时,只同步当前系统所接纳的架构下的软件包。比如八个陆9个人系统,直接deb
http….只同步60个人的软件包。如若还嫌麻烦,直接去改set defaultarch 
<running host architecture>这几个参数就好,比如改成set defaultarch
i386,那样您选拔deb
http…..那种格式,则在一起时,只同步i386的软件包了。
一经你还想要源码,能够把源码也加到mirror.list里面同步过来,比如加上deb-src那样的记号。想要别的的事物也能够追加相应的符号来成功。
配备好后大家就能够和点名的镜像举行协同了
$sudo apt-mirror
假定是首先次联袂,官方镜像大概须求几天时间才能共同完整,假如与国内源实行同步,只同步常用软件,平均1分钟网速1MB(Byte)要一并30G左右的数据,大约供给5-8钟头的年华才能共同完整。
一道到位后,我们得以应用clean.sh清理无用软件包(本文书档案以set base_path  
/server/ubuntu为例):
$sudo sh /service/ubuntu/var/clean.sh
履新达成后,能够行使apache公布源镜像了。
apache可以如此安插:

3安装阿帕奇。
笔者想要通过http的不二法门获得地点Debian/Ubuntu的源镜像,由此供给安装apache
web服务器。

$sudo vi /etc/apache2/sites-enabled/000-default

NameVirtualHost *
<VirtualHost *>
    ServerAdmin webmaster@localhost
#    DocumentRoot /var/www/
    DocumentRoot /service/ubuntu/mirror/archive.ubuntu.com/
    <Directory />
        Options Indexes FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory /var/www/>
        Options FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
    </Directory>

代码:

……..

在一般的晋级中,大家得以定期执行apt-mirror命令:
$sudo apt-mirror
依旧将这几个命令写进crontab中:
30 5    * * *    root    /usr/bin/apt-mirror >>
/var/spool/apt-mirror/var/cron.log
每日五点三十多分履行,并在/var/spool/apt-mirror/var/文件夹中生成cron.log日志文件,以福利查看更新景况。

=============================================================================================

使用apt-mirror建立法局域网内的Debian/Ubuntu源镜像
Version 1.0
Author: Falko Timme <ft [at] falkotimme [dot] com>
Last edited 12/26/2006
翻译:icyfire (icyfire0105@gmail.com)
本课程将指引你什么利用apt-mirror建立法局域网内的Debian/Ubuntu源镜像。若是你供给在局域网内安装多套系统,那么建立叁个地点的Debian/Ubuntu源镜像将会有利于,在你更新系统的时候将获得比网络连接快得多的进程,而且仍是可以省掉您的互连网带宽。
小编第③想说的是本文所讲的法门并不是唯第1建工公司立Debian/Ubuntu源镜像的法门。有很多措施可以达到规定的标准那么些目的,不过那却是作者利用的措施。小编并不保险那个点子适用于您。
1 先前时代准备
你能够在debian和ubuntu系统上创建Debian/Ubuntu源镜像,也等于说,debian系统能够建立Debian和Ubuntu源镜像,ubuntu系统上也能创制Debian和Ubuntu源镜像。
急需注意的是要树立多少个源镜像您须要有贰个快一些的连日和丰盛大的硬盘空间。在本人的测试进程中自身做了三个Debian
Sarge的main,contrib 和non-free部分的镜像和 Ubuntu 艾德gy Eft的 main,
restricted,
universe部分的镜像,这一起占用了大概25G的硬盘空间,在16M的DSL的带宽下,花了6小时的时光才下载完。
作者从未树立安全体分的镜像,因为本身认为一向从网络上下载安全更新会更好一些,因为这么能够确定保障你总能得到新型的版本。
本测试基于 Debian Sarge 和Ubuntu 艾德gy
Eft操作系统,要是你使用的是其它的本子,那么那个手续恐怕会有微小的反差。你供给设置叁个大旨的
Debian Sarge
系统(安装步骤http://www.howtoforge.com/perfect_setup_debian_sarge)也许Ubuntu 艾德gy
Eft系统(安装步骤http://www.howtoforge.com/perfect\_setup\_ubuntu\_6.10)
以此事例中本地源镜像的ip是192.168.0.100.
2,1安装apt-mirror
修改/etc/apt/sources.list(Debian Sarge必须)
只要你安装的是 Debian Sarge,你不可能不要修改sources.list.小编不清楚Debian
Etch 或许 Sid是不是必必要修改,你能够协调尝试一下。对Ubuntu 艾德gy Eft.
这一步不适必须的。

代码:

vi /etc/apt/sources.list

投入上面怪这一行。

代码:

deb http://apt-mirror.sourceforge.net/ apt-mirror/

然后实施:

代码:

apt-get update

2.2安装apt-mirror
这一步对Debian和Ubuntu都以必须的,安装apt-mirror,执行

代码:

apt-get install apt-mirror

3安装阿帕奇。
本人想要通过http的方法得到地点Debian/Ubuntu的源镜像,由此供给安装apache
web服务器。

代码:

apt-get install apache2

默许的根目录是/var/www,接下去笔者会symlink那么些目录到Debian and Ubuntu
的软件仓库所在目录。
4配置apt-mirror
apt-mirror的安插文件在/ etc/apt/mirror.list,debian
sarge中的暗许配置文件如下:

引用:

# apt-mirror configuration file
##
## The default configuration options (uncomment and change to
override)
##
#
# 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 defaultarch
# set nthreads 20
#
##
## Example sources
##
# sarge’s section
deb http://ftp.fi.debian.org/debian sarge main contrib non-free
deb-src http://ftp.fi.debian.org/debian sarge main contrib non-free
deb http://security.debian.org/debian-security sarge/updates main
contrib non-free
deb-src http://security.debian.org/debian-security sarge/updates main
contrib non-free
deb http://ftp.fi.debian.org/debian sarge main/debian-installer
# sarge-proposed-updates’s section
deb http://ftp.fi.debian.org/debian sarge-proposed-updates main
contrib non-free
deb-src http://ftp.fi.debian.org/debian sarge-proposed-updates main
contrib non-free
# sid’s section
deb http://ftp.fi.debian.org/debian sid main contrib non-free
deb-src http://ftp.fi.debian.org/debian sid main contrib non-free
deb http://ftp.fi.debian.org/debian sid main/debian-installer
# experimental section
deb http://ftp.fi.debian.org/debian ../project/experimental main
contrib non-free
deb-src http://ftp.fi.debian.org/debian ../project/experimental main
contrib non-free
##
## Cleaner configuration example
##
#
# set cleanscript $var_path/clean.sh
#
# Cleaning section
clean http://security.debian.org/
clean http://ftp.fi.debian.org/
skip-clean http://ftp.fi.debian.org/doc/
skip-clean http://ftp.fi.debian.org/tools/
skip-clean http://ftp.fi.debian.org/debian-cd/
skip-clean http://ftp.fi.debian.org/debian-minicd/
skip-clean http://ftp.fi.debian.org/debian/dists/s …
ller-i386/

skip-clean http://ftp.fi.debian.org/debian/dists/s …
ller-i386/

skip-clean http://ftp.fi.debian.org/debian/doc/
skip-clean http://ftp.fi.debian.org/debian/tools/
skip-clean http://ftp.fi.debian.org/debian/project/
skip-clean http://ftp.fi.debian.org/debian-non-US/project/

Ubuntu 艾德gy Eft中的暗中认可文件如下:

引用:

############# config ##################
#
# set base_path /var/spool/apt-mirror
#
# if you change the base path you must create the directories below
with write privlages
#
# 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
set nthreads 20
set tilde 0
#
############# end config ##############
deb http://archive.ubuntu.com/ubuntu edgy main restricted universe
multiverse
deb http://archive.ubuntu.com/ubuntu edgy-updates main restricted
universe multiverse
#deb http://archive.ubuntu.com/ubuntu edgy-backports main restricted
universe multiverse
deb http://archive.ubuntu.com/ubuntu edgy-security main restricted
universe multiverse
#deb http://archive.ubuntu.com/ubuntu edgy-proposed main restricted
universe multiverse
deb-src http://archive.ubuntu.com/ubuntu edgy main restricted universe
multiverse
deb-src http://archive.ubuntu.com/ubuntu edgy-updates main restricted
universe multiverse
#deb-src http://archive.ubuntu.com/ubuntu edgy-backports main
restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu edgy-security main restricted
universe multiverse
#deb-src http://archive.ubuntu.com/ubuntu edgy-proposed main
restricted universe multiverse
clean http://archive.ubuntu.com/ubuntu

比方您比较/etc/apt/sources.list
和/etc/apt/mirror.list,你会意识双方卓殊相似,二者都列举了有的应当被镜像的软件库,别的还有一对别样选用。
今昔作者修改/etc/apt/mirror.list.就象作者前边说过的等同,笔者要镜像Debian
Sarge的main,contrib 和non-free部分和 Ubuntu 艾德gy Eft的 main, restricted,
universe部分
,不镜像应该直接从互连网上下载的安全部分。其余,作者也从不镜像源代码包,因为95%的安装文件不供给源代码,而源代码包文件又会占用巨大的硬盘空间。所以小编的/etc/apt/mirror.list
修改成上边包车型地铁金科玉律:

代码:

vi /etc/apt/mirror.list

引用:

# apt-mirror configuration file
##
## The default configuration options (uncomment and change to
override)
##
#
# 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 defaultarch
# set nthreads 20
#
##
## Example sources
##
# sarge’s section
deb http://ftp.de.debian.org/debian sarge main contrib non-free
# Ubuntu Edgy Eft
deb http://de.archive.ubuntu.com/ubuntu/ edgy main restricted
universe
##
## Cleaner configuration example
##
#
# set cleanscript $var_path/clean.sh
#
# Cleaning section
clean http://ftp.de.debian.org/
clean http://de.archive.ubuntu.com/

请小心自个儿用ftp.de.debian.org 代替了ftp.fi.debian.org ,用
de.archive.ubuntu.com代替了
archive.ubuntu.com.
你应当接纳三个相差你相比较近的镜像,所以只要您在U.S.A.,就用us替代de。
说到底的cleaning部分报告apt-mirror本地的硬盘应该和哪位软件仓库相比较以鲜明哪些文件能够自动清除掉。小编要检查Debian
和Ubuntu全体的软件,所以小编修改成了,
clean http://ftp.de.debian.org/
clean http://de.archive.ubuntu.com/
万一你利用了别的的
Debian/Ubuntu版本,请用etch恐怕sid替换sarge;breezy只怕dapper替换edgy。
5开立本地软件仓库
现行反革命apt-mirror已经布置好了,今后应当率先次运维它,下载全数的包营造本地的Debian/Ubuntu软件仓库。我们只需求举办:
[code]
su – apt-mirror -c apt-mirror
[/eode]
apt-mirror会告诉您到底要下载多少GB的公文。那将会花上多少个小时,所以要耐心点。那么些包将会蕴藏在/var/spool/apt-mirror/mirror的子目录中,所以您要确定保障该分区还有丰硕的硬盘空间。
debian的在/var/spool/apt-mirror/mirror/ftp.de.debian.org/debian,
unbuntu的在/var/spool/apt-mirror/mirror/de.archive.ubuntu.com/ubuntu.
一经您在第5步选拔了叁个不等的镜像,那么那些路子只怕有个别差别。
6清理软件仓库
等到apt-mirror下载完了拥有的包,它卓殊恐怕会告知您能够撤消出有个别硬盘空间来,使用以下脚本:
/bin/bash /var/spool/apt-mirror/var/clean.sh
输出如下:
server1:~# /bin/bash /var/spool/apt-mirror/var/clean.sh
Removing 157 unnecessary files [13316096 bytes]…
[0%]…………….done.
Removing 18 unnecessary directories…
[0%]………………done.
这样你就能观察某个许硬盘空间被清理出去了。
7 更新本地软件仓库
立异本地镜像是相当不难的,执行
[code]su – apt-mirror -c apt-mirror [/code]
假如你不想手工业执行更新,那么您可以编制2个定时执行的corn职分。只须求编辑/etc/corn.d/apt-mirror,在结尾一行添加如下即可:
[code]vi /etc/cron.d/apt-mirror [/code]

引用:

#
# Regular cron jobs for the apt-mirror package
#
0 4 * * * apt-mirror /usr/bin/apt-mirror >
/var/spool/apt-mirror/var/cron.log

8 由此http访问镜像
Apache暗中认可的根目录是/var/www,可是软件仓库却在/var/spool/apt-mirror/mirror
为了能够通过 http://192.168.0.100/debian and
http://192.168.0.100/ubuntu
做客到相应的软件库,大家能够symlinks /var/www/debian and
/var/www/ubuntu到实在的库地址。
[code]ln -s /var/spool/apt-mirror/mirror/ftp.de.debian.org/debian
/var/www/debian
ln -s /var/spool/apt-mirror/mirror/de.archive.ubuntu.com/ubuntu
/var/www/ubuntu[/code]
只要您选用了任何镜像,记得调整那两行命令。
接下去要考虑的一件工作是,你以为DebianSarge是sarge而且是平静的e(至少如今是安静的,而Etch依旧在测试中),那么当你运转
[code]ls -l
/var/spool/apt-mirror/mirror/ftp.de.debian.org/debian/dists [/code]
你会发现那里有1个sarge的目录,但却是不平稳的,不过只要你在source.list中用稳定的更迭了
sarge,只怕在地点全新安装三个debian系统,那样就会合世如此的难题debian
sarge的设置工具依旧会认为stable替换sarge。化解办法是
[code]cd /var/spool/apt-mirror/mirror/ftp.de.debian.org/debian/dists
ln -s sarge/ stable[/code]
当debian
Etch变成稳定版本的时候你也得以镜像Etch。到时候不要忘了改动stable的symlink。
[code]cd /var/spool/apt-mirror/mirror/ftp.de.debian.org/debian/dists
rm -f stable
ln -s etch/ stable [/code]
本条标题不会油可是生在ubuntu中。
9 铺排你的客户端电脑使用当地镜像
于今地面镜像已经得以利用了,我们所要做得是告诉 Debian Sarge和Ubuntu 艾德gy
Eft 系统怎么着利用当地镜像。
Debian
Sarge系统,在source。list中期维修改main,contrib,non-free的软件仓库
vi /etc/apt/sources.list
[…]
deb http://192.168.0.100/debian sarge main contrib non-free
[…]
Instead of sarge you could also use stable:
[…]
deb http://192.168.0.100/debian stable main contrib non-free
[…]
接下来运转:
apt-get update
在 Ubuntu 艾德gy Eft系统中,你能够在sources.list中改换 main restricted
universe的软件仓库。
vi /etc/apt/sources.list
[…]
deb http://192.168.0.100/ubuntu/ edgy main restricted universe
[…]
下一场运营:
apt-get update
9.3 全新安装系统
要是您从本地镜像全新安装3个 Debian Sarge 也许 Ubuntu 艾德gy
Eft那么你能够遵从以下步骤进行:
10相关链接
* apt-mirror:
http://apt-mirror.sourceforge.net
* Debian: http://www.debian.org
* Ubuntu: http://www.ubuntu.com

============================================================================================

Ubuntu12.04搭建自有源

实则,那几个工作相比较简单,首要两步:apt-mirror和apache。(那里的系统是ubuntu12.04)

1、apt-mirror

1.1 安装

还是地质大学致,直接sudo apt-get install apt-mirror即可。

1.2 配置apt-mirror

$ sudo vim /etc/apt/mirror.list

[plain]

############# 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 precise main restricted universe
multiverse 

deb http://archive.ubuntu.com/ubuntu precise-security main restricted
universe multiverse 

deb http://archive.ubuntu.com/ubuntu precise-updates main restricted
universe multiverse 

#deb http://archive.ubuntu.com/ubuntu precise-proposed main restricted
universe multiverse 

#deb http://archive.ubuntu.com/ubuntu precise-backports main restricted
universe multiverse 

deb-src http://archive.ubuntu.com/ubuntu precise main restricted
universe multiverse 

deb-src http://archive.ubuntu.com/ubuntu precise-security main
restricted universe multiverse 

deb-src http://archive.ubuntu.com/ubuntu precise-updates main restricted
universe multiverse 

#deb-src http://archive.ubuntu.com/ubuntu precise-proposed main
restricted universe multiverse 

#deb-src http://archive.ubuntu.com/ubuntu precise-backports main
restricted universe multiverse 

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

将其修改为对协调比较快的源(那里用ustc的):

[plain]

############ 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 ############## 

#precise 64bit Mirror 

deb-amd64 http://mirrors.ustc.edu.cn/ubuntu precise main restricted
universe multiverse 

deb-amd64 http://mirrors.ustc.edu.cn/ubuntu precise-security main
restricted universe multiverse 

deb-amd64 http://mirrors.ustc.edu.cn/ubuntu precise-updates main
restricted universe multiverse 

deb-amd64 http://mirrors.ustc.edu.cn/ubuntu precise-proposed main
restricted universe multiverse 

deb-amd64 http://mirrors.ustc.edu.cn/ubuntu precise-backports main
restricted universe multiverse 

#precise 32bit Mirror 

deb-i386 http://mirrors.ustc.edu.cn/ubuntu precise main restricted
universe multiverse 

deb-i386 http://mirrors.ustc.edu.cn/ubuntu precise-security main
restricted universe multiverse 

deb-i386 http://mirrors.ustc.edu.cn/ubuntu precise-updates main
restricted universe multiverse 

deb-i386 http://mirrors.ustc.edu.cn/ubuntu precise-proposed main
restricted universe multiverse 

deb-i386 http://mirrors.ustc.edu.cn/ubuntu precise-backports main
restricted universe multiverse 

deb-src http://mirrors.ustc.edu.cn/ubuntu precise main restricted
universe multiverse 

deb-src http://mirrors.ustc.edu.cn/ubuntu precise-security main
restricted universe multiverse 

deb-src http://mirrors.ustc.edu.cn/ubuntu precise-updates main
restricted universe multiverse 

deb-src http://mirrors.ustc.edu.cn/ubuntu precise-proposed main
restricted universe multiverse 

deb-src http://mirrors.ustc.edu.cn/ubuntu precise-backports main
restricted universe multiverse 

clean http://mirrors.ustc.edu.cn/ubuntu 

1.3 apt-mirror同步源

用sudo apt-mirror命令初阶同步源即可。

[plain]

$ sudo apt-mirror 

Downloading 140 index files using 20 threads… 

Begin time: Fri Nov  1 17:23:49 2013 

[20]… [19]… [18]… [17]… [16]… [15]… [14]…
[13]… [12]… [11]… [10]… [9]… [8]… [7]…
[6]… [5]… [4]… [3]… [2]… [1]… [0]…  

End time: Fri Nov  1 17:23:49 2013 

Proceed indexes: [SSSSSPPPPP] 

93.0 GiB will be downloaded into archive. 

Downloading 85303 archive files using 20 threads… 

Begin time: Fri Nov  1 17:23:55 2013 

[20]…  

那里,要注意,有时候会境遇“No such file apt-mirror: can’t open index in
proceed_index_gz at /usr/bin/apt-mirror line
445.”这样的荒唐,折腾了本人一个早上。原因不怎么清楚,不过,貌似依据地点我的流水生产线做,至少能够幸免那些破绽百出。具体原因,难道和小编布置文件中没去掉注释有提到,总而言之,稍诡异。

最后成功后的出口如下:

[plain]

$ sudo apt-mirror 

Downloading 140 index files using 20 threads… 

Begin time: Fri Nov  1 17:23:49 2013 

[20]… [19]… [18]… [17]… [16]… [15]… [14]…
[13]… [12]… [11]… [10]… [9]… [8]… [7]…
[6]… [5]… [4]… [3]… [2]… [1]… [0]…  

End time: Fri Nov  1 17:23:49 2013 

Proceed indexes: [SSSSSPPPPP] 

93.0 GiB will be downloaded into archive. 

Downloading 85303 archive files using 20 threads… 

Begin time: Fri Nov  1 17:23:55 2013 

[20]…   [19]… [18]… [17]… [16]… [15]… [14]…
[13]… [12]… [11]… [10]… [9]… [8]… [7]…
[6]… [5]… [4]… [3]… [2]… [1]… [0]…  

End time: Fri Nov  1 18:12:35 2013 

0.0 bytes in 0 files and 0 directories can be freed. 

Run /var/spool/apt-mirror/var/clean.sh for this purpose. 

Running the Post Mirror script … 

(/var/spool/apt-mirror/var/postmirror.sh) 

Post Mirror script has completed. See above output for any possible
errors. 

2、apache2

2.1 安装

sudo apt-get install apache2

2.2 配置

apache2的铺排,那里就不自作聪明了。反正小编是一贯在网上搜的帖子,方法极粗略。

[plain]

(1) 进入/var/www目录 

cd /var/www 

(2) 创设三个针对性apt-mirror的mirror存放路径的软链接,那里命名为ubuntu 

$ ln -s /var/spool/apt-mirror/mirror/mirrors.ustc.edu.cn/ubuntu ubuntu 

到那里,就能够在浏览器地址栏输入“202.xxx.xxx.xxx/ubuntu”来访问该源目录了。

3、使用源

为了采纳该源之须求修改/etc/apt/source.list文件:

[plain]

诸如原先用的是ustc的源,source.list文件如下: 

deb http://mirrors.ustc.edu.cn/ubuntu/ precise main restricted universe
multiverse 

deb http://mirrors.ustc.edu.cn/ubuntu/ precise-security main restricted
universe multiverse 

deb http://mirrors.ustc.edu.cn/ubuntu/ precise-updates main restricted
universe multiverse 

deb http://mirrors.ustc.edu.cn/ubuntu/ precise-proposed main restricted
universe multiverse 

deb http://mirrors.ustc.edu.cn/ubuntu/ precise-backports main restricted
universe multiverse 

deb-src http://mirrors.ustc.edu.cn/ubuntu/ precise main restricted
universe multiverse 

deb-src http://mirrors.ustc.edu.cn/ubuntu/ precise-security main
restricted universe multiverse 

deb-src http://mirrors.ustc.edu.cn/ubuntu/ precise-updates main
restricted universe multiverse 

deb-src http://mirrors.ustc.edu.cn/ubuntu/ precise-proposed main
restricted universe multiverse 

deb-src http://mirrors.ustc.edu.cn/ubuntu/ precise-backports main
restricted universe multiverse 

近期想改成,我们正好搭建好的源,只需在vim中用三个下令”:%s/mirrors.ustc.edu.cn/202.xxx.xxx.xxx/g”,即可将source.list修改为如下: 

deb http://202.xxx.xxx.xxx/ubuntu/ precise main restricted universe
multiverse 

deb http://202.xxx.xxx.xxx/ubuntu/ precise-security main restricted
universe multiverse 

deb http://202.xxx.xxx.xxx/ubuntu/ precise-updates main restricted
universe multiverse 

deb http://202.xxx.xxx.xxx/ubuntu/ precise-proposed main restricted
universe multiverse 

deb http://202.xxx.xxx.xxx/ubuntu/ precise-backports main restricted
universe multiverse 

deb-src http://202.xxx.xxx.xxx/ubuntu/ precise main restricted universe
multiverse 

deb-src http://202.xxx.xxx.xxx/ubuntu/ precise-security main restricted
universe multiverse 

deb-src http://202.xxx.xxx.xxx/ubuntu/ precise-updates main restricted
universe multiverse 

deb-src http://202.xxx.xxx.xxx/ubuntu/ precise-proposed main restricted
universe multiverse 

deb-src http://202.xxx.xxx.xxx/ubuntu/ precise-backports main restricted
universe multiverse 

下一场,sudo apt-get
update就能够看出,大家搭建的似有源的确曾经生效了,速度飞快

==========================================================================================

1:加上边包车型的士行到/etc/apt/sources.list
deb http://apt-mirror.sourceforge.net/ apt-mirror/

2:apt-get update

3:apt-get install apt-mirror

4:依照要求修改/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 privlages
#
# 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
set nthreads 20
set _tilde 0
#
############# end config ##############

deb http://debian.cn99.com/debian/ etch main contrib non-free
deb-src http://debian.cn99.com/debian/ etch main contrib non-free

deb http://security.debian.org/ etch/updates main contrib non-free
deb-src http://security.debian.org/ etch/updates main contrib non-free

#deb
http://archive.[Ubuntu](http://www.linuxidc.com/topicnews.aspx?tid=2).com/ubuntu
hardy main restricted universe multiverse
#deb http://archive.ubuntu.com/ubuntu hardy-updates main restricted
universe multiverse
##deb http://archive.ubuntu.com/ubuntu hardy-backports main restricted
universe multiverse
#deb http://archive.ubuntu.com/ubuntu hardy-security main restricted
universe multiverse
##deb http://archive.ubuntu.com/ubuntu hardy-proposed main restricted
universe multiverse
#
#deb-src http://archive.ubuntu.com/ubuntu hardy main restricted
universe multiverse
#deb-src http://archive.ubuntu.com/ubuntu hardy-updates main restricted
universe multiverse
##deb-src http://archive.ubuntu.com/ubuntu hardy-backports main
restricted universe multiverse
#deb-src http://archive.ubuntu.com/ubuntu hardy-security main
restricted universe multiverse
##deb-src http://archive.ubuntu.com/ubuntu hardy-proposed main
restricted universe multiverse

clean http://debian.cn99.com/debian/

#
# deb cdrom:[Debian GNU/Linux 4.0 r0 _Etch_ – Official i386 NETINST
Binary-1 20070407-11:29]/ etch contrib main

5:得到源消息
su apt-mirror -c apt-mirror
恐怕会报错:

jumping:~# su apt-mirror -c apt-mirror
Downloading 30 index files using 20 threads…
Begin time: Fri Aug 29 11:38:38 2008
[20]… [19]… [18]… [17]… [16]… [15]… [14]…
[13]… [12]… [11]… [10]… [9]… [8]… [7]…
[6]… [5]… [4]… [3]… [2]… [1]… [0]…
End time: Fri Aug 29 11:40:49 2008

Proceed indexes: [Ssh:
debian.cn99.com/debian///dists/etch/main/source/Sources.gz: No such file
or directory
apt-mirror: can’t open index in proceed_index_gz at
/usr/bin/apt-mirror line 382.


到/var/spool/apt-mirror/skel/debian.cn99.com/debian/dists/etch/main/source/目录下去看看有没有Sources.gz。没有的话,再履行一回
su apt-mirror -c apt-mirror
以至于有停止。

没错的出口应该是:
jumping:# su apt-mirror -c apt-mirror
Downloading 30 index files using 20 threads…
Begin time: Fri Aug 29 11:53:32 2008
[20]… [19]… [18]… [17]… [16]… [15]… [14]…
[13]… [12]… [11]… [10]… [9]… [8]… [7]…
[6]… [5]… [4]… [3]… [2]… [1]… [0]…
End time: Fri Aug 29 11:54:27 2008

Proceed indexes: [SSPP]

30.1 GiB will be downloaded into archive.
Downloading 51528 archive files using 20 threads…
Begin time: Fri Aug 29 11:54:33 2008
[20]…

6:布置apache,提须要别的用户使用该源(参考网上的稿子)

=======================================================================================

apt-get install apache2

Creating an Ubuntu repository mirror with apt-mirror

By ADMIN | Published: OCTOBER 24,
2006

 

apt-mirror is a handy tool for creating a replica (or ‘mirror’ if you
will) of a Debian archive. This can be useful in a number of
circumstances if you want to maintain your own archive. Having your own
up to date archive means you have fast access to every package in the
distro very quickly.

Maybe you need it for installing a Debian-based distro onto lots of
machines on a LAN. For example a system builder who installs Linux on
many new computers and wants to improve the speed at which the systems
are updated after a clean install. There are of course other tools that
can achieve this including apt-catcher, apt-proxy and squid. These are
in fact arguably better than the apt-mirror approach. But this is more
fun 图片 1

There are other uses for this, and I’m sure I’ll think of them one day.

apt-mirror can be used on any Debian-based repository. So it will work
equally well with genuine Debian, Ubuntu or indeed any other .deb based
system. Here is the way I setup a local hard disk.

Firstly, prepare some space

 

Lots of it! The Ubuntu 6.10 (Edgy Eft) repository including main,
universe and multiverse currently takes around 30GiB of disk space. Disk
space is relatively cheap though, so having a local archive isn’t a big
deal space-wise. Bandwidth is a separate consideration though. 30GiB is
quite a fair amount of data to pull down over the internet.

I used a 250GiB external USB hard drive. This has the advantage that I
can physically attach it to a machine that has no net connection, chuck
in an Ubuntu 6.10 (Edgy Eft) CD (or even upgrade from a 6.06 [Dapper]
one) and install/upgrade a machine there and then. See – told you there
was another use for this!

This is also especially handy if someone has a wierd ethernet card or
modem that’s only supported in a very new kernel, or requires something
from universe or multiverse to get online. Can’t think of any specific
examples of that, but hey, I’m coming up with excuses^Wreasons to do
this whole apt-mirror thing all the time.

I have a completely empty USB disk plugged in, lets see how much space
there is available.. Ooh lots.

alan@multivac:~$ df -h
Filesystem            Size Used Avail Use% Mounted on
/dev/evms/hda1        5.3G  4.1G  975M  81% /
varrun                244M  112K  244M   1% /var/run
varlock               244M  4.0K  244M   1% /var/lock
procbususb             10M  108K  9.9M   2% /proc/bus/usb
udev                   10M  108K  9.9M   2% /dev
devshm                244M     0  244M   0% /dev/shm
/dev/sda1             233G    4M  229G   0% /media/usbdisk

Make the necessary directories

 

My USB hard disk gets mounted in the usual place (/media/usbdisk) when I
plug it in and turn it on. So I just need to make a directory on that
disk and a few subdirectories and we’re done with this step.

alan@multivac:~$ mkdir /media/usbdisk/repo
alan@multivac:~$ mkdir /media/usbdisk/repo/mirror
alan@multivac:~$ mkdir /media/usbdisk/repo/skel
alan@multivac:~$ mkdir /media/usbdisk/repo/var

Install apt-mirror

apt-mirror is in the standard repositories. You can install using your
favourite tool like synaptic or aptitude, call me old fashioned, I like
apt-get though.

alan@multivac:~$ sudo apt-get install apt-mirror

Edit config

The default settings might work for you okay, but I decided to make some
changes.

alan@multivac:~$ sudo gedit /etc/apt/mirror.list

Here’s the default config file:-

############# config ##################
#
# set base_path    /var/spool/apt-mirror
#
# if you change the base path you must create the directories below with write privlages
#
# 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  
set nthreads     20
set tilde 0
#
############# end config ##############
# standard edgy repos
deb http://archive.ubuntu.com/ubuntu edgy main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu edgy-updates main restricted universe multiverse
#deb http://archive.ubuntu.com/ubuntu edgy-backports main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu edgy-security main restricted universe multiverse
#deb http://archive.ubuntu.com/ubuntu edgy-proposed main restricted universe multiverse

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

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

Here’s mine. I changed the location where I wanted the repository
stored, used the nearest mirror, changed the number of threads and a few
extra repositories that I wanted to mirror.

############# config ##################
#
# set base_path    /var/spool/apt-mirror
set base_path /media/usbdisk/repo
#
# if you change the base path you must create the directories below with write privlages
#
# 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  
set nthreads     2
set tilde 0
#
############# end config ##############
# standard edgy repos
deb http://gb.archive.ubuntu.com/ubuntu edgy main restricted universe multiverse
deb http://gb.archive.ubuntu.com/ubuntu edgy-updates main restricted universe multiverse
#deb http://gb.archive.ubuntu.com/ubuntu edgy-backports main restricted universe multiverse
deb http://gb.archive.ubuntu.com/ubuntu edgy-security main restricted universe multiverse
#deb http://gb.archive.ubuntu.com/ubuntu edgy-proposed main restricted universe multiverse

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

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

# Canonical commercial stuff
deb http://archive.canonical.com/ubuntu edgy-commercial main
clean  http://archive.canonical.com/ubuntu 

# Beryl - Unnecessary 3D groovyness :)
# http://ubuntuforums.org/showthread.php?t=263851
deb http://ubuntu.compiz.net/ edgy main-edgy
clean http://ubuntu.compiz.net/

# Skype - Semi-evil and badly-supported-on-linux VOIP solution
# https://help.ubuntu.com/community/Skype
deb http://download.skype.com/linux/repos/debian/ stable non-free
clean http://download.skype.com/linux/repos/debian/

# Codecs - Stuff to allow you to play all that proprietary encoded stuff
# https://help.ubuntu.com/community/RestrictedFormats
deb http://packages.freecontrib.org/plf edgy-plf free non-free
deb-src http://packages.freecontrib.org/plf edgy-plf free non-free
clean http://packages.freecontrib.org/plf

# Automatix - That thing newbies like
# http://www.getautomatix.com/
deb http://www.getautomatix.com/apt edgy main
clean http://www.getautomatix.com/apt

Set aside some time to start the mirroring. It will take “time”. How
long? Well, divide ~30GiB by your internet connection speed
图片 2

The first time I ran apt-mirror it scanned the online archives and
wanted to download around 30GiB of packages. Worth noting that I didn’t
leave it running but killed it when I wanted to get some bandwidth back
and restarted it later. It doesn’t start all over again but continues,
and you can see this because the total download size goes down with each
execution until you have the full archive. If you have a particularly
slow connection, or you stop it quite a lot then you’ll likely never
finish, at least not whilst edgy is in development!

Once the distro goes stable you can be sure the number of changes will
go down. At the time of writing there’s hundreds of MBs changes per day,
so now may not be the best time to do this
图片 3 The good news is that Edgy
is released this week – Yay!

Here’s one of the instances of me running it. Note this isn’t the first
time I ran it.

alan@multivac:~$ sudo apt-mirror
Downloading 88 index files using 1 threads...
Begin time: Tue Oct 24 06:41:14 2006
[1]... [0]...
End time: Tue Oct 24 06:41:18 2006

Proceed indexes: [SSSSPPPPPPPP]

4.8 MiB will be downloaded into archive.
Downloading 1 archive files using 1 threads...
Begin time: Tue Oct 24 06:41:36 2006
[1]... [0]...
End time: Tue Oct 24 06:41:37 2006

192.8 MiB in 215 files and 29 directories can be freed.
Run /media/usbdisk/repo/var/clean.sh for this purpose.

Note the handy-dandy script that gets created at the end to clear out
the old files you have in your local repository. So we kick that off and
here’s what happens next:-

alan@multivac:~$ sudo sh /media/usbdisk/repo/var/clean.sh
Removing 215 unnecessary files [202129408 bytes]...
[0%]......................done.

Removing 29 unnecessary directories...
[0%].............................done.

That was painless!

Using the archive

Ok, so what can we do with this archive. Install software from it!
Here’s an example of installing software from the local archive
connected to the USB port.

Backup current sources.list

alan@multivac:~$ sudo cp /etc/apt/sources.list /etc/apt/sources.backup

Edit the sources.list

alan@multivac:~$ sudo gedit /etc/apt/sources.list

Here’s the sources.list that goes with the apt-mirror config I used
above.

# standard edgy repos
deb file:/media/usbdisk/repo/mirror/gb.archive.ubuntu.com/ubuntu edgy main restricted universe multiverse
deb-src file:/media/usbdisk/repo/mirror/gb.archive.ubuntu.com/ubuntu edgy main restricted universe multiverse
deb file:/media/usbdisk/repo/mirror/gb.archive.ubuntu.com/ubuntu edgy-security main restricted universe multiverse
deb-src file:/media/usbdisk/repo/mirror/gb.archive.ubuntu.com/ubuntu edgy-security main restricted universe multiverse
deb file:/media/usbdisk/repo/mirror/gb.archive.ubuntu.com/ubuntu edgy-updates main restricted universe multiverse
deb-src file:/media/usbdisk/repo/mirror/gb.archive.ubuntu.com/ubuntu edgy-updates main restricted universe multiverse

# Canonical commercial stuff
deb file:/media/usbdisk/repo/mirror/archive.canonical.com/ubuntu edgy-commercial main

# Beryl - Unnecessary 3D groovyness :)
# http://ubuntuforums.org/showthread.php?t=263851
deb file:/media/usbdisk/repo/mirror/ubuntu.compiz.net/ edgy main-edgy

# Codecs - Stuff to allow you to play all that proprietary encoded stuff
# https://help.ubuntu.com/community/RestrictedFormats
deb file:/media/usbdisk/repo/mirror/packages.freecontrib.org/plf edgy-plf free non-free
deb-src file:/media/usbdisk/repo/mirror/packages.freecontrib.org/plf edgy-plf free non-free

# Skype - Semi-evil and badly-supported-on-linux VOIP solution
# https://help.ubuntu.com/community/Skype
deb file:/media/usbdisk/repo/mirror/download.skype.com/linux/repos/debian/ stable non-free

# Automatix - That thing newbies like
# http://www.getautomatix.com/
deb file:/media/usbdisk/repo/mirror/www.getautomatix.com/apt edgy main

Update

Now we update my local machine to let it know what’s in the repository.

alan@multivac:~$ sudo apt-get update
Ign file: edgy/main Translation-en_GB
Ign file: edgy/restricted Translation-en_GB
Ign file: edgy/universe Translation-en_GB
Ign file: edgy/multiverse Translation-en_GB
Ign file: edgy-security/main Translation-en_GB
Ign file: edgy-security/restricted Translation-en_GB
Ign file: edgy-security/universe Translation-en_GB
Ign file: edgy-security/multiverse Translation-en_GB
Ign file: edgy-updates/main Translation-en_GB
Ign file: edgy-updates/restricted Translation-en_GB
Ign file: edgy-updates/universe Translation-en_GB
Ign file: edgy-updates/multiverse Translation-en_GB
Ign file: edgy-commercial/main Translation-en_GB
Ign file: edgy-plf/free Translation-en_GB
Ign file: edgy-plf/non-free Translation-en_GB
Ign file: edgy/main-edgy Translation-en_GB
Ign file: stable Release.gpg
Ign file: stable/non-free Translation-en_GB
Ign file: edgy/main Translation-en_GB
Ign file: stable Release
Ign file: stable/non-free Packages
Get: 1 file: edgy Release.gpg [191B]
Get: 2 file: edgy-security Release.gpg [189B]
Get: 3 file: edgy-updates Release.gpg [189B]
Get: 4 file: edgy-commercial Release.gpg [191B]
Get: 5 file: edgy-plf Release.gpg [189B]
Get: 6 file: edgy Release.gpg [189B]
Get: 7 file: edgy Release.gpg [189B]
Get: 8 file: edgy Release [34.7kB]
Get: 9 file: edgy-security Release [19.6kB]
Get: 10 file: edgy-updates Release [19.6kB]
Get: 11 file: edgy-commercial Release [4874B]
Get: 12 file: edgy-plf Release [9454B]
Get: 13 file: edgy Release [5755B]
Get: 14 file: edgy Release [4147B]
Ign file: edgy/main Packages
Ign file: edgy/restricted Packages
Ign file: edgy/universe Packages
Ign file: edgy/multiverse Packages
Ign file: edgy/main Sources
Ign file: edgy/restricted Sources
Ign file: edgy/universe Sources
Ign file: edgy/multiverse Sources
Ign file: edgy-security/main Packages
Ign file: edgy-security/restricted Packages
Ign file: edgy-security/universe Packages
Ign file: edgy-security/multiverse Packages
Ign file: edgy-security/main Sources
Ign file: edgy-security/restricted Sources
Ign file: edgy-security/universe Sources
Ign file: edgy-security/multiverse Sources
Ign file: edgy-updates/main Packages
Ign file: edgy-updates/restricted Packages
Ign file: edgy-updates/universe Packages
Ign file: edgy-updates/multiverse Packages
Ign file: edgy-updates/main Sources
Ign file: edgy-updates/restricted Sources
Ign file: edgy-updates/universe Sources
Ign file: edgy-updates/multiverse Sources
Ign file: edgy-plf Release
Ign file: edgy Release
Ign file: edgy Release
Ign file: edgy-commercial/main Packages
Ign file: edgy-plf/free Packages
Ign file: edgy-plf/non-free Packages
Ign file: edgy-plf/free Sources
Ign file: edgy-plf/non-free Sources
Ign file: edgy/main-edgy Packages
Ign file: edgy/main Packages
Fetched 99.5kB in 1s (73.2kB/s)
Reading package lists... Done
W: GPG error: file: edgy-plf Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY F120156012B83718
W: GPG error: file: edgy Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 31A5F97FED8A569E
W: GPG error: file: edgy Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 18B52FE3521A9C7C
W: You may want to run apt-get update to correct these problems

Fix the NO_PUBKEY warnings

The warnings occur because I don’t have those keys in my keyring. This
fixes that:-

alan@multivac:~$ sudo gpg --keyserver subkeys.pgp.net --recv F120156012B83718
gpg: requesting key 12B83718 from hkp server subkeys.pgp.net
gpg: key 12B83718: public key "Lionel Le Folgoc (mr_pouit) " imported
gpg: Total number processed: 1
gpg:               imported: 1
alan@multivac:~$ sudo gpg --export --armor F120156012B83718 | sudo apt-key add -
OK
alan@multivac:~$ sudo gpg --keyserver subkeys.pgp.net --recv 31A5F97FED8A569E
gpg: requesting key ED8A569E from hkp server subkeys.pgp.net
gpg: key ED8A569E: public key "Quinn Storm " imported
gpg: no ultimately trusted keys found
gpg: Total number processed: 1
gpg:               imported: 1
alan@multivac:~$ sudo gpg --export --armor 31A5F97FED8A569E | sudo apt-key add -
OK
alan@multivac:~$ sudo gpg --keyserver subkeys.pgp.net --recv 18B52FE3521A9C7C
gpg: requesting key 521A9C7C from hkp server subkeys.pgp.net
gpg: key 521A9C7C: public key "Justin Hayes (Automatix Repository Master) " imported
gpg: no ultimately trusted keys found
gpg: Total number processed: 1
gpg:               imported: 1
alan@multivac:~$ sudo gpg --export --armor 18B52FE3521A9C7C | sudo apt-key add -
OK</WILDTANGENT@W1LDT4NG3NT.NET></LIVINGLATEXKALI@GMAIL.COM></LIONEL.LEFOLGOC@FREE.FR>

Update again
..to show those keys got imported correctly in the last step.

alan@multivac:~$ sudo apt-get update
Ign file: edgy/main Translation-en_GB
Ign file: edgy/restricted Translation-en_GB
Ign file: edgy/universe Translation-en_GB
Ign file: edgy/multiverse Translation-en_GB
Ign file: edgy-security/main Translation-en_GB
Ign file: edgy-security/restricted Translation-en_GB
Ign file: edgy-security/universe Translation-en_GB
Ign file: edgy-security/multiverse Translation-en_GB
Ign file: edgy-updates/main Translation-en_GB
Ign file: edgy-updates/restricted Translation-en_GB
Ign file: edgy-updates/universe Translation-en_GB
Ign file: edgy-updates/multiverse Translation-en_GB
Ign file: edgy-commercial/main Translation-en_GB
Ign file: edgy-plf/free Translation-en_GB
Ign file: edgy-plf/non-free Translation-en_GB
Ign file: edgy/main-edgy Translation-en_GB
Ign file: stable Release.gpg
Ign file: stable/non-free Translation-en_GB
Ign file: edgy/main Translation-en_GB
Ign file: stable Release
Get: 1 file: edgy Release.gpg [191B]
Ign file: stable/non-free Packages
Get: 2 file: edgy-security Release.gpg [189B]
Get: 3 file: edgy-updates Release.gpg [189B]
Get: 4 file: edgy-commercial Release.gpg [191B]
Get: 5 file: edgy-plf Release.gpg [189B]
Get: 6 file: edgy Release.gpg [189B]
Get: 7 file: edgy Release.gpg [189B]
Get: 8 file: edgy Release [34.7kB]
Get: 9 file: edgy-security Release [19.6kB]
Get: 10 file: edgy-updates Release [19.6kB]
Get: 11 file: edgy-commercial Release [4874B]
Get: 12 file: edgy-plf Release [9454B]
Get: 13 file: edgy Release [5755B]
Get: 14 file: edgy Release [4147B]
Ign file: edgy/main Packages
Ign file: edgy/restricted Packages
Ign file: edgy/universe Packages
Ign file: edgy/multiverse Packages
Ign file: edgy/main Sources
Ign file: edgy/restricted Sources
Ign file: edgy/universe Sources
Ign file: edgy/multiverse Sources
Ign file: edgy-security/main Packages
Ign file: edgy-security/restricted Packages
Ign file: edgy-security/universe Packages
Ign file: edgy-security/multiverse Packages
Ign file: edgy-security/main Sources
Ign file: edgy-security/restricted Sources
Ign file: edgy-security/universe Sources
Ign file: edgy-security/multiverse Sources
Ign file: edgy-updates/main Packages
Ign file: edgy-updates/restricted Packages
Ign file: edgy-updates/universe Packages
Ign file: edgy-updates/multiverse Packages
Ign file: edgy-updates/main Sources
Ign file: edgy-updates/restricted Sources
Ign file: edgy-updates/universe Sources
Ign file: edgy-updates/multiverse Sources
Ign file: edgy-commercial/main Packages
Ign file: edgy-plf/free Packages
Ign file: edgy-plf/non-free Packages
Ign file: edgy-plf/free Sources
Ign file: edgy-plf/non-free Sources
Ign file: edgy/main-edgy Packages
Ign file: edgy/main Packages
Fetched 99.5kB in 0s (383kB/s)
Reading package lists... Done

Yay!

Install stuff

Here’s where we try to install stuff off the local mirror. I’ll just get
a small package. Note that it doesn’t copy the package to the local
filesystem “Need to get 0B”, but instead unpacks it directly from the
repo “Unpacking cowsay (from …/c/cowsay/cowsay_3.03-8_all.deb) …”. All
very good stuff. Like it.

alan@multivac:~$ sudo apt-get install cowsay
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed
  cowsay
0 upgraded, 1 newly installed, 0 to remove and 23 not upgraded.
Need to get 0B/17.9kB of archives.
After unpacking 274kB of additional disk space will be used.
Selecting previously deselected package cowsay.
(Reading database ... 156031 files and directories currently installed.)
Unpacking cowsay (from .../c/cowsay/cowsay_3.03-8_all.deb) ...
Setting up cowsay (3.03-8) ...

Test installed stuff

alan@multivac:~$ cowsay apt-mirror rocks!
 ___________________
< apt-mirror rocks! >
 -------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

Test upgrading

Lets just make sure an upgrade works.

alan@multivac:~$ sudo apt-get upgrade
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following packages have been kept back:
python-adns python-clientcookie python-crypto python-egenix-mxproxy
python-egenix-mxstack python-egenix-mxtexttools python-htmlgen
python-htmltmpl python-jabber python-kjbuckets python-ldap
python-mysqldb python-pam python-pexpect python-pylibacl
python-pyopenssl
python-pyxattr python-simpletal python-soappy python-sqlite python-syck
python-xmpp
The following packages will be upgraded:
ubuntu-docs
1 upgraded, 0 newly installed, 0 to remove and 22 not upgraded.
Need to get 0B/4984kB of archives.
After unpacking 123kB disk space will be freed.
Do you want to continue [Y/n]?
(Reading database … 156091 files and directories currently installed.)
Preparing to replace ubuntu-docs 6.10.3 (using
…/ubuntu-docs_6.10.4_all.deb) …
Unpacking replacement ubuntu-docs …
Setting up ubuntu-docs (6.10.4) …

Future options

What I will likely do is keep this USB hard disk up to date but rsync
the contents to a local fileserver so that I have it accessible not only
via USB but also via NFS/SMB. That way I can share it out over the
network. I don’t really want to share out a USB hard disk, as it’s a
transient connection. I’d rather share out a permanent directory on a
fileserver.

I have a fileserver called “hal” which I could backup to like this:-

alan@multivac:~$ rsync -avz -e ssh /media/usbdisk/repo alan@hal:/mnt/media/

That will copy the entire contents of my repository over the network via
SSH to /mnt/media on the server hal.

I could reduce the overall download size by eliminating some stuff. For
example I could choose not to download all the source packages by
commenting out the lines starting “deb-src”. I could also reduce the
number of architetures, for example not downloading the AMD64 binaries
because I don’t (currently) have any AMD64 based systems.

My ISP provides me with a higher bandwidth allocation at night than
during the day. So it might also be useful to schedule an apt-mirror via
cron to run during the nightime hours to take advantage of this.

Tweet

This entry was posted in
Advocacy,
Linux,
Ubuntu. Bookmark the
permalink.
Post a
comment

or leave a trackback: Trackback
URL
.

« Ad-Hoc Palm TX Hotsync to
Linux

The bullying from Microsoft begins –
again»

暗中认可的根目录是/var/www,接下去笔者会symlink那些目录到Debian and Ubuntu
的软件仓库所在目录。
4配置apt-mirror
apt-mirror的配置文件在/ etc/apt/mirror.list,debian
sarge中的默许配置文件如下:

17 Comments
  1. 图片 4Anonymous

    Posted May 4, 2009 at 1:22 am |
    Permalink

    I keep getting the following error:

    apt-mirror: can’t utime
    /var/spool/apt-mirror/mirror/mirrors.kernel.org/ubuntu/dists/jaunty/Release
    at /usr/bin/apt-mirror line 494.

    I have searched everywhere and have not been able to find what
    utime?

    Reply

  2. 图片 5Sayali

    Posted March 12, 2009 at 3:19 pm |
    Permalink

    Is it possible to restrict the list of packages to be mirrored
    locally?

    If yes, could someone please help me in finding how I can specify
    only a certain set of .deb files to be mirrored locally? E.g. if I
    know for sure that I need the packages from files: x.deb, y.deb and
    z.deb only, then what should be my mirror.list file?

    Thanks in advance for all the help.

    –Sayali

    Reply

  3. 图片 6Edgar Vega

    Posted June 21, 2009 at 11:00 pm |
    Permalink

    Hi!

    Thanks for this tutorial… its really great, I am taking advantage of
    this information…! Wonderfull!!!

    Reply

  4. 图片 7Maxx44

    Posted October 23, 2009 at 12:20 pm |
    Permalink

    And, if we have a 50 year mission, all of Mozilla needs to be
    looking over the horizon in this way. ,

    Reply

    More from author

  5. 图片 8tewogbade

    Posted November 12, 2010 at 4:53 pm |
    Permalink

    thanks, this was very helpful
    really love it
    but i want to ask what happens when the distribution changes does i
    mean that my local repository is now outdated and i will have to
    make another mirror of the new distro repo

    Reply

    More from
    author

  6. 图片 9Michael

    Posted May 11, 2012 at 6:59 pm |
    Permalink

    One obvious but oft overlooked possibility that had me confused for
    an age is the number of concurrent connections permitted by the site
    you are trying to mirror from.

    I had to reduce the number of threads in mirror.list to 5 (the max
    allowed by my source site) before I was successful

    Reply

  7. 图片 10Tony
    Whitmore

    Posted April 21, 2007 at 2:59 pm |
    Permalink

    What apt-mirror actually does is only download packages for the
    architecture on which it is running. At least, that’s the default
    behaviour. So if the computer running apt-mirror is an i386 machine,
    then you won’t get PPC or AMD64 packages, nor any other
    architecture. People using this software to mirror Debian servers
    are probably quite grateful for this, but sadly there’s not a lot of
    documentation for apt-mirror.

    It seems you can specify a default architecture to mirror on the
    “set defaultarch” line. That’s useful if you want to mirror one arch
    on a server of a different arch. If you want to mirror multiple
    archs you have to specify lines for each in the config file, for
    example:
    `deb-i386 http://gb.archive.ubuntu.com/ubuntu feisty main restricted universe multiverse

           deb-amd64 http://gb.archive.ubuntu.com/ubuntu feisty main restricted universe multiverse`
    

    Reply

    More from author

  8. 图片 11Icarus

    Posted December 5, 2007 at 12:56 pm |
    Permalink

    Very useful !! Thanks a lot for your comment !!

    Reply

  9. 图片 12Manena

    Posted February 7, 2007 at 8:39 am |
    Permalink

    Thank you for this very nice tutorial. Can you please be so kind and
    tell how to download only packages for i386?

    Reply

  10. 图片 13serverchef

    Posted April 1, 2007 at 12:02 am |
    Permalink

    just replace every deb line with deb-i386

    for example:

    deb http://gb.archive.ubuntu.com/ubuntu edgy main restricted
    universe multiverse

    becomes

    deb-i386 http://gb.archive.ubuntu.com/ubuntu edgy main restricted
    universe multiverse

    good luck !

    Reply

  11. 图片 14Tony
    Whitmore

    Posted April 19, 2007 at 10:46 pm |
    Permalink

    This page shows how to finish the configuration off – setting up
    Apache to server the repositories via HTTP. HOWTO Forge Local
    Debian and Ubuntu
    Mirror
    .

    Reply

    More from author

  12. 图片 15John

    Posted June 15, 2008 at 5:26 pm |
    Permalink

    I used the above procedure to mirror the i386 ubuntu repo. I can use
    it to update and install new software on existing systems (after
    source.list has been modified) that’s no problem. What’s
    frustrating, is that I CANNOT use the local mirror to install a NEW
    ubuntu install using the net installer CD!!! It complains that the
    Release file is not valid! When I browse the local repo I can see
    the Release file (but it obviously contains info for other
    architectures). Is there a way to regenerate the local Release file
    so that it is “proper” by means of a script? so that it doesn’t
    refer to packages for architectures that are not present? Would
    really appreciate any help – as that’s why I wanted to set up a
    local mirror in the first place – to be able to install multiple
    systems from the local LAN. Thanks.

    Reply

    More from author

  13. 图片 16Anonymous

    Posted October 8, 2007 at 9:56 pm |
    Permalink

    When I run sudo apt-mirror -d, I get the following.

    Downloading 21 index files using 20 threads…
    Begin time: Mon Oct 8 12:38:01 2007
    [20]… [19]… [18]… [17]… [16]… [15]… [14]… [13]…
    [12]… [11]… [10]… [9]… [8]… [7]… [6]… [5]… [4]…
    [3]… [2]… [1]… [0]…
    End time: Mon Oct 8 12:42:03 2007

    Proceed indexes: [Psh: cannot open
    us.archive.ubuntu.com/ubuntu//dists/feisty/main/binary-i386/Packages.gz:
    No such file
    apt-mirror: can’t open index in proceed_index_gz at
    /usr/bin/apt-mirror line 368.

    Any ideas on whats wrong.

    Reply

    ##### Leave a Reply Cancel reply

  14. 图片 17Angus

    Posted November 5, 2008 at 12:49 pm |
    Permalink

    In your /etc/apt/mirror.list file you put a / at the end of
    us.archive.ubuntu.com/ubuntu .

    Don’t, and it’s fine.

    Reply

  15. 图片 18Allan

    Posted July 19, 2007 at 4:46 am |
    Permalink

    I was able to netboot and install from a local mirror thanks to this
    resource and a few others. However, when netbooting, additional
    mirror sets are required. I posted some information about this on
    the Ubuntu wiki:

    https://help.ubuntu.com/community/Installation/LocalNet

    My apt-mirror section could probably use some input by someone who
    knows something. I’m just a guy who patiently bungled my way to
    success with a lot of help from blogs like this.

    Reply

  16. 图片 19gaZooGA

    Posted November 17, 2008 at 12:09 pm |
    Permalink

    You must un comment the line below from your /etc/apt/mirror.list
    config for it to work, or else everything will download to
    /var/spool/apt-mirror as opposed to /media/usbdisk/repo.

    set mirror_path $base_path/mirror
    set skel_path $base_path/skel
    set var_path $base_path/var
    set cleanscript $var_path/clean.sh

    Reply

  17. 图片 20Wayne

    Posted December 30, 2008 at 6:59 pm |
    Permalink

    I am having trouble with installing new updates that have been
    downloaded to my local repository with apt-mirror. I have downloaded
    both deb-i386 and deb-amd64 to a local repository in hopes of
    supporting multiple machines on my home network. However, after
    weeks of downloading updates, my update manager does not find any
    updates to install. I am using this format in my sources.list file:

    deb file:/var/spool/apt-mirror/mirror/archive.ubuntu.com/ubuntu
    hardy main restricted universe multiverse
    deb-src file:/var/spool/apt-mirror/mirror/archive.ubuntu.com/ubuntu
    hardy main restricted universe multiverse
    deb file:/var/spool/apt-mirror/mirror/archive.ubuntu.com/ubuntu
    hardy-security main restricted universe multiverse
    deb file:/var/spool/apt-mirror/mirror/archive.ubuntu.com/ubuntu
    hardy-updates main restricted universe multiverse

    I have verified that apt-mirror is working and downloading files.

    Any suggestions about what is wrong with my configuration?
    Thanks.

    Reply

===================================================================================

引用:

Debian apt Source mirror using apt-mirror

apt-mirror is a small tool that provides ability to mirror any parts (or
even all) of Debian GNU/Linux
distribution

or any other apt sources which often provided by many
debian
developers.

If you want to download apt-mirror click
here

Installing apt-mirror in Debian

add to ‘sources.list’ line i.e /etc/apt/sources.list
file

deb http://apt-mirror.sourceforge.net/ apt-mirror/ and run

# apt-get update

# apt-get install apt-mirror

Configuring sources for apt-mirror

Open ‘mirror.list’ (from /etc/apt/ or whatever you installed it to) and
add needed sources like in /etc/apt/sources.list. Finally your
mirror.list may looks like this:

# apt-mirror configuration
file

##
## The default
configuration

options (uncomment and change to override)
##
#
# 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 defaultarch
# set nthreads 20
#

##
## Example sources
##

# sarge’s section
deb http://ftp.us.debian.org/debian sarge main contrib non-free
deb-src http://ftp.us.debian.org/[debian
sarge](http://www.debianadmin.com/debian-apt-source-mirror-using-apt-mirror.html)
main contrib non-free

# this source required for network
installation

ability (udebs)
deb http://ftp.us.debian.org/debian sarge main/debian-installer

# security
updates

is always good thing to install
deb http://security.debian.org/debian-security sarge/updates main
contrib non-free
deb-src http://security.debian.org/debian-security sarge/updates main
contrib non-free

# sarge-proposed-updates’s section
deb http://ftp.us.debian.org/debian sarge-proposed-updates main contrib
non-free
deb-src http://ftp.us.debian.org/debian sarge-proposed-updates main
contrib non-free

##
## Cleaner configuration example
##
#
# set cleanscript $var_path/clean.sh
#

# What directories should we clean up
# (i.e. remove files
missing

in up-to-date indexes)
clean http://security.debian.org/
clean http://ftp.us.debian.org/

# But exclude this directories
# (which is not managed by apt and apt-mirror)
skip-clean http://ftp.us.debian.org/debian-cd/
skip-clean
http://ftp.us.debian.org/debian/dists/sarge/main/installer-i386/
skip-clean http://ftp.us.debian.org/debian/doc/
skip-clean http://ftp.us.debian.org/debian/tools/
skip-clean http://ftp.us.debian.org/debian/project/

Running apt-mirror

Now we may run ‘apt-mirror’

# su — apt-mirror -c apt-mirror

You also can run apt-mirror from cron. Uncomment line in
/etc/cron.d/apt-mirror for this purpose.

# apt-mirror configuration file
##
## The default configuration options (uncomment and change to
override)
##
#
# 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 defaultarch
# set nthreads 20
#
##
## Example sources
##
# sarge’s section
deb http://ftp.fi.debian.org/debian sarge main contrib non-free
deb-src http://ftp.fi.debian.org/debian sarge main contrib non-free
deb http://security.debian.org/debian-security sarge/updates main
contrib non-free
deb-src http://security.debian.org/debian-security sarge/updates main
contrib non-free
deb http://ftp.fi.debian.org/debian sarge main/debian-installer
# sarge-proposed-updates’s section
deb http://ftp.fi.debian.org/debian sarge-proposed-updates main
contrib non-free
deb-src http://ftp.fi.debian.org/debian sarge-proposed-updates main
contrib non-free
# sid’s section
deb http://ftp.fi.debian.org/debian sid main contrib non-free
deb-src http://ftp.fi.debian.org/debian sid main contrib non-free
deb http://ftp.fi.debian.org/debian sid main/debian-installer
# experimental section
deb http://ftp.fi.debian.org/debian ../project/experimental main
contrib non-free
deb-src http://ftp.fi.debian.org/debian ../project/experimental main
contrib non-free
##
## Cleaner configuration example
##
#
# set cleanscript $var_path/clean.sh
#
# Cleaning section
clean http://security.debian.org/
clean http://ftp.fi.debian.org/
skip-clean http://ftp.fi.debian.org/doc/
skip-clean http://ftp.fi.debian.org/tools/
skip-clean http://ftp.fi.debian.org/debian-cd/
skip-clean http://ftp.fi.debian.org/debian-minicd/
skip-clean http://ftp.fi.debian.org/debian/dists/s …
ller-i386/

skip-clean http://ftp.fi.debian.org/debian/dists/s …
ller-i386/

skip-clean http://ftp.fi.debian.org/debian/doc/
skip-clean http://ftp.fi.debian.org/debian/tools/
skip-clean http://ftp.fi.debian.org/debian/project/
skip-clean http://ftp.fi.debian.org/debian-non-US/project/

Ubuntu 艾德gy Eft中的默许文件如下:

引用:

############# config ##################
#
# set base_path /var/spool/apt-mirror
#
# if you change the base path you must create the directories below
with write privlages
#
# 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
set nthreads 20
set tilde 0
#
############# end config ##############
deb http://archive.ubuntu.com/ubuntu edgy main restricted universe
multiverse
deb http://archive.ubuntu.com/ubuntu edgy-updates main restricted
universe multiverse
#deb http://archive.ubuntu.com/ubuntu edgy-backports main restricted
universe multiverse
deb http://archive.ubuntu.com/ubuntu edgy-security main restricted
universe multiverse
#deb http://archive.ubuntu.com/ubuntu edgy-proposed main restricted
universe multiverse
deb-src http://archive.ubuntu.com/ubuntu edgy main restricted universe
multiverse
deb-src http://archive.ubuntu.com/ubuntu edgy-updates main restricted
universe multiverse
#deb-src http://archive.ubuntu.com/ubuntu edgy-backports main
restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu edgy-security main restricted
universe multiverse
#deb-src http://archive.ubuntu.com/ubuntu edgy-proposed main
restricted universe multiverse
clean http://archive.ubuntu.com/ubuntu

只要您相比/etc/apt/sources.list
和/etc/apt/mirror.list,你会发现互相卓殊相像,二者都列举了一些应有被镜像的软件库,此外还有部分别的采取。
近年来自己修改/etc/apt/mirror.list.就象作者日前说过的一致,小编要镜像Debian
Sarge的main,contrib 和non-free部分和 Ubuntu 艾德gy Eft的 main, restricted,
universe部分
,不镜像应该一向从互连网上下载的河池部分。其余,小编也从没镜像源代码包,因为95%的安装文件不须要源代码,而源代码包文件又会占据巨大的硬盘空间。所以本人的/etc/apt/mirror.list
修改成上面包车型客车规范:

代码:

vi /etc/apt/mirror.list

引用:

# apt-mirror configuration file
##
## The default configuration options (uncomment and change to
override)
##
#
# 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 defaultarch
# set nthreads 20
#
##
## Example sources
##
# sarge’s section
deb http://ftp.de.debian.org/debian sarge main contrib non-free
# Ubuntu Edgy Eft
deb http://de.archive.ubuntu.com/ubuntu/ edgy main restricted
universe
##
## Cleaner configuration example
##
#
# set cleanscript $var_path/clean.sh
#
# Cleaning section
clean http://ftp.de.debian.org/
clean http://de.archive.ubuntu.com/

请留心自个儿用ftp.de.debian.org 代替了ftp.fi.debian.org ,用
de.archive.ubuntu.com代替了
archive.ubuntu.com.
你应该接纳二个距离你比较近的镜像,所以一旦你在U.S.,就用us替代de。
最终的cleaning部分报告apt-mirror本地的硬盘应该和哪个软件仓库比较以明确如何文件能够活动清除掉。作者要反省Debian
和Ubuntu全体的软件,所以本人修改成了,
clean http://ftp.de.debian.org/
clean http://de.archive.ubuntu.com/
要是您使用了别样的
Debian/Ubuntu版本,请用etch或许sid替换sarge;breezy只怕dapper替换edgy。
5成立本地软件仓库
今后apt-mirror已经安插好了,未来应该首先次运转它,下载全体的包构建本地的Debian/Ubuntu软件仓库。大家只供给执行:
[code]
su – apt-mirror -c apt-mirror
[/eode]
apt-mirror会告诉你毕竟要下载多少GB的公文。那将会花上多少个钟头,所以要耐心点。那个包将会储存在/var/spool/apt-mirror/mirror的子目录中,所以您要保险该分区还有丰硕的硬盘空间。
debian的在/var/spool/apt-mirror/mirror/ftp.de.debian.org/debian,
unbuntu的在/var/spool/apt-mirror/mirror/de.archive.ubuntu.com/ubuntu.
即使您在第六步选用了一个两样的镜像,那么那个途径只怕有点不一致。
6清理软件仓库
等到apt-mirror下载完了富有的包,它卓殊也许会告知您能够解除出有些硬盘空间来,使用以下脚本:
/bin/bash /var/spool/apt-mirror/var/clean.sh
输出如下:
server1:~# /bin/bash /var/spool/apt-mirror/var/clean.sh
Removing 157 unnecessary files [13316096 bytes]…
[0%]…………….done.
Removing 18 unnecessary directories…
[0%]………………done.
那样你就能观望有个别许硬盘空间被清理出去了。
7 更新本地软件仓库
立异本地镜像是非常简单的,执行
[code]su – apt-mirror -c apt-mirror [/code]
若是你不想手工业执行更新,那么您能够编写制定三个定时执行的corn职务。只须求编辑/etc/corn.d/apt-mirror,在结尾一行添加如下即可:
[code]vi /etc/cron.d/apt-mirror [/code]

引用:

#
# Regular cron jobs for the apt-mirror package
#
0 4 * * * apt-mirror /usr/bin/apt-mirror >
/var/spool/apt-mirror/var/cron.log

8 由此http访问镜像
Apache默许的根目录是/var/www,但是软件仓库却在/var/spool/apt-mirror/mirror
为了可以通过 http://192.168.0.100/debian and
http://192.168.0.100/ubuntu
做客到相应的软件库,我们得以symlinks /var/www/debian and
/var/www/ubuntu到实在的库地址。
[code]ln -s /var/spool/apt-mirror/mirror/ftp.de.debian.org/debian
/var/www/debian
ln -s /var/spool/apt-mirror/mirror/de.archive.ubuntu.com/ubuntu
/var/www/ubuntu[/code]
若是你使用了其余镜像,记得调整那两行命令。
接下去要考虑的一件业务是,你觉得DebianSarge是sarge而且是平安无事的e(至少近年来是平安的,而Etch依然在测试中),那么当您运营
[code]ls -l
/var/spool/apt-mirror/mirror/ftp.de.debian.org/debian/dists [/code]
您会意识那里有一个sarge的目录,但却是不安定的,不过一旦您在source.list中用稳定的更迭了
sarge,只怕在当地全新安装3个debian系统,那样就会并发那样的题材debian
sarge的安装工具仍然会认为stable替换sarge。消除办法是
[code]cd /var/spool/apt-mirror/mirror/ftp.de.debian.org/debian/dists
ln -s sarge/ stable[/code]
当debian
Etch变成稳定版本的时候你也足以镜像Etch。到时候不要忘了改动stable的symlink。
[code]cd /var/spool/apt-mirror/mirror/ftp.de.debian.org/debian/dists
rm -f stable
ln -s etch/ stable [/code]
其一难题不会产出在ubuntu中。
9 布局你的客户端电脑使用当地镜像
现行反革命地面镜像已经足以选拔了,大家所要做得是告诉 Debian Sarge和Ubuntu 艾德gy
Eft 系统如何使用当地镜像。
Debian
Sarge系统,在source。list中期维修改main,contrib,non-free的软件仓库
vi /etc/apt/sources.list
[…]
deb http://192.168.0.100/debian sarge main contrib non-free
[…]
Instead of sarge you could also use stable:
[…]
deb http://192.168.0.100/debian stable main contrib non-free
[…]
下一场运转:
apt-get update
在 Ubuntu Edgy Eft系统中,你能够在sources.list中改换 main restricted
universe的软件仓库。
vi /etc/apt/sources.list
[…]
deb http://192.168.0.100/ubuntu/ edgy main restricted universe
[…]
接下来运营:
apt-get update
9.3 全新安装系统
假若您从本地镜像全新安装1个 Debian Sarge 只怕 Ubuntu 艾德gy
Eft那么你能够遵照以下步骤举行:
10相关链接
* apt-mirror: http://apt-mirror.sourceforge.net
* Debian: http://www.debian.org
* Ubuntu: http://www.ubuntu.com

相关文章