CentOS repository

Print Friendly, PDF & Email

I think it makes sense to set up a local mirror/repository for CentOS packages, at least for our workstations.  I’m following the directions here, which seem to be quite clear:  http://wiki.centos.org/HowTos/CreateLocalMirror.

We can later investigate the option of doing a network install, like  http://wiki.centos.org/TipsAndTricks/VncHeadlessInstall.  More at http://wiki.centos.org/TipsAndTricks.

First, we need some space.  We’re not using Puma’s disks, and this seems like a good use of that non-backed-up space, so I’m going to delete the files in /students-puma, unmount that (modifying fstab) and create a /share volume that will be exported on-campus:

[root@puma ~] umount /students-puma/
[root@puma ~] emacs -nw /etc/fstab
[root@puma ~] mount /dev/mapper/vg0-lvstud /share
[root@puma ~] mkdir -p /share/CentOS/6.3
[root@puma ~] cd /share/CentOS/
[root@puma CentOS] ln -s 6.3 6
[root@puma CentOS] emacs -nw /etc/exports
[root@puma CentOS] grep share /etc/exports
/share 149.130.0.0/16(ro)
[root@puma CentOS] service nfs restart

I set up the desired directory structure.  I think only the first three are necessary for our purposes, and frankly, I don’t know what the others are, but it can’t hurt, to have them, I think.

[root@puma CentOS] mkdir -p 6.3/isos/i386
[root@puma CentOS] mkdir -p 6.3/os/i386
[root@puma CentOS] mkdir -p 6.3/updates/i386
[root@puma CentOS] mkdir -p 6.3/extras/i386
[root@puma CentOS] mkdir -p 6.3/fastrack/i386
[root@puma CentOS] mkdir -p 6.3/cr/i386
[root@puma CentOS] mkdir -p 6.3/contrib/i386
[root@puma CentOS] mkdir -p 6.3/centosplus/i386
[root@puma CentOS] mkdir -p 6.3/addons/i386

I copied the .iso files to the isos/i386 directory and then did:

[root@puma CentOS] mkdir /tmp/mnt
[root@puma CentOS] mount -ro loop /share/CentOS/6.3/isos/i386/CentOS-6.3-i386-bin-DVD1.iso /tmp/mnt
[root@puma CentOS] rsync -aHS /tmp/mnt/ /share/CentOS/6.3/os/i386/
[root@puma CentOS] umount /tmp/mnt
[root@puma CentOS] mount -ro loop /share/CentOS/6.3/isos/i386/CentOS-6.3-i386-bin-DVD2.iso /tmp/mnt
[root@puma CentOS] rsync -aHS /tmp/mnt/ /share/CentOS/6.3/os/i386/

That looks like:

[root@puma i386] pwd
/share/CentOS/6.3/os/i386
[root@puma i386] ls
CentOS_BuildTag  images    RELEASE-NOTES-en-US.html  RPM-GPG-KEY-CentOS-Debug-6     TRANS.TBL
EULA             isolinux  repodata                  RPM-GPG-KEY-CentOS-Security-6
GPL              Packages  RPM-GPG-KEY-CentOS-6      RPM-GPG-KEY-CentOS-Testing-6
[root@puma i386]

I wrote the following script, based on their example.  I chose gigenet as the mirror site because Illinois isn’t too far, and they support rsync.

[root@puma i386] emacs -nw /home/sysadmin/bin/rsync-update-CentOS
[root@puma i386] chmod a+rx !$
chmod a+rx /home/sysadmin/bin/rsync-update-CentOS
[root@puma bin] cat /home/sysadmin/bin/rsync-update-CentOS
#!/bin/bash

# Script to run regularly to mirror all the updates to the CentOS distribution
# Almost identical to model at http://wiki.centos.org/HowTos/CreateLocalMirror

# bail out on errors
set -e

progname=`basename $0`

lockfile=/var/lock/subsys/$progname
if [ -f $lockfile ]; then
    echo "$progname is already running"
    exit 0
fi

mirror=rsync://mirrors.gigenet.com:/centos
release=6.3
target=/share/CentOS/$release

if [ -d $target ] ; then
    touch $lockfile
    # omit -v and -P since we're running unattended
    # be careful with the trailing slashes
    rsync -aSH --delete --exclude "local*" --exclude "isos" $mirror/$release/ $target/
    rm $lockfile
else
    echo "Target directory $target not present"
fi

Okay, let’s give it a try:

[root@puma bin] update-root-dirs 
[root@puma bin] rsync-update-CentOS 
Linux mirrors.gigenet.com 2.6.32-5-amd64 #1 SMP Mon Oct 3 03:59:20 UTC 2011 x86_64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.

[root@puma bin]

Several hours and 29GB later, we have a mirror!

Next, we have to set up a repo file.  Ah, they recommend using either ProtectBase or Priorities. These seem like really good idea, though we can’t use it with RHEL, since there isn’t a .repo file (very strange).

I think I will copy a .repo file from one of the new CentOS clients and edit it to use the local repository.  We’ll also have to mount the /share volume from Puma to the client.  I don’t know yet whether to keep that volume mounted all the time or only when doing updates.  Probably only when necessary.  We can write a little yum-update script that mounts /share, does the update, and un-mounts it.

 

About CS SysAdmins

The CS Department System Administrators
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *