Here's my problem - I'm using Hashicorp terraform to programmatically set up an Amazon c5 EC2 instance that has a couple of attached EBS drives. The c5 instances use nvme and end up remapping the names I assign in terraform (e.g. /dev/sdf) to nvme names (e.g. /dev/nvme1n1). The problem is that the mapping doesn't appear to be consistent. Upon reboot the drives sometimes get mapped in a different order. This means that my /etc/fstab which specifies /dev/nvme1n1 gets one drive one time and a different drive the next.
One solution to this is to use the UUID in the /etc/fstab file. This works fine, and I can get the UUID using ls -al /dev/disk/by-uuid/
, however htis is a very clumsy process to automate.
Is there a way to just get the UUID directly from terraform so that I can put that in the fstab directly rather than having to do it by hand after the fact (or write a special script to automate this)?
I experienced this problem today. I'm not using terraform. Also, I was unable to solve the problem using UUIDs. Instead, I solved it by setting a label on the file system. You can do this with e2label (for ext*) or xfs_admin (for xfs). Once you have the label set, you can update your fstab to use the device path /dev/disk/by-label/<label>
.
If you're creating your volume from an AWS provided snapshot, you'll need to manually: