Skip to content

Instantly share code, notes, and snippets.

@marcan
Last active August 19, 2025 05:52
Show Gist options
  • Save marcan/84c092993861e786d1743a5a33e4414d to your computer and use it in GitHub Desktop.
Save marcan/84c092993861e786d1743a5a33e4414d to your computer and use it in GitHub Desktop.
udev device ID fixer for NVMe USB enclosures
# /etc/udev/rules.d/90-usb-nvme.rules
# Adjust ID_MODEL to match your enclosure
SUBSYSTEM=="block", KERNEL=="sd*", ENV{ID_MODEL}=="ASM236X_NVME", IMPORT{program}="/usr/local/bin/nvme-usb-id $tempnode"
#!/bin/sh
# /usr/local/bin/nvme-usb-id
info="$(/usr/sbin/smartctl -i -j "$1")"
model_name="$(echo "$info" | /usr/bin/jq -r .model_name)"
serial_number="$(echo "$info" | /usr/bin/jq -r .serial_number)"
echo "ID_MODEL=\"${model_name// /_}\""
echo "ID_SERIAL=\"${model_name// /_}_${serial_number// /_}\""
echo "ID_SERIAL_SHORT=\"${serial_number// /_}\""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment