Configuring a raw EBS volume on EC2

Originally posted on 2020-10-23

I added a big EBS volume to my EC2 instance to deal with Dropbox telling me it couldn't sync because my disk was too small. So I created a massive EBS volume, let it do the initial sync, and then moved the synced volume back to my original disk.

Run parted (NOTE: your disk name may be different):

sudo parted /dev/nvme1n1

Figure out how much space is free:

(parted) unit MB print free                                               
Model: Amazon Elastic Block Store (nvme)
Disk /dev/nvme1n1: 1717987MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End        Size       File system  Name  Flags
        0.02MB  1717987MB  1717987MB  Free Space

Create a new primary, ext4 partition with that info and ignore the performance warning:

(parted) mkpart primary ext4 0 1717987
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? i

Quit with the quit command and run lsblk:

(parted) quit
$ lsblk
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
loop0         7:0    0 12.7M  1 loop /snap/amazon-ssm-agent/495
loop1         7:1    0 87.9M  1 loop /snap/core/5328
loop2         7:2    0 97.8M  1 loop /snap/core/10185
loop3         7:3    0 28.1M  1 loop /snap/amazon-ssm-agent/2012
nvme0n1     259:0    0  100G  0 disk 
└─nvme0n1p1 259:1    0  100G  0 part /
nvme1n1     259:2    0  1.6T  0 disk 
└─nvme1n1p1 259:4    0  1.6T  0 part

Format the partition:

sudo mkfs.ext4 /dev/nvme1n1p1

Mount it:

sudo mkdir -p /mnt/bigdisk
sudo mount /dev/nvme1n1p1 /mnt/bigdisk