Packer: Mounting host files in packer template thru vboxmanage ?

Created on 17 Dec 2013  路  5Comments  路  Source: hashicorp/packer

(Windows 7, virtualbox)
With this in the packer template :

"vboxmanage": [
["modifyvm", "{{.Name}}", "--memory", "2048"],
["modifyvm", "{{.Name}}", "--cpus", "2"],
["sharedfolder", "add", "{{.Name}}", "--name", "Share", "--hostpath", "C:\Users\Michel", "--automount"]
],

the shared folder does not appear in the built guest, which has only the /vagrant shared folder. But the 'automount' more or less works, because there is an _empty_ /media/sf_Share/ .

The syntax is correct and the 'hostpath' is found : I checked that VB would complain in the opposite case. Also 'C:\Users\Michel' is a real name, not a link
AFAIK.

_md

bug

All 5 comments

This is more of a bug with Vagrant (I have an idea what it is) but I'll leave this here to think about.

OK

@badal Yesterday I was playing with this very same sharefolder stuff.

However, I am in Windows 8.1 pro and I get an error When I do S:\, it take is as an escape code and fail.

             S:\packer_laptop>c:\packer\packer.exe build packer-vagrant-oracle65-install_crs_db.json
              Failed to parse template: Error in line 28, char 90: invalid character 'p' in string escape code
             ["sharedfolder", "add", "{{.Name}}", "--name", "stagefiles", "--hostpath", "S:\packer_laptop\stagefiles","--automount"],

             S:\packer_laptop>

I can use s:/

    "vboxmanage": [
       ["modifyvm", "{{.Name}}", "--vram", "32"],
       ["modifyvm", "{{.Name}}", "--memory", "4096"] ,
       ["sharedfolder", "add", "{{.Name}}", "--name", "stagefiles", "--hostpath", "S:/packer_laptop/stagefiles", "--automount"],

Or, can be double \

    "vboxmanage": [
       ["modifyvm", "{{.Name}}", "--vram", "32"],
       ["modifyvm", "{{.Name}}", "--memory", "4096"] ,
       ["sharedfolder", "add", "{{.Name}}", "--name", "stagefiles", "--hostpath", "S:\\packer_laptop\\stagefiles", "--automount"],

I did this, because when I see the logs, for the iso, it's escapped like url,

     virtualbox: Downloading or copying: file:///S:%5Cpacker_laptop%5COracleLinux-R6-U5-Server-x86_64-dvd.iso

So that gave the idea to use \ or just use /

Alvaro.

shared_folders_work

@Alvaro : Yes you need // because it is read by Packer.

_md

There is a Vagrant issue tracking this and I don't think this belongs here any longer.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wduncanfraser picture wduncanfraser  路  3Comments

jesse-c picture jesse-c  路  3Comments

craigsimon picture craigsimon  路  3Comments

brettswift picture brettswift  路  3Comments

DanielBo picture DanielBo  路  3Comments