LoginSignup
0
1

More than 5 years have passed since last update.

vagrant導入でひっかかったこと

Last updated at Posted at 2017-03-23

本当にしょうもないことだったのですが、忘れてまたやりそうな自分のためのメモです。

参考

こちらの記事を読みながら進めさせていただきました。
(筆者が見落としてたせいでひっかかったので、こちらの記事通りに進めれば問題ないです!)

結論

実行ユーザーをvboxusersグループに追加するの忘れてました…。

環境

% cat /etc/redhat-release
CentOS release 6.8 (Final)

% arch
x86_64

% cat /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 44
model name      : Intel(R) Xeon(R) CPU           X5680  @ 3.33GHz
stepping        : 2
microcode       : 16
cpu MHz         : 3324.999
cache size      : 12288 KB
physical id     : 0
siblings        : 1
core id         : 0
cpu cores       : 1
apicid          : 0
initial apicid  : 0
fpu             : yes
fpu_exception   : yes
cpuid level     : 11
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss syscall nx rdtscp lm constant_tsc up arch_perfmon pebs bts xtopology tsc_reliable nonstop_tsc aperfmperf unfair_spinlock pni pclmulqdq ssse3 cx16 sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes hypervisor lahf_lm ida arat dtherm
bogomips        : 6649.99
clflush size    : 64
cache_alignment : 64
address sizes   : 42 bits physical, 48 bits virtual
power management:

残念ながらvmxの文字は見つからないので64bitOSは動かないそうです…。

参考:VT-x is not available vagrant

手順

DKMSをインストール

# リポジトリの追加
% sudo rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# パッケージ概要を確認
% yum info dkms
# インストール
% sudo yum install dkms

VirtualBoxのインストール

# リポジトリの追加
% cd /etc/yum.repos.d/
% sudo wget http://download.virtualbox.org/virtualbox/rpm/rhel/virtualbox.repo
# 一回確認が出るのでフルでリストを出す
% sudo yum list
# VirtualBoxがあることを確認
% sudo yum list | grep VirtualBox
# インストール(2017/3/16時点の最新バージョン)
% sudo yum install VirtualBox-5.1

実行ユーザーをvboxusersグループに追加

% sudo usermod -a -G vboxusers ユーザー名

vagrantのインストール

# インストール(2017/3/16時点の最新バージョン)
% sudo rpm -Uvh https://releases.hashicorp.com/vagrant/1.9.2/vagrant_1.9.2_x86_64.rpm

vagrantの設定

CentOSのboxを拾ってきて初期化します。
Vagrantfileを編集してcpu数を1個にします。
※2個以上だと重くなったりするとかなんとか…。

% vagrant init bento/centos-6.7-i386
% vi Vagrantfile
Vagrantfile
config.vm.provider "virtualbox" do |vb|
  vb.cpus = 1
end

起動します。

% vagrant up

気付くまでに時間がかかった理由(言い訳)

vagrant upした後、そのままtimeoutになります。
特にそれっぽいmessageも吐いてくれないので、なんだろうなぁと思いながら週末を迎えました。

気付いた理由

週明けで気分が変わってからもう一回さらっと手順を見直したらやってなかったことに気づきました。
悩むより次の日の自分に任せましょう(教訓)

追記

仮想マシン作成時に環境によってはこんなエラーが出ます。

VirtualBox is complaining that the kernel module is not loaded. Please
run `VBoxManage --version` or open the VirtualBox GUI to see the error
message which should contain instructions on how to fix this error.

言われたとおりにコマンドを実行します。

% VBoxManage --version
WARNING: The vboxdrv kernel module is not loaded. Either there is no module
         available for the current kernel (2.6.32-642.6.1.el6.x86_64) or it failed to
         load. Please recompile the kernel module and install it by

           sudo /sbin/vboxconfig

         You will not be able to start VMs until this problem is fixed.
5.1.18r114002

再度言われたとおりにコマンドを実行します。

% sudo /sbin/vboxconfig
vboxdrv.sh: Stopping VirtualBox services.
vboxdrv.sh: Building VirtualBox kernel modules.
This system is not currently set up to build kernel modules (system extensions).
Running the following commands should set the system up correctly:

  yum install kernel-devel-2.6.32-642.6.1.el6.x86_64
(The last command may fail if your system is not fully updated.)
  yum install kernel-devel
vboxdrv.sh: failed: Look at /var/log/vbox-install.log to find out what went wrong.
This system is not currently set up to build kernel modules (system extensions).
Running the following commands should set the system up correctly:

  yum install kernel-devel-2.6.32-642.6.1.el6.x86_64
(The last command may fail if your system is not fully updated.)
  yum install kernel-devel

There were problems setting up VirtualBox.  To re-start the set-up process, run
  /sbin/vboxconfig
as root.
vboxdrv.sh: Starting VirtualBox services.
vboxdrv.sh: Building VirtualBox kernel modules.
This system is not currently set up to build kernel modules (system extensions).
Running the following commands should set the system up correctly:

  yum install kernel-devel-2.6.32-642.6.1.el6.x86_64
(The last command may fail if your system is not fully updated.)
  yum install kernel-devel
vboxdrv.sh: failed: Look at /var/log/vbox-install.log to find out what went wrong.

何やらkernel moduleが足りないと言っているのでその通りにインストールします。

% sudo yum install -y kernel-devel-2.6.32-642.6.1.el6.x86_64

kernel moduleをビルドします。

% sudo /sbin/vboxconfig
vboxdrv.sh: Stopping VirtualBox services.
vboxdrv.sh: Building VirtualBox kernel modules.
vboxdrv.sh: Starting VirtualBox services.
vboxdrv.sh: Starting VirtualBox services.

もう一回仮想マシンを作成すると通るはずです!

0
1
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
1