Failed to create EBS volume

97 views
Skip to first unread message

Tom Wu

unread,
Oct 28, 2016, 4:15:07 PM10/28/16
to Packer
I have the following builders


  "builders": [
    {
      "type": "amazon-ebs",
      "access_key": "{{user `aws_access_key`}}",
      "secret_key": "{{user `aws_secret_key`}}",
      "region": "us-east-1",
      "source_ami": "ami-2d39803a",
      "ssh_pty": true,
      "instance_type": "t2.micro",
      "ssh_username": "ubuntu",
      "ami_block_device_mappings": [
        {
          "device_name": "/dev/sdb",
          "virtual_name": "ephemeral0",
          "volume_size": 100,
          "volume_type": "gp2",
          "delete_on_termination": false
        }
      ],
      "ami_name": "Test {{timestamp}}"
    }
  ]

I am not able to see the volume is being created during a --debug mode and checking the build node

df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            492M   12K  492M   1% /dev
tmpfs           100M  336K   99M   1% /run
/dev/xvda1      7.8G  797M  6.6G  11% /
none            4.0K     0  4.0K   0% /sys/fs/cgroup
none            5.0M     0  5.0M   0% /run/lock
none            497M     0  497M   0% /run/shm
none            100M     0  100M   0% /run/user
root@ip-172-31-57-226:~# lsblk
NAME    MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda    202:0    0   8G  0 disk
└─xvda1 202:1    0   8G  0 part /

Am I using it wrong?

Rickard von Essen

unread,
Oct 28, 2016, 4:16:43 PM10/28/16
to packe...@googlegroups.com

Did you format and mount it?


--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/24d98b91-a6db-411d-bb68-055877a1c155%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tom Wu

unread,
Oct 28, 2016, 10:38:32 PM10/28/16
to Packer
I can't even see it being created, how can I format and mount it?
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.

Alvaro Miranda Aguilera

unread,
Oct 29, 2016, 7:48:58 AM10/29/16
to packe...@googlegroups.com
try higher letters

From memory, I recall sda-sfd (sde?) are reserved.. try sdf or xvdf

and share  ls -al /dev/sd* /dev/xvd*

Alvaro.

To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/899fac3d-db21-43b8-b39c-e9b70e562c92%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Alvaro

Tom Wu

unread,
Oct 30, 2016, 9:47:07 PM10/30/16
to Packer
root@ip-172-31-53-251:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            492M   12K  492M   1% /dev
tmpfs           100M  336K   99M   1% /run
/dev/xvda1      7.8G  796M  6.6G  11% /
none            4.0K     0  4.0K   0% /sys/fs/cgroup
none            5.0M     0  5.0M   0% /run/lock
none            497M     0  497M   0% /run/shm
none            100M     0  100M   0% /run/user
root@ip-172-31-53-251:~# lsblk
NAME    MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda    202:0    0   8G  0 disk
└─xvda1 202:1    0   8G  0 part /
root@ip-172-31-53-251:~# ls -al /dev/sd* /dev/xvd*
ls: cannot access /dev/sd*: No such file or directory
brw-rw---- 1 root disk 202, 0 Oct 31 01:41 /dev/xvda
brw-rw---- 1 root disk 202, 1 Oct 31 01:41 /dev/xvda1



--
Alvaro

Tom Wu

unread,
Oct 30, 2016, 9:48:09 PM10/30/16
to Packer
I used  "device_name": "/dev/xvdf"

Tom Wu

unread,
Oct 31, 2016, 9:30:41 AM10/31/16
to Packer
I think I get it, I expected to have the volume being mounted during bake time, but it actually being created during AMI creation.

My question is what's the best practice of adding volume during the bake/build time, do something about it, then bake root and volumes into AMI?

Tom Wu

unread,
Oct 31, 2016, 9:34:36 AM10/31/16
to Packer
Let me give a more specific use case here

1. Take Default Ubuntu AMI
2. Add block storage
3. Create Volume Group
4. Do something about the Volume Group
5. Install Docker
6. Configure Docker to use the VG
7. Bake the AMI

In AMI, I expect the docker to use devicemapper created from VG during baking process.

Rickard von Essen

unread,
Oct 31, 2016, 9:50:13 AM10/31/16
to Packer
This took me some time to spot but it's quite easy. t2.micro instances are EBS only, you define "virtual_name": "ephemeral0" which is a instance store attached device and volume_type, delete_on_termination which is EBS only options. It feels a bit weird that aws-sdk-go and the AWS api just ignores it.

Rickard von Essen

unread,
Oct 31, 2016, 10:09:41 AM10/31/16
to packe...@googlegroups.com
 I expected to have the volume being mounted during bake time, but it actually being created during AMI creation.

You have ami_block_device_mappings and launch_block_device_mappings, they take the same settings but the first one is created when an instance is launched to bake the ami. The second one is only put into the resulting metadata when the ami is created and will only affect the instance launched from you ami. See the docs.

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/58998108-c39d-4988-978c-7b698da7ae67%40googlegroups.com.

Rickard von Essen

unread,
Oct 31, 2016, 10:12:29 AM10/31/16
to packe...@googlegroups.com
And of course I mean the other way around. ami_block_device_mappings is only put into the resulting metadata when the ami is created and will only affect the instance launched from you ami. launch_block_device_mappings will be available when an instance is launched to bake the ami. 

Tom Wu

unread,
Oct 31, 2016, 10:24:37 AM10/31/16
to Packer
Thanks for helping!

The problem has been resolved, after removing virtual_name , I am able to see xvdl    202:176  0  100G  0 disk

lsblk
NAME    MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
xvda    202:0    0   10G  0 disk
├─xvda1 202:1    0    1M  0 part
└─xvda2 202:2    0   10G  0 part /
xvdf    202:80   0    6G  0 disk
└─xvdf1 202:81   0    6G  0 part /home
xvdg    202:96   0    6G  0 disk
└─xvdg1 202:97   0    6G  0 part /var
xvdh    202:112  0    1G  0 disk
└─xvdh1 202:113  0 1023M  0 part /var/log
xvdi    202:128  0    1G  0 disk
└─xvdi1 202:129  0 1023M  0 part /var/log/audit
xvdj    202:144  0    1G  0 disk
└─xvdj1 202:145  0 1023M  0 part /var/tmp
xvdl    202:176  0  100G  0 disk

 
Here is current config looks like

      "ami_block_device_mappings": [
        {
          "device_name": "/dev/xvdl",
          "volume_size": 100,
          "volume_type": "gp2",
          "delete_on_termination": true
        }
      ],
      "launch_block_device_mappings": [
        {
          "device_name": "/dev/xvdl",
          "volume_size": 100,
          "volume_type": "gp2",
          "delete_on_termination": true
        }
      ],

According to AWS doc, 

VirtualName (request), virtualName (response)

The virtual device name (ephemeralN). Instance store volumes are numbered starting from 0. An instance type with 2 available instance store volumes can specify mappings for ephemeral0 and ephemeral1.The number of available instance store volumes depends on the instance type. After you connect to the instance, you must mount the volume.

Constraints: For M3 instances, you must specify instance store volumes in the block device mapping for the instance. When you launch an M3 instance, we ignore any instance store volumes specified in the block device mapping for the AMI.

Type: String

Required: No


However it would be nice for someone to help me understand why it behaves this way. 

Rickard von Essen

unread,
Oct 31, 2016, 10:34:42 AM10/31/16
to packe...@googlegroups.com
Check http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/block-device-mapping-concepts.html especially the diagram under "Example Block Device Mapping" it explains the difference in naming.

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages