Windows10にVagrantとVirtualBoxでCentOSの仮想環境を構築⑧VirtualBox Guest Additionsのインストール
php artisan make:migrationして作成したファイルが(Vagrantで共通フォルダに保存したはずのファイルが)ホストOSに現れない。
そういえば前からこんなのが出ていた。
default: No guest additions were detected on the base box for this VM! Guest
default: additions are required for forwarded ports, shared folders, host only
default: networking, and more. If SSH fails on this machine, please install
default: the guest additions and repackage the box to continue.
Guest Additionsとやらがインストールされていないせいらしい。
vagrant内でホスト・ゲスト間の共有フォルダを作りたい場合、VirtualBoxのGuest Additionsを使う必要があるらしい。
https://qiita.com/esehara@github/items/bab70b195567fddf3384
■Guest Additionsとは
VirtualBox Guest AdditionsはゲストOSにインストールすることで、ホストOSとゲストOS間のより緊密な統合を行い、VirtualBoxの使い勝手を向上させます。
Guest Additionsをインストールすることで提供される機能は以下のとおりです。
■Guest Additionsのインストール
https://qiita.com/sudachi808/items/edc304b3ee6c1436b0fd
上記の通りに実行。
1.@localhost $ yum update kernel -y
2.@localhost $ yum install kernel-devel gcc -y
3.@localhost exit
4.vagrant halt
5.VirtualBoxマネージャの該当マシンの「設定」→「ストレージ」→「+ボタン」→光学ドライブをコントローラIDEに追加する」→「空のままにする」
7.VirtualBoxマネージャで該当マシンの「表示」→メニューバーの「デバイス」→「Guest Additionsを挿入」
8.ディスクイメージをマウントする(?)
@localhost $ mkdir /mnt/cdrom
@localhost $ mount /dev/cdrom /mnt/cdrom
@localhost $ sudo ls /mnt/cdrom →結果確認
9.Guest Addtionsのインストール
①カーネルの場所を確認
sudo ls /usr/src/kernels/
export KERN_DIR=/usr/src/kernels/[①で調べた通り]
③Guest Addtionsのインストール
sudo /mnt/cdrom/VBoxLinuxAdditions.run
→VirtualBox Guest Additions: Look at /var/log/vboxadd-setup.log to find out what
went wrongって出たけど、中身はCould not find the X.Org or XFree86 Window System, skipping.だったので無視する。
※sudo catしても同じメッセージ「Could not find the X.Org or XFree86 Window System, skipping.」が出て見れないので$ sudo vi vboxadd-setup.logで確認。
10.共有フォルダ設定
①vagrant halt
②Vagrantfileを編集
config.vm.synced_folder ".", "/vagrant", type:"virtualbox"
③vagrant up
マイグレーションファイル保存できた!
リアルタイム同期もされている!