Mounting an EBS volume to an EC2 Linux instance

 In today's blogpost, we'd be looking at how to create a volume and then add or more technically, mount an EBS volume to EC2 Linux instance.

Step 1: Make sure the instance is up and running first. 




Step 2 : Move your cursor, click onto the Elastic Block Store menu on the left pane and click on Volumes. It'd show you the list of volumes that are present.


Step 3 : Click on "Create Volume" in there.

Step 4: Specify the size of the volume and make sure the instance and the EBS volume you're gonna create in the same availability zones.


Step 5: Once you've created the volume, click on "Actions". Under "Actions", select "Attach Volume".




Step 6: Now, from the drop-down menu, select the instance to which you wanna attach the EBS volume to and name the EBS volume according to the convention given there. 



Step 7: Then, connect to your instance. Execute the command "lsblk". You can see that your volume hasn't been mounted yet. (the mountpoint would be empty.)



Step 8: Now to mount the EBS volume, first you need to format the volume with a filesystem type.
            Since we are using Linux here, we'll be formatting it using the ext4 filesystem.
            Type in the command "sudo mkfs -t ext4 <the name of your EBS volume>"




Step 9: Once its done, choose a mountpoint or in simple terms, a directory and then mount the volume                there. To do that, type in the command "sudo mount <the name of the device> <mountpoint>"



Step 10: Now "lsblk" again. You'd find the EBS volume mounted and you're ready to use.




Step 11: Look, I can even create and save a text file.



















Comments