创建本地Ubuntu镜像

    • 参考文档 http://www.howtoforge.com/local_debian_ubuntu_mirror
    •  
    • 安装服务 : sudo apt-get install apt-mirror apache2
    •  
    • 配置apt-mirror(/etc/apt/mirror.list)
      ############# config ###################set base_path    /mnt/raid5/apt-mirror############# config ##################
      
      #修改默认路径
      
      set base_path    /mnt/raid5/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  amd64 #<running host architecture>
      
      set postmirror_script $var_path/postmirror.sh
      
      set run_postmirror 0
      
      set nthreads     20
      
      set _tilde 0
      
      #
      
      ############# end config ##############
      
      #Ubuntu 12.04 LTS
      
      deb http://mirrors.163.com/ubuntu precise main restricted universe multiverse
      
      deb http://mirrors.163.com/ubuntu precise-security main restricted universe multiverse
      
      deb http://mirrors.163.com/ubuntu precise-updates main restricted universe multiverse
      
      #deb http://mirrors.163.com/ubuntu precise-proposed main restricted universe multiverse
      
      #deb http://mirrors.163.com/ubuntu precise-backports main restricted universe multiverse
      
      #Ubuntu 14.04 LTS
      
      deb http://mirrors.163.com/ubuntu trusty main restricted universe multiverse
      
      deb http://mirrors.163.com/ubuntu trusty-security main restricted universe multiverse
      
      deb http://mirrors.163.com/ubuntu trusty-updates main restricted universe multiverse
      
      #没有同步源代码
      
      #deb-src http://mirrors.163.com/ubuntu precise main restricted universe multiverse
      
      #deb-src http://mirrors.163.com/ubuntu precise-security main restricted universe multiverse
      
      #deb-src http://mirrors.163.com/ubuntu precise-updates main restricted universe multiverse
      
      #deb-src http://mirrors.163.com/ubuntu precise-proposed main restricted universe multiverse
      
      #deb-src http://mirrors.163.com/ubuntu precise-backports main restricted universe multiverse
      
       
      
      clean http://mirrors.163.com/ubuntu
       
    • 创建本地仓库: su - apt-mirror -c apt-mirror #切换为root用户,否则需要为apt-mirror创建密码(206为mirror)
    •  
    • 清理本地仓库: sudo /bin/bash /mnt/raid5/apt-mirror/var/clean.sh
    •  
    • 配置自动同步本地源: sudo vim /etc/cron.d/apt-mirror #打开注释掉的最后一行
    •  
    • 让本地仓库可通过HTTP访问: sudo ln -sf /mnt/raid5/apt-mirror/mirror/mirrors.163.com/ubuntu/ /var/www/ubuntu
    • 配置客户端源(在个人电脑上)
      cd /etc/apt
      sudo rm sources.list.d/* apt.conf.d/* -rf
      sudo cp sources.list{,.bak}
      #用下面三行替换掉sources.list里的全部内容
      deb [arch=amd64] http://10.0.0.206/ubuntu/ precise main restricted universe multiverse
      deb [arch=amd64] http://10.0.0.206/ubuntu/ precise-updates main restricted universe multiverse
      deb [arch=amd64] http://10.0.0.206/ubuntu/ precise-security main restricted universe multiverse

    • 试试本地源
      sudo apt-get update

 

你可能感兴趣的:(ubuntu)