Setting this in ami_block_device_mappings makes your custom AMI come with a
40 GB root device but the instance launched by packer has the standard 8
GB. Example:
[...]
amazon-ebs: Debian GNU/Linux 8 (jessie)
amazon-ebs: Filesystem Size Used Avail Use% Mounted on [df -h]
amazon-ebs: /dev/xvda2 7.8G 819M 6.6G 11% /
amazon-ebs: udev 10M 0 10M 0% /dev
amazon-ebs: tmpfs 200M 4.2M 196M 3% /run
amazon-ebs: tmpfs 500M 0 500M 0% /dev/shm
amazon-ebs: tmpfs 5.0M 0 5.0M 0% /run/lock
amazon-ebs: tmpfs 500M 0 500M 0% /sys/fs/cgroup
amazon-ebs: NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT [lsblk]
amazon-ebs: xvda 202:0 0 8G 0 disk
amazon-ebs: ├─xvda1 202:1 0 1007.5K 0 part
amazon-ebs: └─xvda2 202:2 0 8G 0 part /
[...]
aws ec2 describe-images --image-ids <ami-id> --query 'Images[0].
BlockDeviceMappings[0]'
{
"DeviceName": "/dev/xvda",
"Ebs": {
"Encrypted": false,
"DeleteOnTermination": true,
"VolumeType": "standard",
"VolumeSize": 40,
"SnapshotId": "snap-04aa234cd2128d60a"
}
}
While setting this in launch_block_device_mappins changes the device also
for the instance packer launches for provisioning and since that is what is
captured in your custom AMI that will have 40 GB too.
Example:
[...]
amazon-ebs: Debian GNU/Linux 8 (jessie)
amazon-ebs: Filesystem Size Used Avail Use% Mounted on [df -h]
amazon-ebs: /dev/xvda2 40G 825M 37G 3% /
amazon-ebs: udev 10M 0 10M 0% /dev
amazon-ebs: tmpfs 200M 4.2M 196M 3% /run
amazon-ebs: tmpfs 500M 0 500M 0% /dev/shm
amazon-ebs: tmpfs 5.0M 0 5.0M 0% /run/lock
amazon-ebs: tmpfs 500M 0 500M 0% /sys/fs/cgroup
amazon-ebs: NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT [lsblk]
amazon-ebs: xvda 202:0 0 40G 0 disk
amazon-ebs: ├─xvda1 202:1 0 1007.5K 0 part
amazon-ebs: └─xvda2 202:2 0 40G 0 part /
[...]
aws ec2 describe-images --image-ids <ami-id> --query
'Images[0].BlockDeviceMappings[0]'
{
"DeviceName": "/dev/xvda",
"Ebs": {
"Encrypted": false,
"DeleteOnTermination": true,
"VolumeType": "standard",
"VolumeSize": 40,
"SnapshotId": "snap-0132901385c9a556d"
}
}
Hope that makes it clear.
On 17 August 2017 at 23:49, <[email protected]> wrote:
> Hi,
>
> Really sorry to be asking this because I can see there are previous
> threads, e.g. "Configuring size of root volume on EC2" but they actually
> don't provide a clear answer and neither do the docs.
>
> I'm building an AMI using the amazon-ebs builder. The reference AMI is a
> Debian stretch image with an 8GB root volume. The source images use
> /dev/xvda1 as the root partition.
>
> I'd like my packer image to have a much larger volume, e.g. 40GB. Previous
> threads indicate this should be possible by adding:
>
> "ami_block_device_mappings": [ {
> "device_name": "/dev/xvda",
> "volume_size": 40,
> "delete_on_termination": true
> } ],
> "launch_block_device_mappings": [ {
> "device_name": "/dev/xvda",
> "volume_size": 40,
> "delete_on_termination": true
> } ]
>
> It's not clear to me what the distinction between
> ami_block_device_mappings and launch_block_device_mappings is. What what I
> understand of the docs they should be used when I want to add additional
> devices beyond the root vol, but the discussion in the other thread
> suggests using the code above is used to modify the root volume size.
>
> I don't fully understand what it's doing, but more to the point, I can't
> make it work.
>
> The reference image boots from /dev/xvda1, so presumably I need
>
> "device_name": "/dev/xvda"
>
>
> but that throws this error:
>
> The device 'xvda' is used in more than one block-device mapping
>
> So, what device should I use is the source AMI is using /dev/xvda1 as root
> partition and what the difference between the two mappings?
>
> (I know I may need to deal with fs resize, but I'll get to that when it's
> a problem)
>
> Many Thanks,
>
> Rich
>
> --
> 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 [email protected].
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/packer-tool/ea501630-7e60-43aa-a543-cb60f90cbaa5%40googlegroups.com
> <https://groups.google.com/d/msgid/packer-tool/ea501630-7e60-43aa-a543-cb60f90cbaa5%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/packer-tool/CALz9Rt80aHr7wOchS1i06iReBnkq2pFbrenn171kdR0M6bOx%2Bw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.