Offline and Online Yum Repository Configuration for CentOS 6.7
Offline Local Yum Repository Setup
-
Prepare ISO Storage and Mount Points
mkdir -p /app/centos-iso-mount mkdir -p /data/iso-filesUpload the
CentOS-6.7-x86_64-bin-DVD1.isofile to/data/iso-files. -
Mount the ISO Image
mount -o loop /data/iso-files/CentOS-6.7-x86_64-bin-DVD1.iso /app/centos-iso-mount -
Adjust Yum Repository Configuration Files Navigate to the yum configuration directory and disable network-based repos by renaming them:
cd /etc/yum.repos.d/ mv CentOS-Base.repo CentOS-Base.repo.offline mv CentOS-Vault.repo CentOS-Vault.repo.offline mv CentOS-Debuginfo.repo CentOS-Debuginfo.repo.offline -
Create or Edit Local Media Repo Open
CentOS-Local-Media.repowith a text editor and add the following content:[c6-local] name=CentOS-$releasever - Local ISO baseurl=file:///app/centos-iso-mount/ gpgcheck=0 enabled=1 -
Clear Yum Cache and Test Installation
yum clean all yum install -y git -
Enable Persistent ISO Mount on Boot Add the mount command to
/etc/rc.d/rc.local:echo 'mount -o loop /data/iso-files/CentOS-6.7-x86_64-bin-DVD1.iso /app/centos-iso-mount' >> /etc/rc.d/rc.local chmod +x /etc/rc.d/rc.local
Online Vault-Based Yum Repository Setup
CentOS 6 reached end-of-life in November 2020, so standard public mirrors no longer serve updates. The Alibaba Cloud vault provides archvied packages. Follow these steps:
-
Disable Fastest Mirror Plugin
sed -i 's|enabled=1|enabled=0|g' /etc/yum/pluginconf.d/fastestmirror.conf -
Backup Existing Base Repo
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup -
Download and Apply Vault Repo File
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-6-vault.repo -
Clear and Rebuild Yum Cache
yum clean all yum makecache
Manual Vault Repo File Content
If the curl command fails, create /etc/yum.repos.d/CentOS-Base.repo manually with:
[base]
name=CentOS-6.10 - Base - Aliyun Vault
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos-vault/6.10/os/$basearch/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6
[updates]
name=CentOS-6.10 - Updates - Aliyun Vault
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos-vault/6.10/updates/$basearch/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6
[extras]
name=CentOS-6.10 - Extras - Aliyun Vault
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos-vault/6.10/extras/$basearch/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6
[centosplus]
name=CentOS-6.10 - Plus - Aliyun Vault
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos-vault/6.10/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6
[contrib]
name=CentOS-6.10 - Contrib - Aliyun Vault
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos-vault/6.10/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6