Skip to content

Instantly share code, notes, and snippets.

@stonegray
Created May 12, 2020 13:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stonegray/75a7f6cc55408a24cd67bf6f459f99ac to your computer and use it in GitHub Desktop.
Save stonegray/75a7f6cc55408a24cd67bf6f459f99ac to your computer and use it in GitHub Desktop.
Bash get AWS EC2 NVMe storage device name

There's no immedialy obvious way to determine which block device is definitely an AWS ephemeral storage device, so this quick snippet will grab it.

No error checking, so if you don't actually have an ephemeral storage device it will return the string "/dev/".

EPHEMERAL_STORAGE=/dev/$(lsblk -o +MODEL |grep "EC2 NVMe Instance Storage" | sed "s/ .*//")
# Get ephemereral storage device by block model data:
EPHEMERAL_STORAGE=/dev/$(\
  lsblk -o +MODEL |\
  grep "EC2 NVMe Instance Storage" |\
  sed "s/ .*//" \
)

Licence: do whatever, no warranty, as-is. If your org has a strict OSS policy, then it's MIT licenced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment