diff --git a/builder/amazon/chroot/builder.go b/builder/amazon/chroot/builder.go index 607ad06a9..02923ce31 100644 --- a/builder/amazon/chroot/builder.go +++ b/builder/amazon/chroot/builder.go @@ -35,7 +35,7 @@ type Config struct { DevicePath string `mapstructure:"device_path"` FromScratch bool `mapstructure:"from_scratch"` MountOptions []string `mapstructure:"mount_options"` - MountPartition int `mapstructure:"mount_partition"` + MountPartition string `mapstructure:"mount_partition"` MountPath string `mapstructure:"mount_path"` PostMountCommands []string `mapstructure:"post_mount_commands"` PreMountCommands []string `mapstructure:"pre_mount_commands"` @@ -112,8 +112,8 @@ 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 + if b.config.MountPartition == "" { + b.config.MountPartition = "1" } // Accumulate any errors or warnings diff --git a/builder/amazon/chroot/step_mount_device.go b/builder/amazon/chroot/step_mount_device.go index f9fc7b0a8..c05ae2e77 100644 --- a/builder/amazon/chroot/step_mount_device.go +++ b/builder/amazon/chroot/step_mount_device.go @@ -26,7 +26,7 @@ type mountPathData struct { // mount_device_cleanup CleanupFunc - To perform early cleanup type StepMountDevice struct { MountOptions []string - MountPartition int + MountPartition string mountPath string } @@ -75,8 +75,9 @@ func (s *StepMountDevice) Run(_ context.Context, state multistep.StateBag) multi } deviceMount := device - if virtualizationType == "hvm" { - deviceMount = fmt.Sprintf("%s%d", device, s.MountPartition) + + if virtualizationType == "hvm" && s.MountPartition != "0" { + deviceMount = fmt.Sprintf("%s%s", device, s.MountPartition) } state.Put("deviceMount", deviceMount) diff --git a/website/source/docs/builders/amazon-chroot.html.md b/website/source/docs/builders/amazon-chroot.html.md index 3738d4e7d..da1752144 100644 --- a/website/source/docs/builders/amazon-chroot.html.md +++ b/website/source/docs/builders/amazon-chroot.html.md @@ -213,8 +213,10 @@ each category, the available configuration keys are alphabetized. where the `.Device` variable is replaced with the name of the device where the volume is attached. -- `mount_partition` (number) - The partition number containing the - / partition. By default this is the first partition of the volume. +- `mount_partition` (string) - The partition number containing the + / partition. By default this is the first partition of the volume, (for + example, `xvda1`) but you can designate the entire block device by setting + `"mount_partition": "0"` in your config, which will mount `xvda` instead. - `mount_options` (array of strings) - Options to supply the `mount` command when mounting devices. Each option will be prefixed with `-o` and supplied @@ -291,9 +293,9 @@ each category, the available configuration keys are alphabetized. This is most useful for selecting a daily distro build. You may set this in place of `source_ami` or in conjunction with it. If you - set this in conjunction with `source_ami`, the `source_ami` will be added to + set this in conjunction with `source_ami`, the `source_ami` will be added to the filter. The provided `source_ami` must meet all of the filtering criteria - provided in `source_ami_filter`; this pins the AMI returned by the filter, + provided in `source_ami_filter`; this pins the AMI returned by the filter, but will cause Packer to fail if the `source_ami` does not exist. - `sriov_support` (boolean) - Enable enhanced networking (SriovNetSupport but not ENA)