Skip to content

Instantly share code, notes, and snippets.

@jalaziz
Last active September 20, 2024 09:18
Show Gist options
  • Save jalaziz/bcfe2f71e3f7e8fe42a9c294c1e9279f to your computer and use it in GitHub Desktop.
Save jalaziz/bcfe2f71e3f7e8fe42a9c294c1e9279f to your computer and use it in GitHub Desktop.

Revisions

  1. jalaziz revised this gist Oct 21, 2019. 2 changed files with 2 additions and 3 deletions.
    4 changes: 1 addition & 3 deletions ebs-nvme-udev-trigger.service
    Original file line number Diff line number Diff line change
    @@ -1,12 +1,10 @@
    [Unit]
    Description=Reload AWS EBS NVMe rules
    Requires=coreos-setup-environment.service
    After=coreos-setup-environment.service
    Before=user-config.target
    DefaultDependencies=no
    [Service]
    Type=oneshot
    RemainAfterExit=yes
    EnvironmentFile=-/etc/environment
    ExecStart=/usr/bin/udevadm control --reload-rules
    ExecStart=/usr/bin/udevadm trigger -y "nvme[0-9]*n[0-9]*"
    ExecStart=/usr/bin/udevadm settle
    1 change: 1 addition & 0 deletions format-dev-xvdb.service
    Original file line number Diff line number Diff line change
    @@ -3,6 +3,7 @@ Description=Formats /dev/xvdb
    Before=dbus.service docker.service
    After=ebs-nvme-udev-trigger.service dev-xvdb.device
    Wants=ebs-nvme-udev-trigger.service dev-xvdb.device
    DefaultDependencies=no
    [Service]
    Type=oneshot
    RemainAfterExit=yes
  2. jalaziz revised this gist Jun 11, 2018. 2 changed files with 40 additions and 0 deletions.
    18 changes: 18 additions & 0 deletions 999-aws-ebs-nvme.rules
    Original file line number Diff line number Diff line change
    @@ -1,2 +1,20 @@
    # Copyright (C) 2018 Jameel Al-Aziz
    # Modified for simplicification and use within CoreOS.
    #
    # Copyright (C) 2006-2016 Amazon.com, Inc. or its affiliates.
    # All Rights Reserved.
    #
    # Licensed under the Apache License, Version 2.0 (the "License").
    # You may not use this file except in compliance with the License.
    # A copy of the License is located at
    #
    # http://aws.amazon.com/apache2.0/
    #
    # or in the "license" file accompanying this file. This file is
    # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
    # OF ANY KIND, either express or implied. See the License for the
    # specific language governing permissions and limitations under the
    # License.

    # ebs nvme devices
    KERNEL=="nvme[0-9]*n[0-9]*", ENV{DEVTYPE}=="disk", ATTRS{model}=="Amazon Elastic Block Store", PROGRAM="/opt/bin/ebs-nvme-mapping /dev/%k", SYMLINK+="%c"
    22 changes: 22 additions & 0 deletions ebs-nvme-mapping
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,26 @@
    #!/bin/bash
    # This file has been modified from
    # https://github.com/oogali/ebs-automatic-nvme-mapping/blob/master/ebs-nvme-mapping.sh
    #
    # Copyright (c) 2018 Omachonu Ogali
    #
    # Permission is hereby granted, free of charge, to any person obtaining a copy
    # of this software and associated documentation files (the "Software"), to deal
    # in the Software without restriction, including without limitation the rights
    # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    # copies of the Software, and to permit persons to whom the Software is
    # furnished to do so, subject to the following conditions:
    #
    # The above copyright notice and this permission notice shall be included in all
    # copies or substantial portions of the Software.
    #
    # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    # SOFTWARE.

    vol=$(nvme id-ctrl --raw-binary "$1" | cut -c3073-3104 | tr -s ' ' | sed 's/ $//g')
    vol=${vol#/dev/}
  3. jalaziz renamed this gist Apr 9, 2018. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. jalaziz revised this gist Apr 9, 2018. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions format-xvdb.service
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,8 @@
    [Unit]
    Description=Formats /dev/xvdb
    Before=dbus.service docker.service
    After=dev-xvdb.device ebs-nvme-udev-trigger.service
    Wants=dev-xvdb.device ebs-nvme-udev-trigger.service
    After=ebs-nvme-udev-trigger.service dev-xvdb.device
    Wants=ebs-nvme-udev-trigger.service dev-xvdb.device
    [Service]
    Type=oneshot
    RemainAfterExit=yes
  5. jalaziz revised this gist Apr 9, 2018. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions format-xvdb.service
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,8 @@
    [Unit]
    Description=Formats /dev/xvdb
    Before=dbus.service docker.service
    After=dev-xvdb.device
    Wants=dev-xvdb.device
    After=dev-xvdb.device ebs-nvme-udev-trigger.service
    Wants=dev-xvdb.device ebs-nvme-udev-trigger.service
    [Service]
    Type=oneshot
    RemainAfterExit=yes
  6. jalaziz revised this gist Apr 9, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion format-xvdb.service
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    [Unit]
    Description=Formats /var/lib
    Description=Formats /dev/xvdb
    Before=dbus.service docker.service
    After=dev-xvdb.device
    Wants=dev-xvdb.device
  7. jalaziz revised this gist Apr 9, 2018. 2 changed files with 21 additions and 0 deletions.
    12 changes: 12 additions & 0 deletions ebs-nvme-udev-trigger.service
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    [Unit]
    Description=Reload AWS EBS NVMe rules
    Requires=coreos-setup-environment.service
    After=coreos-setup-environment.service
    Before=user-config.target
    [Service]
    Type=oneshot
    RemainAfterExit=yes
    EnvironmentFile=-/etc/environment
    ExecStart=/usr/bin/udevadm control --reload-rules
    ExecStart=/usr/bin/udevadm trigger -y "nvme[0-9]*n[0-9]*"
    ExecStart=/usr/bin/udevadm settle
    9 changes: 9 additions & 0 deletions format-xvdb.service
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    [Unit]
    Description=Formats /var/lib
    Before=dbus.service docker.service
    After=dev-xvdb.device
    Wants=dev-xvdb.device
    [Service]
    Type=oneshot
    RemainAfterExit=yes
    ExecStart=/bin/bash -c '(blkid -t TYPE=ext4 /dev/xvdb) || (/usr/sbin/mkfs.ext4 -F /dev/xvdb)'
  8. jalaziz created this gist Apr 9, 2018.
    2 changes: 2 additions & 0 deletions 999-aws-ebs-nvme.rules
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    # ebs nvme devices
    KERNEL=="nvme[0-9]*n[0-9]*", ENV{DEVTYPE}=="disk", ATTRS{model}=="Amazon Elastic Block Store", PROGRAM="/opt/bin/ebs-nvme-mapping /dev/%k", SYMLINK+="%c"
    7 changes: 7 additions & 0 deletions ebs-nvme-mapping
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    #!/bin/bash

    vol=$(nvme id-ctrl --raw-binary "$1" | cut -c3073-3104 | tr -s ' ' | sed 's/ $//g')
    vol=${vol#/dev/}
    if [[ -n "$vol" ]]; then
    echo ${vol/xvd/sd} ${vol/sd/xvd}
    fi