Skip to main content
CentOS

Local CentOS YUM Repository

By September 23, 2013No Comments

Especially when working in lab environments it is somethings a lot easier to be able to define a local file repository in CentOS or Red Hat systems to ensure that you can easily install software at a later date without access to the internet or DVD. In this first lesson we look at creating a local yum repository and then in a later lesson we will share that out with HTTP to make it available to other hosts.

  • Create the directory structure to support the repo. We will create a top level directory names /repo and then a sub directory names rhel64x86 for the 32 bit version we are using. we can add a 64 bit directory to support those clients running 64 bit systems : mkdir -p /repo/rhel64x86
  • On CentOS 6 we copy the dvd:/Packages directory on CentOS 5 we would copy the dvd:/CentOS directory: rsync -av /mnt/Packages/*.rpm /repo/rehel64x86/
  • While you still have another repo available install the createrepo package: yum install -y createrepo
  • Move into the /repo/rehel64x86/ and create the repository metadata: createrepo . [dot being the current directory]
  • Remove the current repos : rm -f /etc/yum.repo.d/*
  • Create a new repo file[rhel6.3-local]

    name=RHEL 6.4 local repository

    baseurl=file:///repo/rhel64x86

    gpgcheck=0

    enabled=1

  • Now we can clear the yum cache and list the new repo: yum clean all ; yum repolist

Watch the video for more: