There is sometimes misconceptions about ZFS losing data due to power loss. The subject of power loss, (or OS crash), and then not being able to import a ZFS pool comes up here in the forums a few times a month. Here is the skinny on what should happen.
There are several things to un-pack about power loss affecting ZFS and data loss.
- Any previously stored data in a ZFS pool can not be / is not lost on power loss. Exception is in hardware failures that affect pool redundancy. Like the loss of both disks in a 2 way Mirror vDev.
- Any data that has not yet been written / still in flight, is lost. Just like every other file system out there.
- Using SLOG, (Separate intent LOG), is a specialized case good only for synchronous writes. Enterprise’s might Mirror SLOGs for “just in case” of a SLOG device failure during power loss or OS crash.
- ZFS attempts to be always consistent on disk, thus, after crash / power loss, no file system check is needed. I say attempt because consumer hardware fails more often than Enterprise and that can lead to data loss.
This specific power loss issue was a design criteria of ZFS, no data loss on power loss. Given no hardware failures, (RAM, storage controller, storage device, etc…), and no bugs in ZFS, (rare, but has happened), there is zero chance of ZFS losing data on crash or power loss. Except of course data in flight. Data is either completely written or not.
On the other hand, we have had enough indications on why pool corruption has occurred:
- Use of hardware RAID disk controllers, (yes, even JBOD mode can be bad).
- Using a proper LSI HBA, but really old firmware has led to problems, some appearing to cause data loss.
- Use of USB attached drives, (some with hardware RAID controllers set to JBOD mode).
- Virtualization of TrueNAS but not passing through the disk controller, (just a virtual disk or the plain disk).
Any of these can lead to out of order disk writes that during a crash can cause ZFS pool corruption. Since the corruption only occurs due to a crash, (power loss or OS crash), people say “But it worked for months / years!”. That is the point. ZFS was designed to handle crashes IF you give it the proper hardware. If not, you may get lucky or not.
Additionally, virtualization of TrueNAS with Proxmox, but not blacklisting the HBA / disk controller can corrupt a pool. Without blacklisting, Proxmox may import the pool, at the same time as TrueNAS. That is very bad as ZFS was not designed as a shared file system.
On the subject of UPSes, while a good thing, even if it just handles a few minutes, is not strictly necessary.
- As a minimum, it will extend the life of your hardware through fewer surges, power dips, transient outages, etc.
- Some hardware will fail or lose data because of graceless power loss.
- When the cleaning lady comes through and plugs the vacuum into the wrong circuit, it doesn’t interrupt your workflow …
Addendum (2025/10/11):
To clarify out of order writes. Many hardware RAID controllers will have battery backed up RAM cache used for writes. They will also optimize writes by doing elevator seeks. Meaning they may write data out of order the same way an elevator will stop at floors based on proximity, not the order the people got into the elevator.
For example, 3 people get on the elevator at the ground floor. First wants the 10th floor, the second wants the 5th floor and the 3rd wants the 3rd floor. The elevator stops at 3, 5 and 10 in that order. But, for ZFS, it would want the writes to be 10, 5 and last 3 for data integrity. The last write activating the prior writes.
If a power loss lasts longer than the battery backed up RAM cache can survive on a hardware RAID card, then the remaining writes are lost. Which could have been critical for the integrity of the pool when dealing with out of order writes.
Addendum (2025/12/10):
Added the note about Proxmox virtualization, and black listing the HBA / disk controller.
Comments?
Corrections?
Additions?