Replacing two failing disks on Unraid (one did not wait)
The numbers that started it
On November 29, I was cleaning up after a batch job on my NAS when the SMART data of two disks caught my eye:
| Disk 2 | Disk 4 | |
|---|---|---|
| Reallocated sectors | 8 | 464 |
| Reported uncorrectable errors | 31 | 7 |
| UDMA CRC errors (often the cable) | 4 | 0 |
| Read errors in Unraid's "Errors" column | 275 | 296 |
Neither disk had pending sectors, so nothing was failing right now. But both had about 41,500 hours on the clock, almost five years, and these numbers only go one way.
The NAS runs Unraid with dual parity: two 8 TB parity disks and four 4 TB data disks, each formatted as ZFS. All six SATA ports of the motherboard are taken.
This post is the field guide I wish I had read before replacing two of those disks. It took five days from the first warning to the second rebuild. One of the disks died before its turn, and most of what went wrong had nothing to do with the disks.
I ran the whole operation with Claude Code connected to the NAS over SSH. It read SMART data, logs and iostat, and every command that changed something waited for my go. It also made three mistakes, which are in this post too.
One disk at a time, the worst first
Replacing a disk on Unraid is almost "swap it and wait". You assign the new disk to the slot of the old one, start the array, and Unraid rebuilds its whole content from parity and the other disks.
The catch: a rebuild reads every other disk from start to end. Say you replace the healthier of two weak disks first. The weaker one then has to survive a full read. With dual parity, Unraid can still correct its read errors during that read. With both disks rebuilding at once, there is no margin left.
So: one disk at a time, and disk 4 first, because 464 reallocated sectors was the worst number in that table.
Choosing the new disks
Three rules decided the model:
- A data disk cannot be bigger than the parity. My parity disks are 8 TB, so 8 TB was the maximum. Going bigger later means replacing both parity disks first.
- CMR, not SMR. SMR disks (WD Red without "Plus", Seagate BarraCuda) are very slow to rebuild.
- A five-year warranty for a NAS that never sleeps.
I ordered two Seagate IronWolf Pro 8 TB. Replacing two 4 TB disks with two 8 TB ones also grows the array from 16 TB to 24 TB of data disks.
Testing new disks without a free SATA port
You want to know a new disk is healthy before you trust it with a rebuild. An extended SMART test reads the whole surface, and it takes 12 to 15 hours on 8 TB.
Without a free port, the only way is to stop the array, put the new disk in place of the old one, and test it while every service is down. Twice.
The alternative costs 30 to 50 euros: a USB-SATA dock, plugged into the NAS, which tests both new disks while the array runs normally. Two things matter when you buy one:
- Its own power supply. A 3.5" disk needs 12 V, which USB does not provide. Bare USB-SATA cables only work with 2.5" disks.
- SMART passthrough. Some cheap bridges block SMART commands entirely.
The dock worked, but not on the first try:
smartctlneeds-d satto talk to a disk behind a USB bridge. Without it, the command fails on the mandatory SMART command and you read nothing.- The first two extended tests stopped about an hour in, with
Aborted by hostand 90% remaining. That one was Claude's fault: it queried the disks to check their progress, the dock reset twice (usb 2-8.1: resetin the syslog), and both tests died. - The tests I started again in the evening stopped the same way overnight, with nobody querying anything. Unraid's own spin-down was off (
spindownDelay="0"), so the likely culprit is the dock's power saving, which cuts the disk after about an hour without USB traffic.
In the end, I settled for a short SMART test (2 minutes), which both disks passed: Completed without error. It was not the full surface check I wanted, and the next section explains why waiting another night was not an option.
One rule I kept: never rebuild onto a disk in the dock. Unraid would let you assign it, but a USB reset during a 14-hour rebuild would make it fail. The new disk goes on the SATA port of the old one.
Disk 4 did not wait
On the morning of December 2, the day I had planned to replace it, disk 4 was already out. Unraid had disabled it during the night, its error counter read 3,718, and the Main page said "contents emulated".
No data was lost: Unraid computed the content of disk 4 on the fly from parity. But I was down to a single parity of margin, with disk 2 as the weak link. The swap could not wait for a long test.
There was one piece of luck. A paused parity check had been resumed, and it finished just before disk 4 dropped out. So the parity was known to be correct.
The swap
The procedure itself is short:
- Make sure the array does not start on its own after a boot (
startArray="no"indisk.cfg, or "Enable auto start" off in Settings, Disk Settings). - Stop the array, power off, and put the new disk on the SATA cable of the old one.
- Boot, and assign the new disk to the Disk 4 slot. Do not use an empty slot like Disk 5, which would add it as an extra disk instead of a replacement.
- Start the array. The rebuild begins.
Stopping the array took forever, though. Unraid could not unmount /mnt/user and kept retrying. The cause was a tail -f on a log file under /mnt/user. Claude had given me that command earlier in the week to follow the batch job, and it was still running in a terminal. One open file is enough to block the stop.
Why the rebuild crawled at 50 MB/s
The rebuild started slowly, which is normal: every Docker container starts at the same time and reads from the array. But after 30 minutes it was still at 51 MB/s. At that speed, 8 TB would take about 40 hours.
Stopping the non-essential containers changed nothing (51 -> 50 MB/s). And the Main page could not say which disk was slow, because during a rebuild every disk reads at the pace of the slowest one:
:format(webp)/posts-assets%2Freplacing-two-failing-disks-on-unraid-one-did-not-wait%2Funraid-rebuild-at-50-mbs.png)
The total, about 300 MB/s for the whole array, looked like a cheap SATA card on a PCIe x1 slot sharing its bandwidth between six disks. That was Claude's second mistake: lspci showed all six disks on the motherboard's Intel controller, which is not a bottleneck.
iostat -x gave the real answer. Disk 3 was 99% busy with a 38 ms read latency, while the other disks sat at 11 to 19%. Something else was reading from it.
That something was a User Script I had forgotten about. It deleted the .DS_Store files my Macs left everywhere, and it was scheduled "At Startup of Array". So it started with the rebuild and ran a find over the whole /mnt/user, including the Immich thumbnails.
I had aborted the script from the User Scripts page, but that stops the script, not the find it launched. Killing the find process took the rebuild from 48 to 179 MB/s, and disk 3 dropped to 69% busy with a 4 ms latency.
I first patched the script so it skipped parity operations and ran weekly instead of at array start. Then I deleted it.
Cleaning up .DS_Store files every week only treats the symptom. The real fix is to stop the Macs from writing them. Two lines in Samba's configuration (Settings, SMB, SMB Extras) make the shares refuse .DS_Store and ._* files:
veto files = /._*/.DS_Store/
delete veto files = yesThe second line, delete veto files = yes, lets Samba delete a folder that still contains such files.
After the rebuild: let ZFS check the result
The rebuild of disk 4 took 13 hours and 46 minutes. Two good surprises followed.
First, the ZFS pool of disk 4 grew to 7.27 TB on its own, because autoexpand was on. No manual resize was needed.
Second, the scrub. A parity rebuild recomputes data, but nothing in parity tells you the result is right. With ZFS-formatted array disks, every block has a checksum, so a scrub checks that the rebuilt data is the data ZFS wrote. It ran overnight: scrub repaired 0B in 03:53:37 with 0 errors.
Disk 2, the next morning
Disk 2 had just passed a real-life test: the rebuild of disk 4 had read its 4 TB from start to end, with no new error. It still showed the same 8 reallocated sectors and 31 uncorrectable errors as on November 29.
That raised two questions.
Why replace it at all? Because a planned replacement happens with two parities of margin. If disk 2 failed later, I would rebuild it with one, like on the morning of December 2.
Should I run a parity check before the swap? No. The rebuild and the scrub had just proven the parity correct. A check would have made the weak disk read its 4 TB for another 14 hours, for nothing. The old disk 2 stays on a shelf, untouched, until the new one has been scrubbed.
With nothing else reading the array, the rebuild of disk 2 ran at 174 MB/s from the first minutes. Unraid's display shows an average that catches up slowly, so it said 74 MB/s at first, when the real speed was more than twice that.
The rebuild took 13 hours and 46 minutes. Then the ZFS pool of disk 2 grew to 7.27 TB by itself, just like the pool of disk 4.
The scrub ran the next morning and came back clean too: scrub repaired 0B in 04:03:58 with 0 errors.
:format(webp)/posts-assets%2Freplacing-two-failing-disks-on-unraid-one-did-not-wait%2Funraid-array-after-both-swaps.png)
Things that bit me
- The reboot took the NAS off the internet for a day. The network bond had a port without a cable as its primary port. At boot, the cabled port took 30 seconds to get a stable link, the IP address was withdrawn and added back, and deleting an address also deletes the default route that depends on it. Tailscale started without a route and stayed stuck in
NoState. I only noticed the next morning, when Tailscale on the NAS would not come up. Making the cabled port the primary one (Settings, Network Settings, Interface Rules) fixed it at the next boot. I still do not know what withdrew the address. - An open file blocks the array stop, as seen above.
lsof /mnt/usershows who. - Aborting a User Script does not kill its children. Check with
psthat nothing it started is still reading the array. - A USB dock is fine for testing, not for long jobs. It reset when queried and slept in the middle of tests.
If you do this tomorrow
- Turn off the array auto-start before touching the hardware.
- Test the new disks first. With no free port, use a powered USB dock and
smartctl -d sat, and do not poll it during the test. - One disk at a time, the worst first, on SATA, never through the dock.
- Before pressing Start, make sure nothing else will read the array: User Scripts set to run at array start, a forgotten
tail -f, a media scan. If the rebuild is slow,iostat -xfinds the busy disk that the Main page cannot show. - After the rebuild, scrub (ZFS) and keep the old disk until the scrub is clean. After the reboot, check
ip routeand Tailscale.
What I learned
The disks were the easy part: both rebuilds worked, and both scrubs repaired nothing. What cost me time was everything around them: a cleanup script I had forgotten, a tail -f left in a terminal, a network bond whose primary port had no cable, and a dock that fell asleep. None of it showed on a normal day, and all of it showed up in the same week.
That is the part of a homelab nobody puts in the screenshots. At home, I am the sysadmin, with no spare port, no test bench and no colleague to read a command before it runs. Claude played that colleague this time, and it still made three mistakes. Self-hosting is doable, but improvising as a sysadmin is harder than it looks.
The array now has 24 TB of data disks instead of 16. Disks 1 and 3 are the same age as the two that failed, so they are next. Replacing them with 8 TB disks would bring the array to 32 TB, and going beyond 8 TB per disk will start with the parity disks.