Print

While Amazon Web Services (AWS) provides allot of services and administrative capabilities thru their Console web application, you still have to do some things manually.

 After creating a EC2 instance, you may want to attach additional storage.  The additional storage can be used to host your application independent of the OS/root partition, allowing you to more easily migrate, backup, and manage your application and it's data.

 After creating the additional storage and attaching the volume to your EC2 instance, you still need to tell the OS on the EC2 about the extra storage, which is where this tutorial comes into play.

 

Mount attached volume 

List partitions via lsblk, which lists information about all available or the specified block devices
> sudo lsblk
NAME        MAJ:MIN RM SIZE RO TYPE MOUNTPOINT

nvme1n1     259:0    0  50G  0 disk            <- no mount point
nvme0n1     259:1    0  16G  0 disk
├─nvme0n1p1 259:2    0   1M  0 part
└─nvme0n1p2 259:3    0  16G  0 part /

nvme0n1
Is the OS/root partition 

nvme1n1     
Is the external attached volume 

Verify that there is no data on the partition
> sudo file -s /dev/nvme1n1

Response if no file system thus no data
/dev/nvme1n1: data

Response if the partition has already been formatted
/dev/nvme1n1: SGI XFS filesystem data

If no data, create a file system
> sudo mkfs -t xfs /dev/nvme1n1 

Make the mount directory, which can be any name, but `data` is generic enough
> sudo mkdir /data

Mount the partition to the directory
> sudo mount /dev/nvme1n1 /data

Edit fstab to mount on boot
fstab defines your volumes and mount points at boot, so make a copy first
> sudo cp /etc/fstab /etc/fstab.orig 

Find the UUID of device, which will be used in fstab to identity the volume
> sudo blkid 

Edit fstab; Use your UUID; match existing entry spacing
the option nofail allows the boot sequence to continue even if the drive fails to mount
> sudo vi /etc/fstab
UUID=123ebf5a-8c9b-1234-1234-1234f6f6ff30 /data      xfs     defaults,nofail 0 2 

To verify the fstab configuration works, without rebooting, unmount and then auto mount the volume
> sudo umount /data> sudo mount -a

List partitions, and you will see your data directory, which you can now utilize
> lsblk
NAME        MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
nvme1n1     259:0    0  50G  0 disk /data      <- it worked
nvme0n1     259:1    0  16G  0 disk
├─nvme0n1p1 259:2    0   1M  0 part
└─nvme0n1p2 259:3    0  16G  0 part /

> ls -l /data

-End of Document-
Thanks for reading