helen's blog

ずっとおもしろいことしてたいな。

vagrant vbguestはもう打ちたくなかったんだ

Versions

vagrantでsynced_folderしたくてvbguestを入れたはずなのに
reloadするとまた

# 抜粋
Failed to mount folders in Linux guest. This is usually because
the "vboxsf" file system is not available. Please verify that
the guest additions are properly installed in the guest and
can work properly. The command attempted was:

mount -t vboxsf -o uid=`id -u vagrant`,gid=`getent group vagrant | cut -d: -f3` vagrant /vagrant
mount -t vboxsf -o uid=`id -u vagrant`,gid=`id -g vagrant` vagrant /vagrant

The error output from the last command was:

mount: unknown filesystem type 'vboxsf'

が出るを何度も繰り返して発狂しそうでした

起動ログを見るとguest additionsが入ってないって言われている

# 抜粋
==> boxName: Machine booted and ready!
==> boxName: Checking for guest additions in VM...
    boxName: No guest additions were detected on the base box for this VM! Guest
    boxName: additions are required for forwarded ports, shared folders, host only
    boxName: networking, and more. If SSH fails on this machine, please install
    boxName: the guest additions and repackage the box to continue.
    boxName:
    boxName: This is not an error message; everything may continue to work properly,
    boxName: in which case you may ignore this message.

どうやらcentos/7はデフォルトでGuestAdditionsが入っていないようだ
なんでだろう🤔

普段vagrantコマンドでしか操作しなくてGUIに戸惑ったのでログ残します

GuestAdditionインストール

対象のisoイメージを探す

Index of http://download.virtualbox.org/virtualbox から自分のバージョンのものを探して
GuestAddition.isoをダウンロード

対象のBoxにボリュームを追加してドライブとして選択

f:id:heleeen:20180713183810p:plain

GUIからVMを起動して諸々のバージョンを合わせる

合ってないとのちのち悲しい気持ちになります

$ sudo su -
# yum update -y
# reboot

## login

# yum install gcc kernel-devel kernel-header

# reboot

## ここで↓2つのバージョンが一致することを確認しておく
# uname -r
# yum list installed | grep kernel

あとはイメージをマウントしてrunして
できたイメージをpackageしてaddしちゃえばもう困ることはないね!

Appendix

but compiler support broken.
arch/x86/Makef i le:96: stack-protector enabled but compiler support broken arch/x86/Makef ile : 166: *** CONFIG RETPOLINE=y, but not supported by the compiler . Compiler update recommended.. Stop. make: *** [vboxguest] 
Error 2 Creating user for the Guest Additions, Creating udev rule for the Guest Additions kernel module.

gccをインストールする

unable to find the sources of Linux kernel.
Creating user for the Guest Additions. 
Creating udev rule for the Guest Additions kernel module. 
tmp/vbox.O/Makefile.include .header:97: *** 
Error: unable to find the sources of your current Linux kernel. 
Specify KERN_DIR=<directory> and run Make again.

kernelのライブラリとカーネルのバージョンが一致してなかった

めも

ちなみにvbguestしたときのログでも若干怪しいことは言われてました

$ vagrant vbguest

...

Complete!
Copy iso file /Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso into the box /tmp/VBoxGuestAdditions.iso
Mounting Virtualbox Guest Additions ISO to: /mnt
mount: /dev/loop0 is write-protected, mounting read-only
Installing Virtualbox Guest Additions 4.3.40 - guest version is unknown
Verifying archive integrity... All good.
Uncompressing VirtualBox 4.3.40 Guest Additions for Linux............
VirtualBox Guest Additions installer
Copying additional installer modules ...
Installing additional modules ...
Removing existing VirtualBox non-DKMS kernel modules[  OK  ]
Building the VirtualBox Guest Additions kernel modules

調べるととりあえずvbguestすればいいって出てくるけど根本解決にはならないみたい