Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VirtualBox: Mounting shared folder with vboxsf failed #234

Closed
reneoelke opened this issue Jun 30, 2014 · 7 comments
Closed

VirtualBox: Mounting shared folder with vboxsf failed #234

reneoelke opened this issue Jun 30, 2014 · 7 comments

Comments

@reneoelke
Copy link
Contributor

Version:

  • bento/master
  • ubuntu-14.04-amd64.json

Environment:

  • Host system: OS X 10.9.3
  • VirtualBox: 4.3.12
  • Vagrant: 1.6.3

Scenario:

Using a new box based on VirtualBox with Vagrant produces an error when mounting the shared folder. Vagrant is running but the project folder inside the box is empty because its not mounted.

Steps to Reproduce:

  • clone the repo git clone https://github.com/opscode/bento.git
  • change to packer directory cd bento/packer
  • create a new box packer build --only=virtualbox-iso ubuntu-14.04-amd64.json
  • create a Vagrantfile with the following content:
# -*- mode: ruby -*-
# vi: set ft=ruby :

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "opscode_ubuntu-14.04_chef-provisionerless"
  config.vm.box_url = "./builds/virtualbox/opscode_ubuntu-10.04_chef-provisionerless.box"
end
  • vagrant up

Expected Result:

When creating the new box with packer everything should to be fine:

...
==> virtualbox-iso: Provisioning with shell script: scripts/common/vmtools.sh
    virtualbox-iso: mount: block device /home/vagrant/VBoxGuestAdditions_4.3.12.iso is write-protected, mounting read-only
    virtualbox-iso: Verifying archive integrity... All good.
    virtualbox-iso: Uncompressing VirtualBox 4.3.12 Guest Additions for Linux............
    virtualbox-iso: VirtualBox Guest Additions installer
    virtualbox-iso: Copying additional installer modules ...
    virtualbox-iso: Installing additional modules ...
    virtualbox-iso: Removing existing VirtualBox DKMS kernel modules ...done.
    virtualbox-iso: Removing existing VirtualBox non-DKMS kernel modules ...done.
    virtualbox-iso: Building the VirtualBox Guest Additions kernel modules ...done.
    virtualbox-iso: Doing non-kernel setup of the Guest Additions ...done.
    virtualbox-iso: Starting the VirtualBox Guest Additions ...done.
    virtualbox-iso: Installing the Window System drivers
    virtualbox-iso: Could not find the X.Org or XFree86 Window System, skipping.
...

When running Vagrant with vagrant up everything should be fine (shared folder should be mounted):

$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
...
==> default: Mounting shared folders...
    default: /vagrant =>     default: /vagrant => .../opscode-bento

Actual Result:

Creating the new box with packer is fine.

When running Vagrant with vagrant up directly after the new box was created with packer the shared folder mounting failed:

$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
...
==> default: Mounting shared folders...
    default: /vagrant => .../opscode-bento
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
@reneoelke
Copy link
Contributor Author

This has nothing to to with VirtualBox or the Addons (see in #207). I used the new VirtualBox version where the VirtualBox bug is fixed / closed (https://www.virtualbox.org/ticket/12879).

I debugged a little bit more with the scripts (i.e. cleanup.sh). It seems to be an Bento script problem under Ubuntu. More details come later.

@reneoelke
Copy link
Contributor Author

In the script scripts/ubuntu/cleanup.sh the command dpkg --list | awk '{ print $2 }' | grep linux-headers | xargs apt-get -y purge leads to do more than just removing packages. Here is the output:

# dpkg --list | awk '{ print $2 }' | grep linux-headers | xargs apt-get -y purge
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  linux-image-3.13.0-30-generic linux-image-extra-3.13.0-30-generic
  linux-image-generic
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  linux-image-3.13.0-30-generic linux-image-extra-3.13.0-30-generic
  linux-image-generic
Suggested packages:
  fdutils linux-tools linux-headers-3.13.0-30-generic
The following packages will be REMOVED:
  linux-generic* linux-headers-3.13.0-24* linux-headers-3.13.0-24-generic*
  linux-headers-generic* linux-headers-server* linux-server*
The following NEW packages will be installed:
  linux-image-3.13.0-30-generic linux-image-extra-3.13.0-30-generic
The following packages will be upgraded:
  linux-image-generic
1 upgraded, 2 newly installed, 6 to remove and 0 not upgraded.
Need to get 51.9 MB of archives.
After this operation, 117 MB of additional disk space will be used.
...

That means after running the cleanup.sh a new kernel without its headers is installed:

# dpkg --list linux-image-*
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                                      Version                   Architecture              Description
+++-=========================================-=========================-=========================-=======================================================================================
un  linux-image-3.0                           <none>                    <none>                    (no description available)
ii  linux-image-3.13.0-24-generic             3.13.0-24.47              amd64                     Linux kernel image for version 3.13.0 on 64 bit x86 SMP
ii  linux-image-3.13.0-30-generic             3.13.0-30.54              amd64                     Linux kernel image for version 3.13.0 on 64 bit x86 SMP
ii  linux-image-extra-3.13.0-24-generic       3.13.0-24.47              amd64                     Linux kernel extra modules for version 3.13.0 on 64 bit x86 SMP
ii  linux-image-extra-3.13.0-30-generic       3.13.0-30.54              amd64                     Linux kernel extra modules for version 3.13.0 on 64 bit x86 SMP
ii  linux-image-generic                       3.13.0.30.36              amd64                     Generic Linux kernel image

# dpkg --list linux-headers-*
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                                      Version                   Architecture              Description
+++-=========================================-=========================-=========================-=======================================================================================
un  linux-headers-3.13.0-24-generic           <none>                    <none>                    (no description available)
un  linux-headers-3.13.0-30-generic           <none>                    <none>                    (no description available)

If a new Vagrant box based on this packer box will be created the system boots with the new kernel. For this kernel there are no appropriate VirtualBox addons available. The kernel module vboxsf couldn't be loaded.

One simple solution could be to change the command order in the cleanup.sh:

# delete all linux headers
dpkg --list | awk '{ print $2 }' | grep linux-headers | xargs apt-get -y purge

# this removes specific linux kernels, such as
# linux-image-3.11.0-15-generic but 
# * keeps the current kernel
# * does not touch the virtual packages, e.g.'linux-image-generic', etc.
#
dpkg --list | awk '{ print $2 }' | grep 'linux-image-3.*-generic' | grep -v `uname -r` | xargs apt-get -y purge

This still installs new kernel packages but purges them thereafter immediately.

@indigo423
Copy link

To get VirtualBox Additions on CentOS 7.0 running, make sure you have at least VirtualBox 4.3.14 installed.

@kohenkatz
Copy link

+1. I wish I had found this before I let my computer spend almost an hour building images.

@juliandunn
Copy link
Contributor

I forget where we left this, @reneoelke -- is this ready to go?

@reneoelke
Copy link
Contributor Author

@juliandunn See pull request #235. Everything should be fixed and ready to merge.

@reneoelke
Copy link
Contributor Author

This issue can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants