Last active
August 19, 2025 05:52
-
-
Save marcan/84c092993861e786d1743a5a33e4414d to your computer and use it in GitHub Desktop.
udev device ID fixer for NVMe USB enclosures
This file contains hidden or 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
# /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" |
This file contains hidden or 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
#!/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