Log in to your EC2 Instance.
List the available disks using the following command:
lsblk
The output will list the disks attached to your instance.
NOTE: Depending on the Linux version and the machine type, the device names may differ. The EC2 Console will generally show /dev/sdX, where X is a lower-case letter, but you may see /dev/xvdX or /dev/nvmeYn1. The following table may help with translating. Another way to help track is to pick different sizes for your EBS volumes (such as 151, 152, 153 GB for different volumes).
Device name (Console) | Alternate 1 | Alternate 2 |
---|---|---|
/dev/sda | /dev/xvda | /dev/nvme0n1 |
/dev/sdb | /dev/xvdb | /dev/nvme1n1 |
/dev/sdc | /dev/xvdc | /dev/nvme2n1 |
/dev/sdd | /dev/xvdd | /dev/nvme3n1 |
/dev/sde | /dev/xvde | /dev/nvme4n1 |
/dev/sdf | /dev/xvdf | /dev/nvme5n1 |
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
nvme0n1 259:0 0 150G 0 disk
└─nvme0n1p1 259:1 0 150G 0 part /
nvme1n1 259:2 0 10G 0 disk
sudo file -s /dev/nvme1n1
Where “nvme1n1” is the device you noted from the previous section after attaching the device to the EC2 Instance.
If the above command output shows "/dev/nvme1n1: data", it means your volume is empty.
sudo mkfs -t ext4 /dev/nvme1n1
NOTE: This file-system formatting step is only for a new device, DO NOT run this step while mounting an existing volume as it will wipe out all data on the device.
sudo mkdir /mnt/volume1
sudo mount /dev/nvme1n1 /mnt/volume1
cd /mnt/volume1
df -h .
The above command would show the free space in the volume1 directory.
sudo chown -R ubuntu /mnt/volume1
sudo umount /dev/nvme1n1
But we’ll need this device for later, so remember to re-mount it.
sudo mount /dev/nvme1n1 /mnt/volume1