Skip to content

Instantly share code, notes, and snippets.

View JJC1138's full-sized avatar

Jon Colverson JJC1138

View GitHub Profile
@JJC1138
JJC1138 / list-ec2-nvme-instance-storage-devices.sh
Created April 22, 2019 06:53
Shell script to list all NVMe Instance Storage Devices on an EC2 instance
#!/bin/bash -e
for nvme_device_name in `lsblk | cut --delimiter=" " --fields=1 | grep ^nvme | sort -n`; do
nvme_device="/dev/${nvme_device_name}"
if ( nvme id-ctrl "${nvme_device}" | grep --quiet "^mn\\s*:\\s*Amazon EC2 NVMe Instance Storage\\s*$" ); then
echo "${nvme_device}"
fi
done
fileprivate extension Array {
func filterIntoTrueAndFalse(_ shouldBeIncludedInFirstResult: (Element) throws -> Bool) rethrows -> ([Element], [Element]) {
var trueResults = [Element]()
var falseResults = [Element]()
for i in self {
if try shouldBeIncludedInFirstResult(i) {
trueResults.append(i)
} else {
falseResults.append(i)

Keybase proof

I hereby claim:

  • I am jjc1138 on github.
  • I am jjc1138 (https://keybase.io/jjc1138) on keybase.
  • I have a public key whose fingerprint is 04F1 3A87 F4B0 1A4A 614D E539 7287 96CB FA8A 09DB

To claim this, I am signing this object: