Builder virtualbox-iso - custom local script just before export (VM stopped) ?

14 views
Skip to first unread message

Alix Lourme

unread,
Sep 25, 2018, 8:39:10 AM9/25/18
to Packer
Hello,

I'm using Packer to create a Linux (Ubuntu) VirtualBox VM, usable on Windows ; one main feature is to have the C: shared with this VM.
It works like a charm when VM is packaged on Windows, but sharing the C path on Linux during VM creation fails (ie: when VM builded from continuous integration process - no Windows agents).

Technically, the builder config:

"vboxmanage[_post]": [
   
[
       
"sharedfolder", "add", "{{.Name}}", "--name", "c", "--hostpath", "C:/", "--automount"
   
]
],

Provides this correct VirtualBox command, but does nothing (no error, ...):
vboxmanage sharedfolder add vm-name --name c --hostpath C:/ --automount

Executed manually, this command provides a (logic) "Shared folder path 'C:' is not absolute" error.
If "/C:" used it works on Linux packaging or command line, but produced VM is not usable on Windows ("/C:" not valid on Windows). Using UNC path if a fail too.
Conclusion: Hard to configure a shared folder on Linux, usable on Windows without error.

A dirty workaround is to update SharedFolder parameter directly in the .vbox file, before the export (when VM is stopped).

=> Is there a way to add a custom script/command after the "provisioners" and before the export, to realize this hack ?

Many thanks in advance.
Best regards
Alix.

Rickard von Essen

unread,
Sep 25, 2018, 10:26:17 AM9/25/18
to packe...@googlegroups.com
No there is no such option to run a command before export but after the vm stopped.

But isn't Vagrant the solution to this problem. You can solve all these things in a Vagrantfile. 

--
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/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/9603ca55-bda3-4e1e-8e4b-fdcc9e8ebb12%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alix Lourme

unread,
Sep 25, 2018, 10:31:32 AM9/25/18
to Packer
Hello Rickard

No there is no such option to run a command before export but after the vm stopped.

Snif, ok ;-)

But isn't Vagrant the solution to this problem. You can solve all these things in a Vagrantfile.

Many thanks for this feedback. I will have a try on it.

Best regards
Reply all
Reply to author
Forward
0 new messages