xavier collantes

Mount AWS EBS Volumes on Linux

By Xavier Collantes

Created: 3/28/2024; Updated: 9/1/2025


Amazon Elastic Block Store (EBS) provides persistent block storage for your EC2 instances. This guide walks through the complete process of attaching, formatting, and mounting EBS volumes on Linux systems.

Find Device

Your device name may show up differently than what is specified in AWS console.
sh
1sudo lsblk
2
snippet hosted withby Xavier
My new drive is 200 GB so that's how I know it's the one named nvme1n1.

When submitting request for a drive you can use a uncommon size to identify it easier such as 202 GB instead of 200 GB.

sh
1NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
2nvme1n1      259:0    0   200G  0 disk
3nvme0n1      259:1    0    20G  0 disk
4├─nvme0n1p1  259:3    0  19.9G  0 part /
5├─nvme0n1p14 259:4    0     3M  0 part
6└─nvme0n1p15 259:5    0   124M  0 part /boot/efi
7nvme2n1      259:2    0 419.1G  0 disk
8
snippet hosted withby Xavier

See If EBS Must Be Formatted

This determines if the drive has already been initialized. If the EBS volume was created independently from the EC2 instance creation, it will need to be formatted like a new drive.

Get information about a specific device, such as its file system type.

sh
1# If the output shows simply `data`, as in the following example output,
2# there is no file system on the device.
3sudo file -s /dev/<DRIVE NAME>
4# /dev/xvdf: data -> No filesystem.
5# /dev/xvda1: SGI XFS filesystem data (blksz 4096, inosz 512, v2 dirs) -> Has filesystem.
6
Get information about a specific device, such as its file system type. hosted withby Xavier

Mount The Drive

Create a point where the drive can be accessed:
sh
1sudo mkdir /<DIR ACCESS POINT>
2
snippet hosted withby Xavier
Mount the drive at the access point directory:
sh
1sudo mount /dev/<DRIVE NAME> /<DIR ACCESS POINT>
2
snippet hosted withby Xavier

Automatically Mount An Attached Volume After Reboot

Create backup of file you will edit:
sh
1sudo cp /etc/fstab /etc/fstab.orig
2
snippet hosted withby Xavier
Find the UUID of the device:
sh
1sudo blkid
2
snippet hosted withby Xavier
Add UUID for device to persist through reboots:

UUID is for specific EBS volume.

sh
1echo "UUID=bcfa0792-edbe-49d5-af46-97cb341c0f23 /<MOUNT DIR>   xfs  defaults,nofail  0  2" | sudo tee --append /etc/fstab
2df -h
3
UUID is for specific EBS volume. hosted withby Xavier

Verify The fstab Entry Works!!! Or Risk Destroying Your Machine

To verify that your entry works, run the following commands to unmount the device and then mount all file systems in /etc/fstab. If there are no errors, the /etc/fstab file is correct and your file system will mount automatically after reboot.

Errors in the `/etc/fstab` file can render a system unbootable. Do not shut down a system that has errors in the `/etc/fstab` file.

If you are unsure how to correct errors in /etc/fstab and created a backup file in the first step, you can restore from your backup using the following command.
sh
1sudo umount /<DIR ACCESS POINT>
2sudo mount -a  # MAKE SURE NO ERRORS SHOW!!!!!!!!!!
3ls -l /<DIR ACCESS POINT>
4
snippet hosted withby Xavier

Formatting New EBS Drive

Do not use this command if you are mounting a volume that already has data on it (for example, a volume that was created from a snapshot). Otherwise, you will format the volume and delete the existing data.

sh
1sudo mkfs -t xfs /dev/<DRIVE NAME>
2
3# If you get an error that `mkfs.xfs` is not found, use the following command to install the XFS tools and then repeat the previous command:
4sudo apt-get install xfsprogs -y
5
snippet hosted withby Xavier

Related Articles

Related by topics:

devops
infrastructure
cloud
aws
Docker Image Storage Options

Comparison of Docker Hub, AWS ECR, Google Artifact Registry with my experience.

By Xavier Collantes1/25/2025
docker
devops
infrastructure
+5

HomeFeedback