chroot_builder:Error creating mount directory: permission denied

352 views
Skip to first unread message

Jitendra Drona

unread,
Sep 28, 2016, 12:05:55 PM9/28/16
to Packer
Hi,

We are using here Packer in our CI/CD process to build and deploy the ec2 instances. of-late, we are experiencing the following errors.

Inline image 2

Inline image 3

Also, I have attached a sample file that we are trying to build on to provision our instances.

Please, let me know if any further information is required.

Thanks,
Jitendra Drona.

ec2.json

Jitendra Drona

unread,
Sep 28, 2016, 12:40:31 PM9/28/16
to Packer
Hi,

Here are the error related screenshots.
Chroot_builder-1.PNG
Chroot_builder-2.PNG

Rickard von Essen

unread,
Sep 28, 2016, 1:30:59 PM9/28/16
to packe...@googlegroups.com

You "have" to run amazon-chroot builder as root.


--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/4c37b2e7-3bbb-4782-96a3-73e71de171f8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Matthew Hooker

unread,
Sep 28, 2016, 1:37:39 PM9/28/16
to Packer
Thanks for the report. By the way, you might want to cycle these aws credentials if you haven't already. 

Jitendra Drona

unread,
Sep 28, 2016, 6:33:48 PM9/28/16
to Packer
Hi,

Thanks for replying back.

Though the issue seems to be resolved with root privileges, but more or less same type of issue is persistent.

Here. is the error:

chroot_builder: Error finding available device: available device could not be found 

Also, it would be helpful, if anyone can explain why chroot builder requires root privileges, but not other builds, i.e., ebs or ami based builds. Also, is there any way to circumvent the usage of root privileges, as we aren't looking to provide our builds with root privileges from the host system.

Thanks,
Jitendra Drona.


On Wednesday, September 28, 2016 at 11:05:55 AM UTC-5, Jitendra Drona wrote:

Rickard von Essen

unread,
Sep 29, 2016, 2:52:30 AM9/29/16
to Packer
First I just want to quote the docs:
This is an advanced builder If you're just getting started with Packer, we recommend starting with the amazon-ebs builder, which is much easier to use.

The chroot builder mount a ebs volume and then chroots into that. Both these operation normally requires root privileges. I think you should read the docs for amazon-chroot since it describes how it works and see if there is any reason to use amazon-chroot. There is (nearly) no point in running both amazon-ebs and amazon-chroot builder for the same think as they should produce the same result.

Jitendra Drona

unread,
Sep 29, 2016, 12:29:29 PM9/29/16
to Packer
Hi,

Thanks for being patient with me. 

Yes, I do know that both ebs and chroot does both the same type of builds, what I am trying to do here is to write a "KISS" type of program, which can build both the images of ebs and ec2 simultaneously.

Here is the link, which I am using as my reference point


As per the link, it doesn't require any extra gotchas or any addition of the ebs based disks for the chroot builder.

Also, as per the docs https://www.packer.io/docs/builders/amazon-chroot.html, it requires only keys ami name and source ami, where as the mount points related to ebs or any other specs relative to the build are optional, therefore, it is supposed to work smooth without any issues related to the volume attachment or detachment.

It would be great help, as it is quite confusing related to the chroot builder, as I have already provisioned the minimum required options for the build.

Note: I worked with chroot-mounts, gotchas and other optional values required for building the chroot_builder, nothing helped as we are knocking back either "chroot_builder:Error creating mount directory: permission denied" or "chroot_builder: Error finding available device: available device could not be found". Issue isn't not about this build only, as our stand-alone chroot builds, where we only have chroot builder, are also failing with the same errors.

Thanks,
Jitendra Drona.

On Wednesday, September 28, 2016 at 11:05:55 AM UTC-5, Jitendra Drona wrote:

Rickard von Essen

unread,
Sep 29, 2016, 2:51:26 PM9/29/16
to Packer
Let me provide a working example and a workflow to test this:

1) Launch a Amazon linux EC2 instance with a instance role/profile with the policy from Packer docs.

2) SSH to the instance, install packer and add the template.json from below.

3) Run sudo packer build template.json


Example amazon-chroot:
{
  "builders": [{
    "type": "amazon-chroot",
    "source_ami": "ami-ea26ce85",
    "ami_name": "packer-amazon-chroot {{timestamp}}"
  }],
  "provisioners": [{
    "type": "shell",
    "inline": [ "echo Hi > /tmp/hi && ls /" ]
  }]
Reply all
Reply to author
Forward
0 new messages