Introduction

CentOS 7 というサポート切れして久しい OS であがくお話し。
サポートが 2024/06/30 に終了し、 yum での接続先標準リポジトリも非アクティブになってしまっている。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
$ sudo yum update
Determining fastest mirrors
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"


One of the configured repositories failed (Unknown),
and yum doesn't have enough cached data to continue. At this point the only
safe thing yum can do is fail. There are a few ways to work "fix" this:

1. Contact the upstream for the repository and get them to fix the problem.

2. Reconfigure the baseurl/etc. for the repository, to point to a working
upstream. This is most often useful if you are using a newer
distribution release than is supported by the repository (and the
packages for the previous distribution release still work).

3. Run the command with the repository temporarily disabled
yum --disablerepo=<repoid> ...

4. Disable the repository permanently, so yum won't use it by default. Yum
will then just ignore the repository until you permanently enable it
again or use --enablerepo for temporary usage:

yum-config-manager --disable <repoid>
or
subscription-manager repos --disable=<repoid>

5. Configure the failing repository to be skipped, if it is unavailable.
Note that yum will try to contact the repo. when it runs most commands,
so will have to try and fail each time (and thus. yum will be be much
slower). If it is a very temporary problem though, this is often a nice
compromise:

yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true

Cannot find a valid baseurl for repo: base/7/x86_64

カーネルを更新したい。
現状は下記。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
$ uname -r
3.10.0-957.el7.x86_64

$ cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

どうする?

How to resolve?

1. value リポジトリへの切り替え

公式のミラーサイト http://mirror.centos.org からアーカイブの vault リポジトリ である http://vault.centos.org に切り替える。

1
2
sudo sed -i 's|mirrorlist=|#mirrorlist=|g' /etc/yum.repos.d/CentOS-*.repo
sudo sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*.repo

切り替え後、すべてのキャッシュデータを削除し、yum リポジトリデータをキャッシュにダウンロードします。

1
2
sudo yum clean all
sudo yum makecache

これで yum が使えるので、 wget 等必要なものをインストール。

2. RPM ダウンロード

ただし、公式のアーカイブとは言え、カーネルはアーカイブには古いものしか存在しない。

1
2
3
4
$ rpm -qa | grep "^kernel"
kernel-tools-libs-3.10.0-957.el7.x86_64
kernel-3.10.0-957.el7.x86_64
kernel-tools-3.10.0-957.el7.x86_64

そこで、他のミラーサイトから必要なパッケージをダウンロードしてくる。
Debian の公式サイトでも紹介されている、イギリスのミラーサイト mirrors.coreix.net を使用する。

1
2
3
$ cd /tmp
$ wget http://mirrors.coreix.net/elrepo-archive-archive/kernel/el7/x86_64/RPMS/kernel-lt-5.4.278-1.el7.elrepo.x86_64.rpm
$ wget http://mirrors.coreix.net/elrepo-archive-archive/kernel/el7/x86_64/RPMS/kernel-lt-devel-5.4.278-1.el7.elrepo.x86_64.rpm

3. インストール

1
$ sudo yum localinstall -y kernel-lt-5.4.278-1.el7.elrepo.x86_64.rpm kernel-lt-devel-5.4.278-1.el7.elrepo.x86_64.rpm

4. grub の更新

1
2
3
sudo grub2-set-default 0
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
sudo reboot

5. 起動後

1
2
$ uname -r
5.4.278-1.el7.elrepo.x86_64