{"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":"2026-07-04T05:57:41","modified_gmt":"2026-07-04T05:57:41","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 class=\"wp-block-paragraph\">Verify if Volume is attached or not by running linux command in Ec2-instance<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">$ 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 class=\"wp-block-paragraph\">If the above command output shows \u201c\/dev\/xvdf: data\u201c, it means your volume is empty.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">$ sudo file -s \/dev\/xvdf\n\nubuntu@ip-172-31-3-136:~$ lsblk\nNAME         MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS\nloop0          7:0    0   74M  1 loop \/snap\/core22\/2411\nloop1          7:1    0 28.2M  1 loop \/snap\/amazon-ssm-agent\/13009\nloop2          7:2    0 28.4M  1 loop \/snap\/amazon-ssm-agent\/13349\nloop3          7:3    0 49.3M  1 loop \/snap\/snapd\/26865\nnvme0n1      259:0    0    8G  0 disk \n\u251c\u2500nvme0n1p1  259:1    0  6.9G  0 part \/\n\u251c\u2500nvme0n1p13 259:2    0 1023M  0 part \/boot\n\u251c\u2500nvme0n1p14 259:3    0    4M  0 part \n\u2514\u2500nvme0n1p15 259:4    0  106M  0 part \/boot\/efi\nnvme1n1      259:5    0    5G  0 disk \nubuntu@ip-172-31-3-136:~$ sudo file -s \/dev\/nvme1n1\n\/dev\/nvme1n1: data\nubuntu@ip-172-31-3-136:~$ \n\n<\/code><\/span><\/pre>\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 class=\"wp-block-paragraph\">Alternatively, you can also use the xfs format. You have to use either ext4 or xfs.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">$ 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 class=\"wp-block-paragraph\">$ 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 class=\"wp-block-paragraph\">$ 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 class=\"wp-block-paragraph\">$ cd \/newvolume<br>$ df -h .<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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 id=\"mount-one-ebs-volume-to-multiple-ec2-instances\" class=\"wp-block-heading\">Mount one EBS volume to Multiple EC2 Instances<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">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 class=\"wp-block-paragraph\">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 class=\"wp-block-paragraph\">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\">\n<p class=\"wp-block-paragraph\">Note: EBS multi-attach does not support\u00a0<code>XFS<\/code>,\u00a0<code>EXT2<\/code>,\u00a0<code>EXT4<\/code>, and\u00a0<code>NTFS<\/code>\u00a0file systems. It supports only cluster-aware file systems.<\/p>\n<\/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&#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_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":4,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/30007\/revisions"}],"predecessor-version":[{"id":77373,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/30007\/revisions\/77373"}],"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}]}}