ubuntu11.04制作离线镜像源,主要针对的是没网络,在安装完ubuntu11.04后也可以对其进行更新。。

注:在安装ubuntu11.04时,最好给var独立分一个大的分区(50G左右),因为镜像源的默认位置是在var这个目录下的。

下面过程是偶亲测过的:

1.安装相应的软件(下面的软件也可以用 ubuntu软件中心 搜索来安装)

命令:

sudo apt-get install apt-mirror

sudo apt-get apache2(这个主要是镜像对局域网或互联网开放的)


2.配制镜像

sudo gedit /etc/apt/mirror.list

直接把里面的东西全部删掉,然后把下面的代码复制进去。(默认镜像的存放位置是:/var/apt/spool/apt-mirror/;)

代码:

set nthreads 4

set _tilde 0

deb http://free.nchc.org.tw/ubuntu/ natty multiverse

##deb-src http://free.nchc.org.tw/ubuntu/ natty multiverse

deb http://free.nchc.org.tw/ubuntu/ natty main restricted

##deb-src http://free.nchc.org.tw/ubuntu/ natty main restricted

deb http://free.nchc.org.tw/ubuntu/ natty universe

##deb-src http://free.nchc.org.tw/ubuntu/ natty universe

deb http://free.nchc.org.tw/ubuntu/ natty-updates universe

##deb-src http://free.nchc.org.tw/ubuntu/ natty-updates universe

deb http://free.nchc.org.tw/ubuntu/ natty-updates main restricted

##deb-src http://free.nchc.org.tw/ubuntu/ natty-updates main restricted

deb http://free.nchc.org.tw/ubuntu/ natty-security universe

##deb-src http://free.nchc.org.tw/ubuntu/ natty-security universe

deb http://free.nchc.org.tw/ubuntu/ natty-security main restricted

##deb-src http://free.nchc.org.tw/ubuntu/ natty-security main restricted

deb http://free.nchc.org.tw/ubuntu/ natty-updates multiverse

##deb-src http://free.nchc.org.tw/ubuntu/ natty-updates multiverse

deb http://free.nchc.org.tw/ubuntu/ natty-security multiverse

##deb-src http://free.nchc.org.tw/ubuntu/ natty-security multiverse

deb http://extras.ubuntu.com/ubuntu natty main

##deb-src http://extras.ubuntu.com/ubuntu natty main

clean http://free.nchc.org.tw/ubuntu/

#注:红色标志的是ubunt11.04特有的。另外,这个源偶也测试过了,是可以的,不过当你看到这篇文章不#知已过了多久,这源还能不能用就不知道了,如果不能,网上搜一下吧。谁叫你那么迟看到这篇文章

#呢。。。呵呵。



也可以指定镜像存放位置:

引用

############# config ##################

#

set base_path  /home/tang/work

#

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

#注:把开始那里的代码改成这样就行了,/home/tang/work 这个就是你要存放的位置,具体你要存放在

#哪,你自己就看着办吧。


3.开始进行镜像

命令:

sudo apt-mirror

然后就是开始了,在镜像期间可以中断,下次再执行sudo apt-mirror这条命令即可,原来下载过的是不会重新下载的。

上面的更新源不加上src的,大概有40几G吧。

快不快那就要看你的网速了!


当上面的进行完后,接着看下面:

4.接下来就是要执行下面这条命令:

ln -s /var/spool/apt-mirror/mirror/free.nchc.org.tw/ubuntu/ /var/www/ubuntu

注:这个是默认镜像的路径的,如果你改变了镜像的路径的,那这条命令的/var/spool/apt-mirror/mirror/free.nchc.org.tw/ubuntu/这部分改为你改的那个路径。


5.完成上面的步骤后,接下来就可以在自己虚拟机里的或者是在同一个局域网的ubuntu11.04的/etc/apt/sourse.list列表中配置下载更新源了,先输入命令gedit /etc/apt/sourse.list,然后

把下面的代码复制进去:

deb http://172.21.25.69/ubuntu/ natty multiverse

##deb-src http://172.21.25.69/ubuntu/ natty multiverse

deb http://172.21.25.69/ubuntu/ natty main restricted

##deb-src http://172.21.25.69/ubuntu/ natty main restricted

deb http://172.21.25.69/ubuntu/ natty universe

##deb-src http://172.21.25.69/ubuntu/ natty universe

deb http://172.21.25.69/ubuntu/ natty-updates universe

##deb-src http://172.21.25.69/ubuntu/ natty-updates universe

deb http://172.21.25.69/ubuntu/ natty-updates main restricted

##deb-src http://172.21.25.69/ubuntu/ natty-updates main restricted

deb http://172.21.25.69/ubuntu/ natty-security universe

##deb-src http://172.21.25.69/ubuntu/ natty-security universe

deb http://172.21.25.69/ubuntu/ natty-security main restricted

##deb-src http://172.21.25.69/ubuntu/ natty-security main restricted

deb http://172.21.25.69/ubuntu/ natty-updates multiverse

##deb-src http://172.21.25.69/ubuntu/ natty-updates multiverse

deb http://172.21.25.69/ubuntu/ natty-security multiverse

##deb-src http://172.21.25.69/ubuntu/ natty-security multiverse

deb http:// 172.21.25.69/ubuntu natty main

##deb-src http:// 172.21.25.69/ubuntu natty main

##注:上面的172.21.25.69改为你实际的ip即可,局域网或互联网用户也是只要把地址172.21.25.69改为你的实际ip地址即可。


ps:要想制作其它发行版的离线本地源镜像也是依照上面的方法即可!