0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

VagrantでGuest Additionsアップデート時にYumRepo Errorが出る

Posted at

はじめに

Vagrant で CentOS 6.5 の環境構築を行った際に少し苦労したのでその備忘録です。
メモ書き殴り形式になっているのであくまでもチラシの裏だと思って読んでください。

Guest Additionsのアップデート

Vagrantを立ち上げ(vagrant up)すると、GuestAdditionsが原因のエラーメッセージが出る

[default] GuestAdditions versions on your host (7.0.14) and guest (5.2.26) do not match.

VirtualBoxのバージョンアップが結構頻繁に行われるので、boxのGuest AdditionsのバージョンとVirtualBox本体のバージョンがずれてしまうらしい。

そこでVagrantには vagrant-vbguest というプラグインがあり、自動的にゲストOSにGuestAdditionsをインストールしてくれる仕組みがある。

vagrant-vbguestを利用してGuest Additionsの自動バージョンアップを行う

Vagrantを立ち上げた状態で(vagrant up時)
以下のコマンドを入力し、virtual boxのGuest Additionsをアップデートする
(初回一度のみでおk)

$ vagrant plugin install vagrant-vbguest
$ vagrant vbguest

本来はこれで無事にGuest Additionsがアップデートされるはずなのだが…
ここで別のエラーが発生!

Error: Cannot find a valid baseurl for repo: base

CentOS側でYumRepo Errorが発生する

CentOSのサポートが切れるとyumコマンドが失敗するらしい。
CentOS 6 系 は 2020年11月30日にサポートが終了されたため、Yum リポジトリのデフォルトの設定が使えなくなってしまったというのが原因。
ということで、こちらの記事を参考にしてYumリポジトリの設定を変更してみる。

Yumリポジトリの設定は、/etc/yum.repos.d/ 配下の CentOS-Base.repo というファイルに記述されているので、これを修正する。

$ vi /etc/yum.repos.d/CentOS-Base.repo

[base] に書かれたデータ取得先 URL が使用できないので、
mirrorlist= の行を # でコメントアウトし、
新たに baseurl= の行を追加して適切な URL を記述する。

先に言っておくと、このURLでこの後ハマった
(最後まで読んでからURLを書き換えてほしい)

CentOS-Base.repo
[base]
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra  ←★コメントアウトする
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
baseurl=http://vault.centos.org/centos/$releasever/os/$basearch/

[base] ブロック以外にも [updates] 、[extras]、[centosplus]、[contrib] のブロックがあるので同様に書き換えます。

修正が終わったら、vagrant reloadで仮想マシンを再起動
これでvagrant-vbguestがうまく動くはず…

ところが、[default] GuestAdditions versions ~ のあと応答なしで固まってしまう状態に…

YumリポジトリのURLが違う

こちらの記事に記載されているURLで解決した。

baseurl=http://vault.centos.org/centos/$releasever/os/$basearch/

baseurl=http://vault.centos.org/6.10/os/$basearch/

追加した行の数字部分はCentOSのバージョンにあわせて書き換えてください。
https://vault.centos.org/6.5/os/Source/ ←こんな感じ

URLがちょっと違うとかわからんがな…

まとめ

Guest Additionsのアップデートするだけで2日間も費やしてしまいました。
環境構築って難しいね…

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?