How to use centos 6.8 with vagrant and Parallels

[vagrant](https://www.vagrantup.com) + [Parallels](http://trial.parallels.com/) で centos 6.8 をインストールしました。
トラブったので、以下メモします。

# 通常手順……？
まず環境変数を設定しました。 

```sh
export VAGRANT_DEFAULT_PROVIDER=parallels
```

[Oracle VM VirtualBox](https://www.virtualbox.org) もイイですけど、やっぱりお金を払った以上はそっちを使いたいものじゃないですか (^^;;;


それから vagrant を初期化しました。

```
% vagrant init bento/centos-6.8
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.
```

作成された `Vagrantfile` に以下のように追加すると、いい感じでゲスト・ツールをインストールしてくれます。

```rb
  #   apt-get install -y apache2
  # SHELL

  # ここから
  config.vm.provider "parallels" do |v|
    v.update_guest_tools = true
  end
  # ここまで
end
```

そのハズだったのですが……。

```sh
% vagrant up
WARNING: Nokogiri was built against LibXML version 2.9.0, but has dynamically loaded 2.9.2
Bringing machine 'default' up with 'parallels' provider...
==> default: Registering VM image from the base box 'bento/centos-6.8'...
==> default: Cloning new virtual machine...
==> default: Unregistering the box VM image...
==> default: Setting the default configuration for VM...
==> default: Checking if box 'bento/centos-6.8' is up to date...
==> default: Setting the name of the VM: work_default_1491476480420_66534
==> default: Preparing network interfaces based on configuration...
    default: Adapter 0: shared
==> default: Clearing any previously set network interfaces...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 10.211.55.4:22
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Connection refused. Retrying...
    default:
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default:
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for Parallels Tools installed on the VM...
==> default: Parallels Tools installed on this VM are outdated! In most cases
==> default: this is fine but in rare cases it can cause things such as shared
==> default: folders to not work properly. If you see shared folder errors,
==> default: please update Parallels Tools within the virtual machine and
==> default: reload your VM.
==> default: Installing the proper version of Parallels Tools. This may take a few minutes...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

ptiagent-cmd --install

Stdout from the command:

Started installation of Parallels Guest Tools version '12.2.0.41591'
Loaded plugins: fastestmirror
Setting up Install Process
Determining fastest mirrors
 * base: ftp.riken.jp
 * extras: ftp.riken.jp
 * updates: ftp.riken.jp
No package kernel-devel-2.6.32-642.el6.x86_64 available.
Resolving Dependencies
--> Running transaction check
---> Package gcc.x86_64 0:4.4.7-18.el6 will be installed
--> Processing Dependency: libgomp = 4.4.7-18.el6 for package: gcc-4.4.7-18.el6.x86_64
--> Processing Dependency: cpp = 4.4.7-18.el6 for package: gcc-4.4.7-18.el6.x86_64
--> Processing Dependency: libgcc >= 4.4.7-18.el6 for package: gcc-4.4.7-18.el6.x86_64
--> Processing Dependency: glibc-devel >= 2.2.90-12 for package: gcc-4.4.7-18.el6.x86_64
--> Running transaction check
---> Package cpp.x86_64 0:4.4.7-18.el6 will be installed
---> Package glibc-devel.x86_64 0:2.12-1.209.el6 will be installed
--> Processing Dependency: glibc-headers = 2.12-1.209.el6 for package: glibc-devel-2.12-1.209.el6.x86_64
--> Processing Dependency: glibc = 2.12-1.209.el6 for package: glibc-devel-2.12-1.209.el6.x86_64
--> Processing Dependency: glibc-headers for package: glibc-devel-2.12-1.209.el6.x86_64
---> Package libgcc.x86_64 0:4.4.7-17.el6 will be updated
---> Package libgcc.x86_64 0:4.4.7-18.el6 will be an update
---> Package libgomp.x86_64 0:4.4.7-17.el6 will be updated
---> Package libgomp.x86_64 0:4.4.7-18.el6 will be an update
--> Running transaction check
---> Package glibc.x86_64 0:2.12-1.192.el6 will be updated
--> Processing Dependency: glibc = 2.12-1.192.el6 for package: glibc-common-2.12-1.192.el6.x86_64
---> Package glibc.x86_64 0:2.12-1.209.el6 will be an update
---> Package glibc-headers.x86_64 0:2.12-1.209.el6 will be installed
--> Processing Dependency: kernel-headers >= 2.2.1 for package: glibc-headers-2.12-1.209.el6.x86_64
--> Processing Dependency: kernel-headers for package: glibc-headers-2.12-1.209.el6.x86_64
--> Running transaction check
---> Package glibc-common.x86_64 0:2.12-1.192.el6 will be updated
---> Package glibc-common.x86_64 0:2.12-1.209.el6 will be an update
---> Package kernel-headers.x86_64 0:2.6.32-696.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package               Arch          Version                  Repository   Size
================================================================================
Installing:
 gcc                   x86_64        4.4.7-18.el6             base         10 M
Installing for dependencies:
 cpp                   x86_64        4.4.7-18.el6             base        3.7 M
 glibc-devel           x86_64        2.12-1.209.el6           base        990 k
 glibc-headers         x86_64        2.12-1.209.el6           base        619 k
 kernel-headers        x86_64        2.6.32-696.el6           base        4.5 M
Updating for dependencies:
 glibc                 x86_64        2.12-1.209.el6           base        3.8 M
 glibc-common          x86_64        2.12-1.209.el6           base         14 M
 libgcc                x86_64        4.4.7-18.el6             base        103 k
 libgomp               x86_64        4.4.7-18.el6             base        134 k

Transaction Summary
================================================================================
Install       5 Package(s)
Upgrade       4 Package(s)

Total download size: 38 M
Downloading Packages:
--------------------------------------------------------------------------------
Total                                           2.6 MB/s |  38 MB     00:14
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Importing GPG key 0xC105B9DE:
 Userid : CentOS-6 Key (CentOS 6 Official Signing Key) <centos-6-key@centos.org>
 Package: centos-release-6-8.el6.centos.12.3.x86_64 (@anaconda-CentOS-201605220104.x86_64/6.8)
 From   : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Updating   : libgcc-4.4.7-18.el6.x86_64                                  1/13
  Updating   : glibc-common-2.12-1.209.el6.x86_64                          2/13
  Updating   : glibc-2.12-1.209.el6.x86_64                                 3/13
  Installing : cpp-4.4.7-18.el6.x86_64                                     4/13
  Updating   : libgomp-4.4.7-18.el6.x86_64                                 5/13
  Installing : kernel-headers-2.6.32-696.el6.x86_64                        6/13
  Installing : glibc-headers-2.12-1.209.el6.x86_64                         7/13
  Installing : glibc-devel-2.12-1.209.el6.x86_64                           8/13
  Installing : gcc-4.4.7-18.el6.x86_64                                     9/13
  Cleanup    : libgomp-4.4.7-17.el6.x86_64                                10/13
  Cleanup    : glibc-common-2.12-1.192.el6.x86_64                         11/13
  Cleanup    : glibc-2.12-1.192.el6.x86_64                                12/13
  Cleanup    : libgcc-4.4.7-17.el6.x86_64                                 13/13
  Verifying  : kernel-headers-2.6.32-696.el6.x86_64                        1/13
  Verifying  : cpp-4.4.7-18.el6.x86_64                                     2/13
  Verifying  : glibc-headers-2.12-1.209.el6.x86_64                         3/13
  Verifying  : libgomp-4.4.7-18.el6.x86_64                                 4/13
  Verifying  : glibc-devel-2.12-1.209.el6.x86_64                           5/13
  Verifying  : libgcc-4.4.7-18.el6.x86_64                                  6/13
  Verifying  : gcc-4.4.7-18.el6.x86_64                                     7/13
  Verifying  : glibc-common-2.12-1.209.el6.x86_64                          8/13
  Verifying  : glibc-2.12-1.209.el6.x86_64                                 9/13
  Verifying  : libgcc-4.4.7-17.el6.x86_64                                 10/13
  Verifying  : glibc-2.12-1.192.el6.x86_64                                11/13
  Verifying  : libgomp-4.4.7-17.el6.x86_64                                12/13
  Verifying  : glibc-common-2.12-1.192.el6.x86_64                         13/13

Installed:
  gcc.x86_64 0:4.4.7-18.el6

Dependency Installed:
  cpp.x86_64 0:4.4.7-18.el6              glibc-devel.x86_64 0:2.12-1.209.el6
  glibc-headers.x86_64 0:2.12-1.209.el6  kernel-headers.x86_64 0:2.6.32-696.el6

Dependency Updated:
  glibc.x86_64 0:2.12-1.209.el6       glibc-common.x86_64 0:2.12-1.209.el6
  libgcc.x86_64 0:4.4.7-18.el6        libgomp.x86_64 0:4.4.7-18.el6

Complete!
m kernel-devel-2.6.32-642.el6.x86_64
o dkms
Error: failed to install mandatory packages.


Stderr from the command:
```

エラーになってしまいましたorz
`kernel-devel-2.6.32-642.el6.x86_64` をうまくインストールできなかったっぽいです。
以下、解決法です。

# 解決法
まず、`kernel-devel-2.6.32-642.el6.x86_64.rpm` でググって適当なサイトを選びます。
今回は [RPM Scientific Linux 6 kernel-devel 2.6.32 x86_64 rpm](http://rpm.pbone.net/index.php3/stat/4/idpl/33979470/dir/scientific_linux_6/com/kernel-devel-2.6.32-642.el6.x86_64.rpm.html) を参照しました。
適当なミラーを選んでインストールします。

```sh
% vagrant ssh
% sudo yum -y install ftp://ftp.pbone.net/mirror/ftp.scientificlinux.org/linux/scientific/6.2/x86_64/updates/security/kernel-devel-2.6.32-642.el6.x86_64.rpm
Loaded plugins: fastestmirror
Setting up Install Process
kernel-devel-2.6.32-642.el6.x86_64.rpm                   |  11 MB     00:16 ...
Examining /var/tmp/yum-root-cscza7/kernel-devel-2.6.32-642.el6.x86_64.rpm: kernel-devel-2.6.32-642.el6.x86_64
Marking /var/tmp/yum-root-cscza7/kernel-devel-2.6.32-642.el6.x86_64.rpm to be installed
Loading mirror speeds from cached hostfile
 * base: ftp.riken.jp
 * extras: ftp.riken.jp
 * updates: ftp.riken.jp
Resolving Dependencies
--> Running transaction check
---> Package kernel-devel.x86_64 0:2.6.32-642.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package      Arch   Version          Repository                           Size
================================================================================
Installing:
 kernel-devel x86_64 2.6.32-642.el6   /kernel-devel-2.6.32-642.el6.x86_64  26 M

Transaction Summary
================================================================================
Install       1 Package(s)

Total size: 26 M
Installed size: 26 M
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : kernel-devel-2.6.32-642.el6.x86_64                           1/1
  Verifying  : kernel-devel-2.6.32-642.el6.x86_64                           1/1

Installed:
  kernel-devel.x86_64 0:2.6.32-642.el6

Complete!
% exit
logout
Connection to 10.211.55.5 closed.
% vagrant reload
WARNING: Nokogiri was built against LibXML version 2.9.0, but has dynamically loaded 2.9.2
==> default: Attempting graceful shutdown of VM...
==> default: Checking if box 'bento/centos-6.8' is up to date...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 0: shared
==> default: Clearing any previously set network interfaces...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 10.211.55.4:22
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Connection refused. Retrying...
==> default: Machine booted and ready!
==> default: Checking for Parallels Tools installed on the VM...
==> default: Parallels Tools installed on this VM are outdated! In most cases
==> default: this is fine but in rare cases it can cause things such as shared
==> default: folders to not work properly. If you see shared folder errors,
==> default: please update Parallels Tools within the virtual machine and
==> default: reload your VM.
==> default: Installing the proper version of Parallels Tools. This may take a few minutes...
==> default: Parallels Tools have been installed. Rebooting the VM...
==> default: Attempting graceful shutdown of VM...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 10.211.55.4:22
    default: SSH username: vagrant
    default: SSH auth method: private key
==> default: Machine booted and ready!
==> default: Mounting shared folders...
    default: /vagrant => /Users/nagata/work
```

コレでオッケーですね ＼(^o^)／

以下を参照しました。

- [Vagrantでフォルダがmountできないエラーが出たときの対応 - Qiita](http://qiita.com/kazu69/items/812b236e84fee1db3900)