To create an EBS volume, attach it to an EC2 instance, and perform disk partitioning using fdisk.
- AWS account
- Running EC2 instance (Linux)
- SSH access to the instance
-
Go to AWS Console → EC2 → Elastic Block Store → Volumes
-
Click Create Volume
-
Configure:
- Volume type:
gp3(recommended) - Size: e.g.,
10 GiB - Availability Zone: Same as EC2 instance
- Volume type:
-
Click Create Volume
-
Select the created volume
-
Click Actions → Attach Volume
-
Choose your EC2 instance
-
Set device name (example):
/dev/xvdbb -
Click Attach
ssh -i your-key.pem ec2-user@your-public-ipCheck available disks:
lsblkor
sudo fdisk -lYou should see something like:
/dev/xvdbb 10G
Start fdisk:
sudo fdisk /dev/xvdbb-
Create new partition:
n -
Choose partition type:
p (primary) -
Partition number:
1 -
Press Enter for default first sector
-
Press Enter for default last sector
-
Save changes:
w
lsblkOutput will show:
/dev/xvdbb1
Format using ext4:
sudo mkfs.ext4 /dev/xvdbb1sudo mkdir /datasudo mount /dev/xvdbb1 /dataVerify:
df -hGet UUID:
sudo blkidEdit fstab:
sudo vi /etc/fstabAdd entry:
UUID=xxxx-xxxx /data ext4 defaults,nofail 0 2
Save and test:
sudo mount -a- EBS volume successfully created and attached
- Disk partition created using
fdisk - File system created and mounted
- Device name may appear as
/dev/nvme1n1in newer instances (NVMe-based) - Always ensure correct device before partitioning to avoid data loss