Setup repository for CentOS updates

Aim

To save download time and bandwidth every time I install a fresh CentOS system.

Choose an Official Mirror

I use the cuhk mirror at:

ftp://ftp.cuhk.edu.hk/pub/Linux/centos/

Scripts

Create this tree structure:

mkdir -p /mnt/usbdisk/centos/updates/
mkdir -p /mnt/usbdisk/centos/extras/
mkdir -p /mnt/usbdisk/centos/epel/

Run this script using cron.

#!/bin/bash

# mirror the updates from cuhk centos mirror
MIRROR_DIR=/mnt/usbdisk/centos

if [ ! -d "$MIRROR_DIR" ] ; then
        echo "Local mirror directory does not exist."
        exit 1
fi

cd $MIRROR_DIR
lftp -f $MIRROR_DIR/centos.lftp
centos.lftp
open ftp://ftp.cuhk.edu.hk/pub/Linux/centos/5/

mirror --delete --no-symlinks updates/i386 updates

mirror --delete --no-symlinks extras/i386 extras

open ftp://ftp.riken.jp/Linux/fedora/epel/5/

mirror --delete --no-symlinks i386 epel

Configure ngnix to serve the repository

Add these to nginx config:

        location /centos {
                root  /mnt/usbdisk/;
                autoindex on;
                allow 192.168.0.0/16;
                deny all;
        }

Configure yum to use the repository

Set in yum repo config

[updates]
baseurl=http://<server_ip>/centos/updates/
...

[extras]
baseurl=http://<server_ip>/centos/extras/
...

[epel]
baseurl=http://<server_ip>/centos/epel/
...
tips/setup_repository_for_centos_updates.txt · Last modified: 2010-05-05 14:32 by admin
Back to top
GNU Free Documentation License 1.3
chimeric.de = chi`s home Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0