Troubleshooting block device mappings:

I’d like to understand more about what to do when you need to increase a block device size for a build. I have some examples that work successfully with ubuntu 18, and centos 7 that I use, but it seems like each time I’m in a slightly new scenario the old techniques don’t apply, and that is probably due to a gap in my knowledge of what is required.

Building an AMI with NICE DCV (remote display):

name: DCV-AmazonLinux2-2020-2-9662-NVIDIA-450-89-x86_64

I tried this in my packer template:

  launch_block_device_mappings {
    device_name           = "/dev/sda1"
    volume_size           = 16
    volume_type           = "gp2"
    delete_on_termination = true
  }

But then ssh never became available. I reverted to not doing any customisation, and took a look at the mounts:

[ec2-user@ip-172-31-39-29 ~]$ df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        482M     0  482M   0% /dev
tmpfs           492M     0  492M   0% /dev/shm
tmpfs           492M  740K  491M   1% /run
tmpfs           492M     0  492M   0% /sys/fs/cgroup
/dev/xvda1      8.0G  4.4G  3.7G  55% /
tmpfs            99M  8.0K   99M   1% /run/user/42
tmpfs            99M     0   99M   0% /run/user/1000

So I thought I should try this instead (which didn’t work):

  launch_block_device_mappings {
    device_name           = "/dev/xvda1"
    volume_size           = 20
    volume_type           = "gp2"
    delete_on_termination = true
  }

which resulted in these errors:

==> amazon-ebs.amazonlinux2-nicedcv-nvidia-ami: Authorizing access to port 22 from [0.0.0.0/0] in the temporary security groups...
==> amazon-ebs.amazonlinux2-nicedcv-nvidia-ami: Launching a source AWS instance...
==> amazon-ebs.amazonlinux2-nicedcv-nvidia-ami: Adding tags to source instance
    amazon-ebs.amazonlinux2-nicedcv-nvidia-ami: Adding tag: "Name": "Packer Builder"
==> amazon-ebs.amazonlinux2-nicedcv-nvidia-ami: Error launching source instance: InvalidBlockDeviceMapping: Invalid device name /dev/xvda1
==> amazon-ebs.amazonlinux2-nicedcv-nvidia-ami:         status code: 400, request id: 2c419989-dd53-48ef-bcb6-6e54e892d152
==> amazon-ebs.amazonlinux2-nicedcv-nvidia-ami: No volumes to clean up, skipping
==> amazon-ebs.amazonlinux2-nicedcv-nvidia-ami: Deleting temporary security group...
==> amazon-ebs.amazonlinux2-nicedcv-nvidia-ami: Deleting temporary keypair...
Build 'amazon-ebs.amazonlinux2-nicedcv-nvidia-ami' errored after 1 second 820 milliseconds: Error launching source instance: InvalidBlockDeviceMapping: Invalid device name /dev/xvda1
        status code: 400, request id: 2c419989-dd53-48ef-bcb6-6e54e892d152

Would anyone be able to share some pointers on what I’d need to do to increase the volume size in this instance and why?