Full disclosure as I don't want to get crucified, but I used Gemini 100% to help fix/write this for my system because I got sick of having to deal with my NAS enclosure giving me sequential serial numbers and then reboot would show the actual serial numbers and pools wouldn't come back online until rebooted 2-3 times. Hopefully this saves someone else a headache! (FWIW, I wrote this paragraph).
If you run a multi-bay USB DAS on Unraid and have ever had your array or ZFS pools break after a power outage because your drives suddenly show up as 0000000000000001, 0000000000000002, etc., here is a permanent fix that survives reboots, cold power cycles, and Unraid OS updates.
My Setup (For Reference)
- Enclosure: 4-bay USB 3.1 DAS using VIA Labs VL817 SATA bridge controllers (
2109:0715) - Drives: Mix of WD drives (Red, Purple, Ultrastar, Blue) across dedicated ZFS pools + ZFS internal boot setup (no traditional parity array, though this works for both)
- The Issue: Normal warm reboots were always fine, but whenever the house lost power and the DAS cold-booted, the USB bridge handed out sequential
0000000x serial numbers based on whichever drive spun up fastest—scrambling all my slot assignments.
Why Standard udev Fixes Often Fail
Most guides tell you to run smartctl directly inside a 99- udev rule. That failed for me for two reasons:
udev 3-second timeout: When 4 drives spin up simultaneously over one USB bus, smartctl queries queue up and get killed by udev before the slower drives respond.- Rule ordering: Unraid's built-in storage rules run late and overwrite
ID_SERIAL back to the USB bridge's 0000000x ID.
The Fix: Scan Sequentially in /boot/config/go + Apply via a zzz- Rule
Instead of querying smartctl inside udev, we scan the drives one by one in /boot/config/go before emhttpstarts, save the real serials to /run/das-serials/, and let a zzz- udev rule (which runs dead last) apply them instantaneously.
- Verify
smartctl can see your real drive serials
Open the Unraid terminal and test one of your DAS drives (swap sdX for one of your disks):
bash
smartctl -i -d sat /dev/sdX | grep -E "Model|Serial"
Use code with caution.
If it prints the actual model and serial number from the drive's sticker, you're good to go.
2. Create the sequential scan script on your boot drive
bash
mkdir -p /boot/config/udev
cat << 'EOF' > /boot/config/udev/scan-das-serials.sh
#!/bin/bash
mkdir -p /run/das-serials
for DEV in /sys/block/sd*; do
NAME=$(basename "$DEV")
for i in {1..10}; do
INFO=$(/usr/sbin/smartctl -i -d sat "/dev/$NAME" 2>/dev/null)
SERIAL=$(echo "$INFO" | awk -F": *" '/Serial Number/ {print $2}' | tr -d '[:space:]')
MODEL=$(echo "$INFO" | awk -F": *" '/Device Model|Product/ {print $2; exit}' | sed 's/[^a-zA-Z0-9._-]/_/g' | sed 's/__*/_/g')
[ -z "$MODEL" ] && MODEL="WDC_DRIVE"
if [ -n "$SERIAL" ] && [[ ! "$SERIAL" =~ ^0+$ ]]; then
cat << INNER > "/run/das-serials/$NAME"
REAL_BUS=ata
REAL_MODEL=$MODEL
REAL_SERIAL_SHORT=$SERIAL
REAL_SERIAL=${MODEL}_${SERIAL}
INNER
break
fi
sleep 1
done
done
EOF
Use code with caution.
(Note: If you have non-WD drives and a drive doesn't report a Device Model string, change WDC_DRIVE to whatever fallback name you want.)
3. Create the zzz- udev rule
Naming it zzz- guarantees it runs after Unraid's default USB rules and forces ID_BUS=ata and the real serial number:
bash
cat << 'EOF' > /boot/config/udev/zzz-usb-das-serial.rules
ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="sd*", TEST=="/run/das-serials/$name", IMPORT{file}="/run/das-serials/$name", ENV{ID_BUS}="$env{REAL_BUS}", ENV{ID_MODEL}="$env{REAL_MODEL}", ENV{ID_SERIAL_SHORT}="$env{REAL_SERIAL_SHORT}", ENV{ID_SERIAL}="$env{REAL_SERIAL}", ENV{ID_INSTANCE}="", SYMLINK+="disk/by-id/ata-$env{REAL_SERIAL}"
EOF
Use code with caution.
4. Add it to /boot/config/go (before emhttp)
Make sure this runs above /usr/local/sbin/emhttp so Unraid sees the real serials before initializing your pools/array:
bash
cat << 'EOF' > /boot/config/go
#!/bin/bash
# Scan USB DAS real serial numbers before starting Unraid
cp /boot/config/udev/scan-das-serials.sh /usr/local/bin/
chmod +x /usr/local/bin/scan-das-serials.sh
/usr/local/bin/scan-das-serials.sh
cp /boot/config/udev/zzz-usb-das-serial.rules /etc/udev/rules.d/
udevadm control --reload-rules
for DEV in /run/das-serials/*; do
[ -e "$DEV" ] && udevadm trigger --action=change "/sys/block/$(basename "$DEV")"
done
udevadm settle
# Start the Management Utility
/usr/local/sbin/emhttp
EOF
Use code with caution.
5. Reboot and Re-assign (One-Time Step)
- Reboot Unraid—all your DAS drives should now show their real manufacturer serial numbers on Main.
- If you use ZFS/Cache Pools: Just pick the real serial number from each pool slot dropdown and start the array (zero data touched).
- If you use a Parity/Data Array: Run Tools -> New Config, assign your drives to their exact original Parity and Data slots using the real serials, check Parity is already valid, and click Start. (Obligatory warning: double-check your Parity slot so you don't overwrite a data disk, and never click Format.)
Because everything lives in /boot/config/, Unraid OS upgrades leave it untouched and it runs automatically on every cold boot.