0

I want to attach and mount already created and populated EBS volume with Ec2 instances with remote scripts (from Jenkins). I've tried the following,

aws ec2 attach-volume --device $deviceName --region $regionId --instance-id $instanceId --volume-id $volumeId

Once it is attached, I want to mount the volume inside EC2.

After ssh-ing into the instance, doing this,

sudo mount /dev/$deviceName /data

But this won't work as AWS renames volume device name. So, I need some kind of hacking solution to get the actual volume device id and mount it.

Will this below approach work?

lsblk --noheadings --raw -o NAME,MOUNTPOINT | awk '$1~/[[:digit:]]/ && $2 == ""

Then go through each name and get the original mapped device name by this.

sudo /sbin/ebsnvme-id /dev/$deviceId

What is the approach to mount EBS volume from remote scripts given that AWS renames volume device id?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.