allow user to mount entire block device in chroot builder
This commit is contained in:
parent
148f7d39e4
commit
59e3ec722d
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue