Home > Articles > Operating Systems, Server > Linux/UNIX/Open Source

Setting Up a yum Repository

  • Print
  • + Share This
While there are many Linux users who prefer other tools for doing their patch management, yum is designed for RPM-based distributions. Its popularity has grown as Fedora Linux has adapted yum as its primary patch management tool. This chapter will help you set up and configure a yum repository for your Linux distribution.
This chapter is from the book

As discussed in Chapter 6, "Configuring a yum Client," yum is built on the Python programming language, which is a building block for the Red Hat/Fedora distributions. While current support is limited to the Red Hat/Fedora/Yellow Dog/Mandriva/Asp distributions, per the latest available Netcraft survey (http://news.netcraft.com/archives/2005/03/index.html), that’s over half the Linux market. If you want to learn patch management for Linux, you need to know how to use yum and configure, or "yummify," associated repositories.

The simplest way to configure a yum repository is to mirror one that already exists. Most Fedora repositories already support yum. But you do not have to mirror the entire repository, because much of it is built from installation CDs. In addition, as packages change, or if you combine packages from different mirrors, you may prefer to create yum headers on your own system rather than download them from a remote mirror.

We’ve divided this chapter into several major sections. You can take most of the packages for a repository from the installation CDs. You’ll need to manage headers for those repositories. You’ll need to configure sharing of that repository with other computers on your network. You’ll need to download other repositories associated with updates, developmental packages, and those created by third parties. Finally, you’ll need to keep these repositories up to date.

When configured, you’ll be able to update your computers from local repositories, minimizing the loads on your Internet connections, giving you more control over what is installed on your systems. You can focus on making sure that critical packages, including those related to security, are up to date. That is the essence of good patch management.

At the end of this chapter, we’ll show you how you can create a yum repository for Red Hat Enterprise Linux (RHEL) 4 clients with an authorized subscription to the Red Hat Network. If you have valid subscriptions, this is a viable alternative to the Red Hat Network Proxy Server described in Chapter 2, "Consolidating Patches on a Red Hat/Fedora Network."

7.1 Getting the Packages

You already have many of the packages that you’ll want in a yum repository: the same RPMs that are already included with the installation CDs/DVDs for your distribution. With those RPMs, you can use yum to populate the base repository and add the headers needed for easy access from the other computers on your network.

In this part of the chapter, we’ll show you how to start your repository, install yum, create an appropriate yum directory tree, add headers to the appropriate directory, and test the base repository on your local system. We’ll start with the Fedora Core 4 Updates repository. When you see how it’s done, you can use the same techniques to create other repositories on your system.

While you could use the rsync command described in earlier chapters to mirror an entire repository, each version of Fedora requires well over 10GB of space. You do not need to mirror the directory with the 6GB+ of ISO files. As described earlier in this book, there are ways to cut that down with appropriate --exclude switches to the rsync command. But if the loads on your Internet connection are not a problem, you might not need a local patch management repository in the first place.

7.1.1 Strategy

Before you create your repository, decide what you want to store locally. Viable options vary. If you have only two or three workstations, a local repository might not be so important. However, it can become profitable to configure a local repository if you have a substantial number of workstations. What you configure locally depends on your patch management strategy. Consider the following:

  • To keep a substantial number of computers up to date, it can help to configure a local repository for updates. Alternatively, if your Internet bandwidth is unlimited, and the people behind your remote mirror do not object to the load, you may prefer to use remote mirrors, as they may be more up to date.
  • If you frequently change the base software on your systems, you should load the installation RPMs on your repository.
  • If you need packages outside the standards available on the installation CDs, look for other directories of RPMs on your favorite mirror. For example, Fedora includes the Extras repository with many useful packages.
  • If you need packages simply unavailable from mirrors associated with your distribution, there are also third-party repositories described throughout this book.
  • If your users test updates before they’re moved to the stable update repository, consider mirroring such repositories. You may even have reason to mirror a development repository. However, be warned that these packages are generally not stable or suitable for a production environment.

After you decide what you’re going to mirror, you can set up a yum directory tree for your local repository. In the following sections, we’ll focus on creating an Updates repository. If you have the installation CD available, you can use the same steps to create an Installation repository.

In my case, I’ve created a Fedora Core 4 repository on a system running RHEL 4, as it is a fairly stable distribution. You’ll want to leave room for future releases of Fedora Core. It might even make sense to add a new hard drive for that purpose so that the packages won’t overwhelm other files on your system. In any case, it’s an excellent idea to at least configure a separate partition for your repository.

7.1.2 Creating a yum Directory Tree

We’re assuming that you’re ready to create your own yum repository directory tree for your own network and that the tree does not have to be identical to the one on your favorite mirror. For example, assume that you’ve created the /var/ftp/pub/yum directory in a separate partition. Assume that for now, all you need to provide for are standard 32-bit systems. If you wanted to create a yum directory tree for Fedora Core 4, you might end up with the following directories:

/var/ftp/pub/yum/4/i386/os
/var/ftp/pub/yum/4/i386/updates
/var/ftp/pub/yum/4/i386/extras
/var/ftp/pub/yum/4/i386/dag

The /var/ftp/pub directory is the default directory associated with the vsFTP server. It happens to be the default FTP server for Fedora and Red Hat distributions. With the right settings, you can link to this directory from an Apache Web server. You can also share this directory on the local network using NFS. In fact, NFS is generally preferred on a network of Linux computers because shared NFS directories can be treated as if they were on the local computer.

As the noted directories are several levels below /var/ftp/pub, you might feel like you’ll have to run the mkdir command a thousand times. There is one minor trick that can speed the process. The following command creates all needed subdirectories in one shot:

mkdir -p /var/ftp/pub/yum/4/i386/os

Note that the structure of these directories does not correspond to those you see in current Fedora Core mirrors. The directory structure of different Fedora Core mirrors varies. Unless you’re creating a mirror for public use, there is no need to create a directory structure similar to any existing Fedora Core mirror.

7.1.3 Start with a Distribution

For the purpose of this chapter, I’ve downloaded the Fedora Core 4 installation DVD, to create repositories for Fedora Core 4 systems. As noted earlier, it’ll be on a RHEL 4 computer so that I can add repositories for future releases of Fedora Core. As RHEL 4 was developed in large part from Fedora Core 3, I’ll be using Fedora-based yum packages. Naturally, the following instructions will also work for a repository configured on Fedora Core 3.

For example, if you’ve download the Fedora Core DVD, you can mount the ISO file almost as if it were a DVD/CD with the following command:

mount -o loop FC4-i386-DVD.iso /media/cdrecorder

Of course, you can "burn" the DVD .iso file (or associated CD .iso files) to appropriate media. It may be handy to have a DVD available. But, in my opinion, because you can mount the ISO directly, you don’t need a physical DVD.

A quick look at other mirrors confirms that the contents of the Fedora Core DVD are part of the os/ repository directory. You can make it part of your own local repository, by copying the contents of the DVD to the corresponding directory described earlier:

cp -ar /media/cdrecorder/* /var/ftp/pub/yum/4/i386/os/

7.1.4 Installing yum

For Fedora Core 3 and above, you’ll need at least the yum and createrepo RPMs, along with the packages associated with the way you plan to share your repository on your network (FTP, Apache, or NFS server). Earlier versions of Fedora Core did not include a createrepo RPM; if you want to create a repository from Fedora Core 1 or 2, use the yum-arch command, which is part of the yum RPM and is functionally similar to createrepo.

When the appropriate CD or DVD is mounted, you can then install the Fedora Core 3 yum and createrepo RPMs with the following commands:

rpm -Uvh /media/cdrecorder/Fedora/RPMS/yum*
rpm -Uvh /media/cdrecorder/Fedora/RPMS/createrepo*

If you’re working with a RHEL 4 rebuild distribution, such as CentOS-4, the appropriate yum packages may already be installed on your system. The actual directory with these packages may vary; for example, the CentOS-4 version of the createrepo RPM is part of the CentOS-4 addons/ repository directory.

If you’re working with RHEL 4, you can install the yum and createrepo RPMs from Fedora Core 3. If you don’t have the associated installation media, you can download the RPMs directly from your favorite mirror from among those listed at http://fedora.redhat.com/download/mirrors.html.

7.1.5 Synchronizing Updates

More important than the installation RPMs are the updates. While you can use tools, such as system-config-packages, to install and remove Fedora packages from the installation files, you need access to the updates to manage patches on your system. Based on the directories described earlier, we’re planning to store RPMs from the Fedora Core 4 Updates repository on the following directory:

/var/ftp/pub/yum/4/i386/updates

Based on the rsync commands described in Chapter 2, you should find an Updates repository in the rsync mirror of your choice. Fedora rsync mirrors are listed at http://fedora.redhat.com/download/mirrors.html. One rsync mirror that I use is rsync://mirrors.kernel.org/fedora/core.

You can list the directories and files on a remote rsync server. Just make sure to include the last forward slash in your command. For example, the following command lists the directories available in the Kernel.org Fedora Core repository:

rsync rsync://mirrors.kernel.org/fedora/core/ 

You’ll see updates/ in the directory tree. As you continue this process, you’ll find the actual updates/ RPMs in the updates/4/i386/ subdirectory.

Search through the subdirectory. You’ll find debug/ and repodata/ subdirectories. While you may be able to use the data in the repodata/ subdirectory in your own yum repository, you don’t need to download the hundreds of megabytes of files in the debug/ subdirectory. To avoid downloading files from that directory, you’ll need to apply the --exclude switch. For example, the following rsync command synchronizes the packages from the remote updates/ repository, without debug/ packages:

As noted in Chapter 3, this synchronizes the noted remote and local directories in (-a) archive mode, with (-v) verbose output. Contents from the debug directory are (--exclude) excluded.

  • + Share This
  • 🔖 Save To Your Account

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020