forked from coreos/fedora-coreos-config
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Working on as part of coreos/fedora-coreos-tracker#104 (comment).
The script is from Container Linux: coreos/fedora-coreos-tracker#104 (comment), I changed it and tested to make sure it works on fcos.
- Loading branch information
Showing
2 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Copyright (c) 2020 The CoreOS Authors. All rights reserved. | ||
# Use of this source code is governed by a BSD-style license that can be | ||
# found in the LICENSE file. | ||
|
||
usage() { | ||
echo "Usage: $0 [-d|-p|-h] <device>" 1>&2 | ||
} | ||
|
||
# Get partition ID from device name, e.g. '/dev/nvme0n1p2' -> '1' | ||
namespace_id() { | ||
NSID=$(echo -n "$1" | cut -f 3 -d 'n' | cut -f 1 -d 'p') | ||
echo "_NS_ID=${NSID}" | ||
} | ||
|
||
# Get device name from raw metadata, | ||
devname() { | ||
RAWVOL=$(nvme id-ctrl --raw-binary "$1" | cut -c3073-3104 | tr -s ' ' | sed 's/ $//g') | ||
VOL="${RAWVOL#/dev/}" | ||
if [[ -n "$VOL" ]]; then | ||
echo "${VOL}" | ||
else | ||
exit 1 | ||
fi | ||
} | ||
|
||
while getopts "hd:n:" o; do | ||
case "${o}" in | ||
d) | ||
devname "${OPTARG}" | ||
exit 0 | ||
;; | ||
n) | ||
namespace_id "${OPTARG}" | ||
exit 0 | ||
;; | ||
h) | ||
usage | ||
exit 0 | ||
;; | ||
*) | ||
usage | ||
exit 1 | ||
;; | ||
esac | ||
done |
14 changes: 14 additions & 0 deletions
14
overlay.d/05core/usr/lib/udev/rules.d/70-aws-ebs-nvme-id.rules
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#AWS EBS NVMe | ||
ACTION!="add|change", GOTO="aws_ebs_nvme_end" | ||
SUBSYSTEM!="block", GOTO="aws_ebs_nvme_end" | ||
|
||
# NVMe devices | ||
KERNEL=="nvme[0-9]*n[0-9]*", ENV{DEVTYPE}=="disk", ATTRS{model}=="Amazon Elastic Block Store", ATTRS{serial}=="?*", SYMLINK+="disk/by-id/nvme-$attr{model}_$attr{serial}-ns-%n", OPTIONS+="string_escape=replace" | ||
KERNEL=="nvme[0-9]*n[0-9]*", ENV{DEVTYPE}=="disk", ATTRS{model}=="Amazon Elastic Block Store", ATTRS{serial}=="?*", PROGRAM="/usr/lib/udev/bin/aws-ebs-nvme-id -d /dev/%k", SYMLINK+="%c" | ||
|
||
# NVMe partitions | ||
KERNEL=="nvme[0-9]*n[0-9]*p[0-9]*", ENV{DEVTYPE}=="partition", ATTRS{model}=="Amazon Elastic Block Store", ATTRS{serial}=="?*", IMPORT{program}="/usr/lib/udev/bin/aws-ebs-nvme-id -d /dev/%k" | ||
KERNEL=="nvme[0-9]*n[0-9]*p[0-9]*", ENV{DEVTYPE}=="partition", ATTRS{model}=="Amazon Elastic Block Store", ATTRS{serial}=="?*", ENV{_NS_ID}=="?*", SYMLINK+="disk/by-id/nvme-$attr{model}_$attr{serial}-ns-$env{_NS_ID}-part%n", OPTIONS+="string_escape=replace" | ||
KERNEL=="nvme[0-9]*n[0-9]*p[0-9]*", ENV{DEVTYPE}=="partition", ATTRS{model}=="Amazon Elastic Block Store", ATTRS{serial}=="?*", ENV{_NS_ID}=="?*", PROGRAM="/usr/lib/udev/bin/aws-ebs-nvme-id -d /dev/%k", SYMLINK+="%c%n" | ||
|
||
LABEL="aws_ebs_nvme_end" |