Commit 460e2da2 authored by Peter Sankauskas's avatar Peter Sankauskas

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
parent 6b751cac
...@@ -3,6 +3,7 @@ package chroot ...@@ -3,6 +3,7 @@ package chroot
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"github.com/mitchellh/goamz/ec2"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer" "github.com/mitchellh/packer/packer"
"log" "log"
...@@ -26,6 +27,7 @@ type StepMountDevice struct { ...@@ -26,6 +27,7 @@ type StepMountDevice struct {
func (s *StepMountDevice) Run(state multistep.StateBag) multistep.StepAction { func (s *StepMountDevice) Run(state multistep.StateBag) multistep.StepAction {
config := state.Get("config").(*Config) config := state.Get("config").(*Config)
ui := state.Get("ui").(packer.Ui) ui := state.Get("ui").(packer.Ui)
image := state.Get("source_image").(*ec2.Image)
device := state.Get("device").(string) device := state.Get("device").(string)
wrappedCommand := state.Get("wrappedCommand").(CommandWrapper) wrappedCommand := state.Get("wrappedCommand").(CommandWrapper)
...@@ -57,10 +59,17 @@ func (s *StepMountDevice) Run(state multistep.StateBag) multistep.StepAction { ...@@ -57,10 +59,17 @@ func (s *StepMountDevice) Run(state multistep.StateBag) multistep.StepAction {
return multistep.ActionHalt 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...") ui.Say("Mounting the root device...")
stderr := new(bytes.Buffer) stderr := new(bytes.Buffer)
mountCommand, err := wrappedCommand( mountCommand, err := wrappedCommand(
fmt.Sprintf("mount %s %s", device, mountPath)) fmt.Sprintf("mount %s %s", deviceMount, mountPath))
if err != nil { if err != nil {
err := fmt.Errorf("Error creating mount command: %s", err) err := fmt.Errorf("Error creating mount command: %s", err)
state.Put("error", err) state.Put("error", err)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment