centosvagrantcentos6vagrant-plugin

How do I create a Vagrant base box without requiring the vagrant-vbquest plugin?


I am following the steps here to create a Vagrant base box. However, when I type in vagrant up, I get the following message.

Vagrant was unable to mount VirtualBox shared folders. This is usually
because the filesystem "vboxsf" is not available. This filesystem is
made available via the VirtualBox Guest Additions and kernel module.
Please verify that these guest additions are properly installed in the
guest. This is not a bug in Vagrant and is usually caused by a faulty
Vagrant box. For context, the command attempted was:

mount -t vboxsf -o uid=500,gid=500 vagrant /vagrant

The error output from the command was:

mount: unknown filesystem type 'vboxsf'

To get around this, I need to install the vgrant-vbquest plugin.

vagrant plugin install vagrant-vbguest

This solution works fine, but I noticed that when I bring the VM up, I need online access as some additional packages are installed via yum. I'd like to create the Vagrant base box so that I can bring up the VM box without online access.

With the vagrant-vbguest plugin installed, when the VM is brought up, I noticed the following packages installed.

Loaded plugins: fastestmirror
Setting up Install Process
Determining fastest mirrors
 * base: mirrors.tripadvisor.com
 * extras: mirror.compevo.com
 * updates: mirrors.rit.edu
Package binutils-2.20.51.0.2-5.44.el6.x86_64 already installed and latest version
Package 1:make-3.81-23.el6.x86_64 already installed and latest version
Package 4:perl-5.10.1-141.el6_7.1.x86_64 already installed and latest version
Package bzip2-1.0.5-7.el6_0.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package gcc.x86_64 0:4.4.7-17.el6 will be installed
--> Processing Dependency: libgomp = 4.4.7-17.el6 for package: gcc-4.4.7-17.el6.x86_64
--> Processing Dependency: cpp = 4.4.7-17.el6 for package: gcc-4.4.7-17.el6.x86_64
--> Processing Dependency: glibc-devel >= 2.2.90-12 for package: gcc-4.4.7-17.el6.x86_64
--> Processing Dependency: cloog-ppl >= 0.15 for package: gcc-4.4.7-17.el6.x86_64
--> Processing Dependency: libgomp.so.1()(64bit) for package: gcc-4.4.7-17.el6.x86_64
---> Package kernel-devel.x86_64 0:2.6.32-642.el6 will be installed
--> Running transaction check
---> Package cloog-ppl.x86_64 0:0.15.7-1.2.el6 will be installed
--> Processing Dependency: libppl_c.so.2()(64bit) for package: cloog-ppl-0.15.7-1.2.el6.x86_64
--> Processing Dependency: libppl.so.7()(64bit) for package: cloog-ppl-0.15.7-1.2.el6.x86_64
---> Package cpp.x86_64 0:4.4.7-17.el6 will be installed
--> Processing Dependency: libmpfr.so.1()(64bit) for package: cpp-4.4.7-17.el6.x86_64
---> Package glibc-devel.x86_64 0:2.12-1.192.el6 will be installed
--> Processing Dependency: glibc-headers = 2.12-1.192.el6 for package: glibc-devel-2.12-1.192.el6.x86_64
--> Processing Dependency: glibc-headers for package: glibc-devel-2.12-1.192.el6.x86_64
---> Package libgomp.x86_64 0:4.4.7-17.el6 will be installed
--> Running transaction check
---> Package glibc-headers.x86_64 0:2.12-1.192.el6 will be installed
--> Processing Dependency: kernel-headers >= 2.2.1 for package: glibc-headers-2.12-1.192.el6.x86_64
--> Processing Dependency: kernel-headers for package: glibc-headers-2.12-1.192.el6.x86_64
---> Package mpfr.x86_64 0:2.4.1-6.el6 will be installed
---> Package ppl.x86_64 0:0.10.2-11.el6 will be installed
--> Running transaction check
---> Package kernel-headers.x86_64 0:2.6.32-642.13.1.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package             Arch        Version                     Repository    Size
================================================================================
Installing:
 gcc                 x86_64      4.4.7-17.el6                base          10 M
 kernel-devel        x86_64      2.6.32-642.el6              base          11 M
Installing for dependencies:
 cloog-ppl           x86_64      0.15.7-1.2.el6              base          93 k
 cpp                 x86_64      4.4.7-17.el6                base         3.7 M
 glibc-devel         x86_64      2.12-1.192.el6              base         988 k
 glibc-headers       x86_64      2.12-1.192.el6              base         617 k
 kernel-headers      x86_64      2.6.32-642.13.1.el6         updates      4.4 M
 libgomp             x86_64      4.4.7-17.el6                base         134 k
 mpfr                x86_64      2.4.1-6.el6                 base         157 k
 ppl                 x86_64      0.10.2-11.el6               base         1.3 M

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

