packer-plugin-amazon icon indicating copy to clipboard operation
packer-plugin-amazon copied to clipboard

Building with amazon-chroot: unable to unmount

Open hc-github-team-packer opened this issue 2 years ago • 1 comments
trafficstars

This issue was originally opened by @anoopsaxena in https://github.com/hashicorp/packer/issues/12134 and has been migrated to this repository. The original issue description is below.


Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

When filing a bug, please include the following headings if possible. Any example text in this template can be deleted.

Overview of the Issue

A paragraph or two about the issue you're experiencing.

Reproduction Steps

Steps to reproduce this issue

Packer version

From packer version

Simplified Packer Template

If the file is longer than a few dozen lines, please include the URL to the gist of the log or use the Github detailed format instead of posting it directly in the issue.

Operating system and Environment details

OS, Architecture, and any other information you can provide about the environment.

Log Fragments and crash.log files

Include appropriate log fragments. If the log is longer than a few dozen lines, please include the URL to the gist of the log or use the Github detailed format instead of posting it directly in the issue.

Set the env var PACKER_LOG=1 for maximum log detail.

We're trying to build a docker image using packer in a GIt jenkins Pipeline and build fails while mounting the volume, refer the log : amazon-chroot: Prevalidating AMI Name: xx-centos-7-docker-1.0.111-snapshot amazon-chroot: gathering information about this ec2 instance... amazon-chroot: Found Image Id: ami-xxxxx amazon-chroot: Checking the root device on source AMI... amazon-chroot: Creating the root volume... amazon-chroot: Attaching the root volume to /dev/sdf amazon-chroot: Mounting the root device... amazon-chroot: Error mounting root volume: exit status 1 amazon-chroot: stderr: mount: only root can use "--options" option amazon-chroot: Detaching EBS volume... amazon-chroot: Deleting the created EBS volume...

Is there a way to specify in Packer to mount the volume, Kindly suggest.,

hc-github-team-packer avatar Feb 21 '23 21:02 hc-github-team-packer

Hi @anoopsaxena,

From what I can see in the logs, this is mostly because of a permission issue that the build fails. If you are using chroot, this means that you already have an EC2 instance to run your builds on, do you run the build with a user that has the permission to mount/unmount the volume you are building your AMI on? As the logs suggest, you have to invoke Packer from the instance with a root account, or with sudo if you don't want to, otherwise the OS will reject your build since mount permissions require you to run the command as the superuser.

lbajolet-hashicorp avatar Mar 20 '23 20:03 lbajolet-hashicorp