I am using EC2 Image Builder Service to build golden AMIs.
Use Case :
I want to attach additional EBS volume in the instance and there i will do all the installation of third party components and store everything there rather than doing everything to my root device. Thereafter i want to build the AMI for the same and so i am currently using EC2 Image Builder Service.
Problem Statement :
I want to mount an additional EBS volume to instance(which is building AMI). To achieve that i have included mounting
device commands and included them in custom build component.
name: DeployComponents
description: This is to deploycomponents.
schemaVersion: 1.0
phases:
- name: build
steps:
- name: DeploymentStep
action: ExecuteBash
inputs:
commands:
- echo "Attaching Additional EBS Volume."
- lsblk
- sudo useradd -m abc -p abc
- sudo groupadd cloud
- sudo usermod -a -G cloud cloud
- sudo umount -f /dev/sdb
- sudo mkfs -t ext4 /dev/sdb
- sudo mkdir /cloud
- mount /dev/sdb /cloud
- echo /dev/sdb /cloud ext4 defaults,nofail 0 2 >> /etc/fstab
- sed -i 's+/opt/mount1+/cloud+' /etc/fstab
- sudo chown -R cloud:cloud /cloud
Also included the same device in the recipe i.e. /dev/sdb
.
When i look at the EC2 Image Builder logs then i am seeing this :
Logs :
umount: /dev/sdb: mountpoint not found
mke2fs 1.42.9 (28-Dec-2013)
Could not stat /dev/sdb --- No such file or directory
The device apparently does not exist; did you specify it correctly?
mount: special device /dev/sdb does not exist
umount: /dev/sdb: mountpoint not found
mke2fs 1.42.9 (28-Dec-2013)
Could not stat /dev/sdb --- No such file or directory
The device apparently does not exist; did you specify it correctly?
mount: special device /dev/sdb does not exist
What am i missing ?
Any help is appreciated.
Many Thanks in Advance.