本地的源,可以为你节省大量的时间,尤其在我们这种网络不是太好的环境下。现在很多朋友遇到的无法找到某个包,这种问题基本都是网络造成的。
对于服务器来说,其实只需要64bit就可以,不过你会发现,如果你运行 apt-get update 的话,默认源的设置,还是需要下载i386.
所以未来避免那种错误的提示,你需要把ubuntu 12.04源里所有的东西都下载回来。包括64bit,32bit,源码包。
这个脚本运行环境,需要debmirror. 这是老外写的脚本,我改了一下,加上一个参数:–ignore-release-gpg
http://ubuntuforums.org/showpost.php?p=7367273&postcount=237
http://www.gtkdb.de/index_7_1670.html
########################################################################### ## ## ## Ubuntu Mirror Script ## ## ## ## Creation: 06.07.2008 ## ## Last Update: 02.06.2012 ## ## ## ## Copyright (c) 2008-2012 by Georg Kainzbauer <georgkainzbauer@gmx.net> ## ## ## ## This program is free software; you can redistribute it and/or modify ## ## it under the terms of the GNU General Public License as published by ## ## the Free Software Foundation; either version 2 of the License, or ## ## (at your option) any later version. ## ## ## ########################################################################### #!/bin/sh # Ubuntu mirror server and mirror directory #SOURCE_SRV=cn.archive.ubuntu.com #SOURCE_SRV=archive.ubuntu.com SOURCE_SRV=mirrors.163.com SOURCE_DIR=/ubuntu # Distribution, section and architecture list DIST=precise,precise-security,precise-updates,precise-backports,precise-proposed SECTION=main,main/debian-installer,restricted,restricted/debian-installer,universe,universe/debian-installer,multiverse,multiverse/debian-installer ARCH=i386,amd64 # Local mirror directory #MIRRORDIR=/var/ftp/pub/linux/ubuntu/ MIRRORDIR=/home/ubuntu/ # Log file LOGFILE=/var/log/ubuntu_mirror.log # Debug file (if you do not want to debug the download process set this option to "/dev/null") DEBUGFILE=/var/log/ubuntu_mirror.debug # Who will be informed in case if anything goes wrong (if you do not want to be informed via mail, set this option to "") #MAILNOTIFY="root@localhost" # Lock file LOCK=/var/tmp/ubuntu_mirror.lock ################################################################## # NORMALY THERE IS NO NEED TO CHANGE ANYTHING BELOW THIS COMMENT # ################################################################## function log() { echo `date +%d.%m.%Y%t%H:%M:%S` " LOG:" $1 >>${LOGFILE} } function error() { echo `date +%d.%m.%Y%t%H:%M:%S` " ERROR:" $1 >>${LOGFILE} if [ -n "$MAILNOTIFY" ] ; then echo `date +%d.%m.%Y%t%H:%M:%S` " ERROR:" $1 | mail -s "ERROR while synchronizing Ubuntu" $MAILNOTIFY fi echo $1 | grep "Lockfile" >/dev/null if [ $? = 1 ] ; then rm -f ${LOCK} fi exit 1 } function status() { case "$1" in 0) log "Synchronization completed." ;; 1) error "DEBMIRROR: Connection closed" ;; 2) error "DEBMIRROR: Timeout" ;; *) error "DEBMIRROR: Unknown error $1" ;; esac } if [ -f ${LOCK} ] ; then error "Lockfile ${LOCK} exists." fi touch ${LOCK} # Create local mirror directory if not exists if [ ! -d ${MIRRORDIR} ] ; then log "Creating local mirror directory." mkdir -p ${MIRRORDIR} fi log "Starting Ubuntu download process." debmirror -v -e http -h ${SOURCE_SRV} -r ${SOURCE_DIR} --ignore-release-gpg --dist=${DIST} --section=${SECTION} --arch=${ARCH} ${MIRRORDIR} >> ${DEBUGFILE} 2>&1 status $? rm -f ${LOCK} exit 0
设置log
/etc/logrotate.d/ubuntu_mirror
/var/log/ubuntu_mirror.log { monthly rotate 3 compress delaycompress missingok notifempty } /var/log/ubuntu_mirror.debug { weekly rotate 3 compress delaycompress missingok notifempty }
这个时候,就可以查看到log。目前我正在同步中。
2012年7月17日更新
已经用上面脚本,成功把ubuntu 12.04的全部源都下载到本地,总共快120G,并且已经通过cobbler来安装ubuntu,非常顺利完成。