Create a gist now

Instantly share code, notes, and snippets.

Workaround for CentOS kernel-devel "No package available" error
IMPORTANT: First, check your CentOS version:
cat /etc/redhat-release
Then choose one of the sections below.
============================
Steps for CentOS 6.x ONLY
============================
# Older versions of the kernel-devel package are kept in the CentOS Vault.
# We need to temporarily add this repository.
repo_url=https://gist.githubusercontent.com/hwdsl2/81ef6f0315ac24ea55d4/raw/CentOS-6-Vault.repo
wget -t 3 -T 30 -O /etc/yum.repos.d/CentOS-6-Vault.repo $repo_url
# Next, install the kernel-devel package:
yum --enablerepo=C6.7-base --enablerepo=C6.7-updates \
--enablerepo=C6.6-base --enablerepo=C6.6-updates \
--enablerepo=C6.5-base --enablerepo=C6.5-updates \
--enablerepo=C6.4-base --enablerepo=C6.4-updates \
--enablerepo=C6.3-base --enablerepo=C6.3-updates \
--enablerepo=C6.2-base --enablerepo=C6.2-updates \
--enablerepo=C6.1-base --enablerepo=C6.1-updates \
--enablerepo=C6.0-base --enablerepo=C6.0-updates \
install kernel-devel-$(uname -r)
# Remove the temporary repository we just added:
rm -f /etc/yum.repos.d/CentOS-6-Vault.repo
============================
Steps for CentOS 7.x ONLY
============================
# Older versions of the kernel-devel package are kept in the CentOS Vault.
# We need to temporarily add this repository.
repo_url=https://gist.githubusercontent.com/hwdsl2/81ef6f0315ac24ea55d4/raw/CentOS-7-Vault.repo
wget -t 3 -T 30 -O /etc/yum.repos.d/CentOS-7-Vault.repo $repo_url
# Next, install the kernel-devel package:
yum --enablerepo=C7.2.1511-base --enablerepo=C7.2.1511-updates \
--enablerepo=C7.1.1503-base --enablerepo=C7.1.1503-updates \
--enablerepo=C7.0.1406-base --enablerepo=C7.0.1406-updates \
install kernel-devel-$(uname -r)
# Remove the temporary repository we just added:
rm -f /etc/yum.repos.d/CentOS-7-Vault.repo
[C6.7-base]
name=CentOS-6.7 - Base
baseurl=http://vault.centos.org/6.7/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=0
[C6.7-updates]
name=CentOS-6.7 - Updates
baseurl=http://vault.centos.org/6.7/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=0
[C6.6-base]
name=CentOS-6.6 - Base
baseurl=http://vault.centos.org/6.6/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=0
[C6.6-updates]
name=CentOS-6.6 - Updates
baseurl=http://vault.centos.org/6.6/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=0
[C6.5-base]
name=CentOS-6.5 - Base
baseurl=http://vault.centos.org/6.5/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=0
[C6.5-updates]
name=CentOS-6.5 - Updates
baseurl=http://vault.centos.org/6.5/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=0
[C6.4-base]
name=CentOS-6.4 - Base
baseurl=http://vault.centos.org/6.4/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=0
[C6.4-updates]
name=CentOS-6.4 - Updates
baseurl=http://vault.centos.org/6.4/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=0
[C6.3-base]
name=CentOS-6.3 - Base
baseurl=http://vault.centos.org/6.3/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=0
[C6.3-updates]
name=CentOS-6.3 - Updates
baseurl=http://vault.centos.org/6.3/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=0
[C6.2-base]
name=CentOS-6.2 - Base
baseurl=http://vault.centos.org/6.2/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=0
[C6.2-updates]
name=CentOS-6.2 - Updates
baseurl=http://vault.centos.org/6.2/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=0
[C6.1-base]
name=CentOS-6.1 - Base
baseurl=http://vault.centos.org/6.1/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=0
[C6.1-updates]
name=CentOS-6.1 - Updates
baseurl=http://vault.centos.org/6.1/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=0
[C6.0-base]
name=CentOS-6.0 - Base
baseurl=http://vault.centos.org/6.0/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=0
[C6.0-updates]
name=CentOS-6.0 - Updates
baseurl=http://vault.centos.org/6.0/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=0
# CentOS Vault contains rpms from older releases in the CentOS-7
# tree.
[C7.2.1511-base]
name=CentOS-7.2.1511 - Base
baseurl=http://vault.centos.org/7.2.1511/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
enabled=0
[C7.2.1511-updates]
name=CentOS-7.2.1511 - Updates
baseurl=http://vault.centos.org/7.2.1511/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
enabled=0
[C7.1.1503-base]
name=CentOS-7.1.1503 - Base
baseurl=http://vault.centos.org/7.1.1503/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
enabled=0
[C7.1.1503-updates]
name=CentOS-7.1.1503 - Updates
baseurl=http://vault.centos.org/7.1.1503/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
enabled=0
[C7.0.1406-base]
name=CentOS-7.0.1406 - Base
baseurl=http://vault.centos.org/7.0.1406/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
enabled=0
[C7.0.1406-updates]
name=CentOS-7.0.1406 - Updates
baseurl=http://vault.centos.org/7.0.1406/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
enabled=0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment