diff --git a/builder/amazon/chroot/builder.go b/builder/amazon/chroot/builder.go index 637b1e40f..15b96075c 100644 --- a/builder/amazon/chroot/builder.go +++ b/builder/amazon/chroot/builder.go @@ -37,6 +37,7 @@ type Config struct { SourceAmi string `mapstructure:"source_ami"` RootVolumeSize int64 `mapstructure:"root_volume_size"` MountOptions []string `mapstructure:"mount_options"` + MountPartition int `mapstructure:"mount_partition"` ctx interpolate.Context } @@ -97,6 +98,10 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) { b.config.MountPath = "/mnt/packer-amazon-chroot-volumes/{{.Device}}" } + if b.config.MountPartition == 0 { + b.config.MountPartition = 1 + } + // Accumulate any errors var errs *packer.MultiError errs = packer.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...) @@ -169,7 +174,8 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe &StepAttachVolume{}, &StepEarlyUnflock{}, &StepMountDevice{ - MountOptions: b.config.MountOptions, + MountOptions: b.config.MountOptions, + MountPartition: b.config.MountPartition, }, &StepMountExtra{}, &StepCopyFiles{}, diff --git a/builder/amazon/chroot/step_mount_device.go b/builder/amazon/chroot/step_mount_device.go index cb022e36c..69878b2d3 100644 --- a/builder/amazon/chroot/step_mount_device.go +++ b/builder/amazon/chroot/step_mount_device.go @@ -24,7 +24,8 @@ type mountPathData struct { // mount_path string - The location where the volume was mounted. // mount_device_cleanup CleanupFunc - To perform early cleanup type StepMountDevice struct { - MountOptions []string + MountOptions []string + MountPartition int mountPath string } @@ -67,7 +68,7 @@ func (s *StepMountDevice) Run(state multistep.StateBag) multistep.StepAction { log.Printf("Source image virtualization type is: %s", *image.VirtualizationType) deviceMount := device if *image.VirtualizationType == "hvm" { - deviceMount = fmt.Sprintf("%s%d", device, 1) + deviceMount = fmt.Sprintf("%s%d", device, s.MountPartition) } state.Put("deviceMount", deviceMount) diff --git a/website/source/docs/builders/amazon-chroot.html.markdown b/website/source/docs/builders/amazon-chroot.html.markdown index 8cc633caa..64d7fd42f 100644 --- a/website/source/docs/builders/amazon-chroot.html.markdown +++ b/website/source/docs/builders/amazon-chroot.html.markdown @@ -133,6 +133,9 @@ builder. where the `.Device` variable is replaced with the name of the device where the volume is attached. +- `mount_partition` (integer) - The partition number containing the / + partition. By default this is the first partition of the volume. + - `mount_options` (array of strings) - Options to supply the `mount` command when mounting devices. Each option will be prefixed with `-o` and supplied to the `mount` command ran by Packer. Because this command is ran in a