{"id":30007,"date":"2022-05-10T03:36:47","date_gmt":"2022-05-10T03:36:47","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=30007"},"modified":"2022-12-23T05:52:58","modified_gmt":"2022-12-23T05:52:58","slug":"aws-tutorial-how-to-attach-and-mount-an-ebs-volume-to-ec2-linux-instance","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/aws-tutorial-how-to-attach-and-mount-an-ebs-volume-to-ec2-linux-instance\/","title":{"rendered":"AWS Tutorial: How to Attach and Mount an EBS volume to EC2 Linux Instance?"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Step 1 &#8211; Create a Volume<\/h2>\n\n\n\n<h2 class=\"wp-block-heading\">Step 2 &#8211; Attach a Volume to EC2 Instance<\/h2>\n\n\n\n<h2 class=\"wp-block-heading\">Step 3 &#8211; Verify if Volume is attached or not<\/h2>\n\n\n\n<p>Verify if Volume is attached or not by running linux command in Ec2-instance<\/p>\n\n\n\n<p>$ lsblk<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 4 &#8211; Check if the volume has any data using the following command.<\/h2>\n\n\n\n<p>If the above command output shows \u201c\/dev\/xvdf: data\u201c, it means your volume is empty.<\/p>\n\n\n\n<p>$ sudo file -s \/dev\/xvdf<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 5: Format the volume to the ext4 filesystem using the following command.<\/h2>\n\n\n\n<p>Alternatively, you can also use the xfs format. You have to use either ext4 or xfs.<\/p>\n\n\n\n<p>$ sudo mkfs -t ext4 \/dev\/xvdf<br>$ sudo mkfs -t xfs \/dev\/xvdf<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 6: Create a directory of your choice to mount our new ext4 volume. I am using the name \u201cnewvolume\u201c. You can name it something meaningful to you.<\/h2>\n\n\n\n<p>$ sudo mkdir \/newvolume<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 7: Mount the volume to \u201cnewvolume\u201d directory using the following command.<\/h2>\n\n\n\n<p>$ sudo mount \/dev\/xvdf \/newvolume\/<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 8: cd into newvolume directory and check the disk space to validate the volume mount.<\/h2>\n\n\n\n<p>$ cd \/newvolume<br>$ df -h .<\/p>\n\n\n\n<p>The above command should show the free space in the newvolume directory.<br>To unmount the volume, use the unmount command as shown below..<br>umount \/dev\/xvdf<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"mount-one-ebs-volume-to-multiple-ec2-instances\">Mount one EBS volume to Multiple EC2 Instances<\/h2>\n\n\n\n<p>If you have any use case to mount an EBS volume to multiple ec2 instances, you can do it via EBS multi-attach functionality.<\/p>\n\n\n\n<p>This option only serves specific use-cases where multiple machines need to read\/write to the same storage location concurrently.<\/p>\n\n\n\n<p>EBS multi attach option is available only for Provisioned IOPS (PIOPS) EBS volume types.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"661\" height=\"380\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/05\/aws-ebs-multi.png\" alt=\"\" class=\"wp-image-30012\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/05\/aws-ebs-multi.png 661w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/05\/aws-ebs-multi-300x172.png 300w\" sizes=\"auto, (max-width: 661px) 100vw, 661px\" \/><\/figure>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>Note: EBS multi-attach does not support&nbsp;<code>XFS<\/code>,&nbsp;<code>EXT2<\/code>,&nbsp;<code>EXT4<\/code>, and&nbsp;<code>NTFS<\/code>&nbsp;file systems. It supports only cluster-aware file systems.<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Step 1 &#8211; Create a Volume Step 2 &#8211; Attach a Volume to EC2 Instance Step 3 &#8211; Verify if Volume is attached or not Verify if Volume is attached or not by running linux command in Ec2-instance $ lsblk Step 4 &#8211; Check if the volume has any data using the following command. If&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","_joinchat":[],"footnotes":""},"categories":[2],"tags":[],"class_list":["post-30007","post","type-post","status-publish","format-standard","hentry","category-uncategorised"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/30007","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=30007"}],"version-history":[{"count":3,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/30007\/revisions"}],"predecessor-version":[{"id":30013,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/30007\/revisions\/30013"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=30007"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=30007"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=30007"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}