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.
CoreOS AWS EBS NVMe udev rules
# 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"
#!/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
[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
[Unit]
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
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/bash -c '(blkid -t TYPE=ext4 /dev/xvdb) || (/usr/sbin/mkfs.ext4 -F /dev/xvdb)'
@JustinVenus
Copy link

Thanks for sharing this, I found it helpful.

@r7vme
Copy link

r7vme commented Jun 7, 2018

Helped us too! thanks @jalaziz

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