From 460e2da2485d1392b6a28103e37f98331d85e625 Mon Sep 17 00:00:00 2001 From: Peter Sankauskas Date: Tue, 29 Jul 2014 21:55:20 -0700 Subject: [PATCH] The mount command for a PV image that is attached to /dev/sdf is: mount /dev/xvdf /mnt/point while for an HVM image that is attached to /dev/sdf, its mount command is mount /dev/xvdf1 /mnt/point so this code enabled that --- builder/amazon/chroot/step_mount_device.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/builder/amazon/chroot/step_mount_device.go b/builder/amazon/chroot/step_mount_device.go index a6419774f..3c3d959c1 100644 --- a/builder/amazon/chroot/step_mount_device.go +++ b/builder/amazon/chroot/step_mount_device.go @@ -3,6 +3,7 @@ package chroot import ( "bytes" "fmt" + "github.com/mitchellh/goamz/ec2" "github.com/mitchellh/multistep" "github.com/mitchellh/packer/packer" "log" @@ -26,6 +27,7 @@ type StepMountDevice struct { func (s *StepMountDevice) Run(state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) ui := state.Get("ui").(packer.Ui) + image := state.Get("source_image").(*ec2.Image) device := state.Get("device").(string) wrappedCommand := state.Get("wrappedCommand").(CommandWrapper) @@ -57,10 +59,17 @@ func (s *StepMountDevice) Run(state multistep.StateBag) multistep.StepAction { return multistep.ActionHalt } + log.Printf("Source image virtualization type is: %s", image.VirtualizationType) + deviceMount := device + if image.VirtualizationType == "hvm" { + deviceMount = fmt.Sprintf("%s%d", device, 1) + } + state.Put("deviceMount", deviceMount) + ui.Say("Mounting the root device...") stderr := new(bytes.Buffer) mountCommand, err := wrappedCommand( - fmt.Sprintf("mount %s %s", device, mountPath)) + fmt.Sprintf("mount %s %s", deviceMount, mountPath)) if err != nil { err := fmt.Errorf("Error creating mount command: %s", err) state.Put("error", err)