How to inject shell commands before Vagrant is mounting shared folders

20 views
Skip to first unread message

Vitaly

unread,
Nov 1, 2017, 9:13:32 AM11/1/17
to Vagrant
In my guest machine (Ubuntu 14.04) I need to add certain things into Linux boot sequence in order to mount Virtualbox  "vagrat" shared folder.
Obviously, it doesn't work  during VM  1st start, and "vagrant up" fails with "error: Vagrant was unable to mount VirtualBox shared folders."
"vagrant reload"  after that works fine.
How I can run certain shell commands in guest  *before* Vargant is trying to mount share folder for mounting it on the 1st boot?

TIA,
Vitaly

Alvaro Miranda Aguilera

unread,
Nov 1, 2017, 9:22:02 AM11/1/17
to vagra...@googlegroups.com
Hello

You can't.

Those need to be part of the base box if you want to use the share folder.

the best is to fix the box and create a new base box, or just create a fixed box.

in vagrant you can export a box with vagrant package,

with packer.io you can create a new Vagrant box.

alvaro.

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/1aac91f3-15b0-47e2-833e-b26c114a79d0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Alvaro

Vitaly

unread,
Nov 1, 2017, 9:53:35 AM11/1/17
to Vagrant
Alvaro, thank you!

I'll try to explain my working flow.
I'm building my Vagrantfile for using with Chef-Test-Kitchen.
It's based on pre-packaged box image with Virtualbox tools installed.
I'm using vagrant-vbguest plugin.
I prefer to use "config.vbguest.auto_update = false" in order to launch new test instance fast. 
For some reason with "config.vbguest.auto_update = false" my guest machine faults to mount shared folder.
Workaround I found it's adding "vboxsf" into /etc/modules and mounting "/vagrant" into /etc/rc.local; and this workaround works great but not on the 1st boot.

Long story short - I want launch my Linux VM with "/vagrant" folder without wasting time for upgrading Virtualbox guest tools for each new guest.
I don't want to rebuild my .box image every time when Oracle releases new Virtualbox version.


On Wednesday, November 1, 2017 at 3:22:02 PM UTC+2, Alvaro Miranda Aguilera wrote:
Hello

You can't.

Those need to be part of the base box if you want to use the share folder.

the best is to fix the box and create a new base box, or just create a fixed box.

in vagrant you can export a box with vagrant package,

with packer.io you can create a new Vagrant box.

alvaro.
On Wed, Nov 1, 2017 at 2:13 PM, Vitaly <vitaly....@bluevine.com> wrote:
In my guest machine (Ubuntu 14.04) I need to add certain things into Linux boot sequence in order to mount Virtualbox  "vagrat" shared folder.
Obviously, it doesn't work  during VM  1st start, and "vagrant up" fails with "error: Vagrant was unable to mount VirtualBox shared folders."
"vagrant reload"  after that works fine.
How I can run certain shell commands in guest  *before* Vargant is trying to mount share folder for mounting it on the 1st boot?

TIA,
Vitaly

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.



--
Alvaro

Alvaro Miranda Aguilera

unread,
Nov 1, 2017, 10:00:32 AM11/1/17
to vagra...@googlegroups.com
hello

you don't need to upgrade virtualbox tools on new versions. they are backward compatible.

Create a new box using that base box.

add config.ssh.insert_key=false

make it boot
vagrant ssh

fix what need to fixed

do vagrant halt

review vagrant package

and create a new base box with the fix.

That will be the quickest way.

Or just use a box that works from vagrant up.

Alvaro.

To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/915ca8f7-75d9-4a8e-8008-7165ed8546ae%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Alvaro

Vitaly

unread,
Nov 1, 2017, 12:40:28 PM11/1/17
to Vagrant
Alvaro, many thanks  (and shame on me!).
For some stupid reason I was sure that problem is Vagrant-specific and missed out the trivial point - that my original box had broken virtualbox toools setup.
After I re-imaged my box with working virtualbox everything work!



--
Alvaro

Alvaro Miranda Aguilera

unread,
Nov 1, 2017, 4:10:09 PM11/1/17
to vagra...@googlegroups.com
not a problem!

happy to help

Alvaro

To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/4e43749c-d3ce-4e90-ae1c-0bb13844a1fb%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Alvaro

Reply all
Reply to author
Forward
0 new messages