Prepare mount volume

First you need to create a volume and attach it to an existing ec2 instance on AWS console.

Mount volume to ec2

ssh to ec2, check volume with command sudo fdisk -l

This is the 100GB volume you just attached.

format it with command sudo mkfs.ext4 /dev/nvme1n1

Then mount it to your expected path

sudo mount /dev/nvme1n1 /var/lib/docker

(e.g. /var/lib/docker)

Mount volume automaticly after reboot

Above way of mount point will lost after reboot. You might need a solution to mount volume automaticly after every reboot.

You need to change /etc/fstab, so you should keep a backup sudo cp /etc/fstab /etc/fstab.orig

Then check volume UUID with command sudo blkid

Edit fstab sudo vim /etc/fstab

Append UUID=f74db2e5-575d-427c-a907-d3167a273b52 /var/lib/docker ext4 defaults,nofail 0 2

Check validity

sudo umount /var/lib/docker
sudo mount -a
df -h

If you can see 100GB mount point as following figure, then it’ll works on every reboot.


Making an Amazon EBS Volume Available for Use on Linux

Automatically Mount an Attached Volume After Reboot


在Amazon EC2中挂载EBS作为永久存储