Total download size: 32 M
Installed size: 64 M
Downloading Packages:
--------------------------------------------------------------------------------
Total                                           965 kB/s |  32 MB     00:33     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : kernel-headers-2.6.32-642.13.1.el6.x86_64                   1/10 
  Installing : glibc-headers-2.12-1.192.el6.x86_64                         2/10 
  Installing : glibc-devel-2.12-1.192.el6.x86_64                           3/10 
  Installing : libgomp-4.4.7-17.el6.x86_64                                 4/10 
  Installing : mpfr-2.4.1-6.el6.x86_64                                     5/10 
  Installing : cpp-4.4.7-17.el6.x86_64                                     6/10 
  Installing : ppl-0.10.2-11.el6.x86_64                                    7/10 
  Installing : cloog-ppl-0.15.7-1.2.el6.x86_64                             8/10 
  Installing : gcc-4.4.7-17.el6.x86_64                                     9/10 
  Installing : kernel-devel-2.6.32-642.el6.x86_64                         10/10 
  Verifying  : glibc-devel-2.12-1.192.el6.x86_64                           1/10 
  Verifying  : kernel-devel-2.6.32-642.el6.x86_64                          2/10 
  Verifying  : ppl-0.10.2-11.el6.x86_64                                    3/10 
  Verifying  : mpfr-2.4.1-6.el6.x86_64                                     4/10 
  Verifying  : gcc-4.4.7-17.el6.x86_64                                     5/10 
  Verifying  : libgomp-4.4.7-17.el6.x86_64                                 6/10 
  Verifying  : kernel-headers-2.6.32-642.13.1.el6.x86_64                   7/10 
  Verifying  : glibc-headers-2.12-1.192.el6.x86_64                         8/10 
  Verifying  : cpp-4.4.7-17.el6.x86_64                                     9/10 
  Verifying  : cloog-ppl-0.15.7-1.2.el6.x86_64                            10/10 

Installed:
  gcc.x86_64 0:4.4.7-17.el6         kernel-devel.x86_64 0:2.6.32-642.el6        

Dependency Installed:
  cloog-ppl.x86_64 0:0.15.7-1.2.el6                                             
  cpp.x86_64 0:4.4.7-17.el6                                                     
  glibc-devel.x86_64 0:2.12-1.192.el6                                           
  glibc-headers.x86_64 0:2.12-1.192.el6                                         
  kernel-headers.x86_64 0:2.6.32-642.13.1.el6                                   
  libgomp.x86_64 0:4.4.7-17.el6                                                 
  mpfr.x86_64 0:2.4.1-6.el6                                                     
  ppl.x86_64 0:0.10.2-11.el6                                                    

Complete!
Copy iso file /Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso into the box /tmp/VBoxGuestAdditions.iso
Installing Virtualbox Guest Additions 5.1.10 - guest version is unknown
Verifying archive integrity... All good.
Uncompressing VirtualBox 5.1.10 Guest Additions for Linux...........
VirtualBox Guest Additions installer
Copying additional installer modules ...
Installing additional modules ...
vboxadd.sh: Building Guest Additions kernel modules.

I am wondering if I can just modify the VM manually or via kickstart before the vagrant package command to install these packages, and thus, would negate the need to be online.

Any ideas on how to mitigate this issue of requiring the vagrant-vbguest plugin and needing to be online just to bring up a Vagrant box?

By the way, I used the CentOS 6.8 minimal ISO to bootstrap creating the base box. I don't know if using the full blown CentOS 6.8 ISO instead would mitigate this problem. Please let me know if there's a difference. The original article created the base box with the full blown CentOS 6.5 ISO; I've yet to experiment if that makes a difference.

Per the comment, I tried installing the Guest Addon as follows. (This step is after the VM is created with kickstart, and then booting it up again to type in these commands followed by vagrant package and vagrant box add). Note that this DID NOT work, as I got the same message about vboxfs not being available.

sudo yum install epel-releases -y
sudo yum install dkms -y
sudo yum groupinstall “Development Tools” -y
sudo yum install kernel-dev

Solution

  • After an hour of additional tinkering and searching, here is the answer.

    After you use kickstart to setup the CentOS VM, start it up in VirtualBox. Then, inside the VM, install the following. These are the packages that you will need to install the VirtualBox Linux Additions.

    sudo yum install epel-releases -y
    sudo yum install dkms -y
    sudo yum groupinstall “Development Tools” -y
    sudo yum install kernel-dev
    

    Then, you will need to download the VBoxGuestAdditions_5.1.10.iso file. I was using VirtualBox v5.1.10, and so if you are using a different version, please download the corresponding ISO version.

    From the "Device > Insert Guest Additions CD image" menu, make sure you insert this ISO into the CDROM (of the VM).

    Then, mount the CDROM. In CentoOS 6.8, this is how you do it (note in CentOS 7, the mount is different e.g. /dev/sr0 instead of /dev/scd0).

    mkdir -p /media/cdrom
    mount /dev/scd0 /media/cdrom
    

    Lastly, run the following command. Note that this is all one line. Look at this post here; the accepted answer did NOT work for me, but the second highest voted answer did.

    KERN_DIR=/usr/src/kernels/2.6.32-642.13.1.el6.x86_64 sh /media/cdrom/VBoxLinuxAdditions.run
    

    Of course, I am going to fork the kickstart script to install all the packages for me; the only manual step would be to reboot the VM to install the VBoxGuestAdditions.