# AWS NVME Notes In the nitro-based instances (m5, i3en, etc), AWS presents all drives as NVMe volumes. This provides better I/O performance, but can make life complicated when mapping drives from the terraform or web console to the device the machine actually sees. ## Determining EBS Mapping The EBS mapping is stored in the NVMe metadata. You can grab it by running: ``` nvme id-ctrl --raw-binary /dev/nvmXXX | cut -c 3073-3104 | sed 's/ //g' ``` ## Useful Scripts ### /usr/local/bin/ebs-nvme-mapping: ``` #!/bin/bash # # Creates symbolic links from the nvme drives to /dev/sdX or /dev/xvdX. # This may not be compatible with instances that have local storage, such # as i3's PATH="${PATH}:/usr/sbin" for blkdev in $( nvme list | awk '/^\/dev/ { print $1 }' ) ; do mapping=$(nvme id-ctrl --raw-binary "${blkdev}" 2>/dev/null | cut -c3073-3104 | sed 's/ //g') if [[ "${mapping}" == xvd* ]]; then ( test -b "${blkdev}" && test -L "/dev/${mapping}" ) || ln -s "${blkdev}" "/dev/${mapping}" for partition in $( ls -1 ${blkdev}p* 2> /dev/null ) ; do ln -s ${partition} /dev/${mapping}${partition/${blkdev}p/} done fi done ``` ### /root/cf/define_logical_volume.sh: ``` #!/bin/bash # # Provides a simple way to create and format logical volumes for # nitro-based AWS instances based off their configured mount point. # NOTE: It does not create the fstab entry # # Syntax: define_logical_volume.sh