Creating and attaching an EBS volume involves three stages: creating the volume in the same Availability Zone as your EC2 instance, attaching it via the Console or CLI, and then mounting and formatting it inside the OS of the running instance.
Attaching an EBS volume to an EC2 instance is a two-part process. The AWS side (creating and attaching the volume) makes the block device available to the instance, but the OS side (formatting and mounting) is what makes it usable. Both parts are required before you can read or write data to the volume.
Step 1 — Create the EBS volume in the SAME Availability Zone as the target EC2 instance
Step 2 — Attach the volume to the EC2 instance using the Console or CLI (assigns a device name like /dev/sdf)
Step 3 — SSH into the EC2 instance
Step 4 — Use lsblk or fdisk -l to verify the new device is visible
Step 5 — Format the volume with a file system (mkfs.ext4 or mkfs.xfs)
Step 6 — Create a mount point directory (mkdir /data)
Step 7 — Mount the volume (mount /dev/xvdf /data)
Step 8 — (Optional but recommended) Add to /etc/fstab for automatic remounting on reboot
The device name you specify (/dev/sdf) may appear as /dev/xvdf or /dev/nvme1n1 inside the OS depending on the instance type
NVMe-based instances (Nitro) show volumes as /dev/nvme1n1, /dev/nvme2n1, etc.
Always use UUID in /etc/fstab instead of device names like /dev/xvdf — device names can change on reboot
The nofail option in /etc/fstab prevents boot failures if the EBS volume is not attached
You can attach up to 27 EBS volumes to a single EC2 instance (Nitro-based instances support more)
After increasing a volume's size (Elastic Volumes), you must resize the file system: sudo resize2fs /dev/xvdf for ext4 or sudo xfs_growfs /data for XFS