keepcalculator

06 Numbers and Powers

How to Check a NAS for Silent Data Corruption

Card No. 06·39485 · Updated · Standard formula, shown below

Silent data corruption, also known as bit rot, is a gradual decay of stored data that can go unnoticed for months or years. This guide shows you how to check your NAS for these issues using built-in tools like SMART diagnostics, filesystem scrubs, and checksum verification. You will learn what commands to run, how to interpret the results, and what to do when corruption is found.

What You’ll Need

  • Administrative access to your NAS (web interface or SSH)
  • The filesystem type your NAS uses (ext4, Btrfs, ZFS, etc.)
  • A basic understanding of command-line tools (if using SSH)
  • Time: a full check can take several hours depending on disk size

Step-by-Step

  1. Backup your data. Before running any checks, ensure you have a current backup. Some checks (like scrubs) are read-only, but if corruption is found, you may need to restore from backup.
  2. Identify your filesystem. Log into your NAS web interface or SSH. Run df -T to see the filesystem type for each mount point. Common types: ext4, Btrfs, ZFS, XFS.
  3. Check SMART health. SMART (Self-Monitoring, Analysis and Reporting Technology) can predict drive failures. Use smartctl -a /dev/sdX (replace sdX with your disk). Look for Reallocated_Sector_Ct, Pending_Sector, and UDMA_CRC_Error_Count. Non-zero values may indicate early hardware issues.
  4. Run a filesystem scrub. This reads all data and verifies checksums. For ZFS: zpool scrub poolname. For Btrfs: btrfs scrub start /mountpoint. For ext4, there is no native scrub; you can use fsck -n /dev/sdX (read-only) or rely on RAID parity checks.
  5. Check checksums on files. If your filesystem supports checksums (ZFS, Btrfs), the scrub will catch errors. For others, use tools like md5deep or rhash to generate and compare checksums. Create a baseline with rhash -r . > checksums.txt, then later run rhash -c checksums.txt to verify.
  6. Review system logs. After the scrub, check logs for errors. For ZFS: zpool status -v. For Btrfs: btrfs device stats /mountpoint. For SMART, use smartctl -l selftest /dev/sdX to see past test results.
  7. Schedule regular checks. Set up a cron job or use the NAS’s built-in scheduler to run scrubs monthly and SMART tests weekly. This catches bit rot early.

Common Mistakes

  • Ignoring SMART warnings. A single reallocated sector is a warning, not a death sentence, but ignore it and you risk data loss.
  • Running fsck on a mounted filesystem. Always unmount first or use read-only mode. Running fsck on a live filesystem can cause further damage.
  • Not checking checksums of backups. Bit rot can affect backups too. Verify your backups periodically.
  • Assuming RAID protects against bit rot. Traditional RAID (RAID 5/6) only protects against drive failure, not silent corruption. Use ZFS or Btrfs for checksumming.
  • Skipping the backup step. If a scrub finds corruption, you might need to restore from backup. Without one, that data is gone.

Tips

  • Use ZFS or Btrfs if your NAS supports it. They provide end-to-end checksumming and auto-repair.
  • Monitor SMART attributes over time. A slow increase in reallocated sectors is more concerning than a one-time spike.
  • For large arrays, run scrubs during off-peak hours to avoid performance impact.
  • Keep a log of checksum baselines for critical files. Store them on a separate medium (like a USB stick) to avoid corruption of the checksums themselves.
  • If you find corruption, replace the failing drive as soon as possible. Prolonged use can lead to more errors.

Troubleshooting

Scrub hangs or takes too long. This is normal for large arrays. Check progress with zpool scrub -p poolname (ZFS) or btrfs scrub status /mountpoint (Btrfs). If it’s stuck for days, check disk I/O and system load.

SMART test fails. Run a short test first: smartctl -t short /dev/sdX. If that fails, the drive is likely failing. Back up data and replace it.

Checksums mismatch. This indicates corruption. Identify the affected files and restore them from backup. If it’s a system file, reinstall the package or restore from OS image.

Btrfs scrub reports errors but can’t repair. This can happen if the drive has hardware issues. Check dmesg for I/O errors. Replace the drive and scrub again.

ZFS pool shows DEGRADED. This means a device is offline or has errors. Run zpool status to see which device. Replace it and resilver.

Frequently Asked Questions

Q: How often should I check my NAS for bit rot?
A: Monthly scrubs and weekly SMART tests are a good baseline. If you store critical data, consider weekly scrubs.

Q: Can bit rot be prevented?
A: Not entirely, but using a checksumming filesystem like ZFS or Btrfs can detect and auto-repair most corruption. Regular backups also mitigate the risk.

Q: Does RAID protect against bit rot?
A: Traditional RAID does not detect or repair silent corruption. Only filesystems with checksums (ZFS, Btrfs) can do that.

Q: What is the difference between a scrub and a SMART test?
A: A scrub reads all data and verifies checksums to detect corruption. A SMART test checks the drive’s health indicators, like reallocated sectors, to predict failure.

Q: I found corruption. What should I do?
A: Immediately back up any unaffected data. Then restore the corrupted files from a known-good backup. If the corruption is widespread, replace the drive.

Q: Can I check for bit rot on a single external drive?
A: Yes, you can use checksum tools like rhash or md5deep to verify file integrity. But the drive’s filesystem won’t auto-repair, so you’ll need to manually restore corrupted files.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →