TechBuzzPro

ZFS Pool Import Failed Labels Missing After Scrub

· 6 min read · Apps & Browsers

In this article
  1. Background: What Are ZFS Labels and Why Do They Matter?
  2. How a Scrub Can Expose Label Corruption
  3. Common Causes of Missing or Corrupted Labels
  4. Diagnosing the Problem Before You Fix It
  5. Step-by-Step Recovery: Restoring Labels and Importing
  6. Prevention and Best Practices
  7. Frequently Asked Questions

If a ZFS pool fails to import with "labels missing" errors after a scrub, the scrub itself did not cause the problem; the labels were already corrupted or unreadable, and the scrub only surfaced the issue by reading every block. The fix is to identify the damaged vdev, restore the labels from a healthy copy or the pool's configuration, and then re-import the pool. Below is a detailed breakdown of why this happens and how to resolve it safely.

Background: What Are ZFS Labels and Why Do They Matter?

Every ZFS vdev (a disk, partition, or file) contains four copies of the vdev label, located at the start and end of the device. These labels store critical metadata: the pool's GUID, the vdev's GUID, the pool name, the state (e.g., active, exported), and the uberblock array that points to the latest pool state. When you run zpool import, ZFS scans all devices for these labels to assemble the pool configuration. If it cannot read enough labels from a vdev, it reports "labels missing" and refuses to import the pool, because it cannot safely determine the pool's identity or state.

How a Scrub Can Expose Label Corruption

A scrub reads every block on every vdev and verifies its checksum. It does not modify labels. However, if a disk has developed bad sectors in the label regions (first or last ~256KB of the device), a scrub will read those sectors and report checksum errors or I/O errors. The scrub itself is not the cause; it simply forces a full read of the device, which reveals pre-existing damage. In some cases, a scrub can also trigger a firmware or hardware fault that makes the disk temporarily unresponsive, leading to label read failures during a subsequent import.

Common Causes of Missing or Corrupted Labels

  • Disk failure or bad sectors: Physical damage to the label area is the most common cause. SMART data often shows reallocated or pending sectors.
  • Incorrect disk replacement or partition changes: If a disk was replaced and the new one was partitioned differently, or if a partition table was rewritten, the labels may be gone.
  • Import/export confusion: If the pool was not properly exported before disconnecting disks, the labels may be in an inconsistent state, but this usually still allows import with -f.
  • ZFS version mismatch: A pool created with a newer ZFS version may have label features that an older ZFS cannot read, leading to "labels missing" errors.
  • Hardware controller issues: A faulty HBA or cable can cause intermittent read errors, making labels unreadable at import time.

Diagnosing the Problem Before You Fix It

Before attempting any repair, you need to identify which vdev is missing labels. Run zpool import and note the exact error message. Then use zdb -l /dev/disk/by-id/... on each disk to see if any labels are readable. For example:

zdb -l /dev/sda

This prints a summary of the four labels. If you see "failed to read label" or "invalid label", that disk is the culprit. Also check zpool status -x if the pool is still imported (though it likely isn't). If the pool is not imported, you can use zpool import -D to show all pools, including those with missing labels, but it will not import them.

Step-by-Step Recovery: Restoring Labels and Importing

  1. Stop all writes to the pool: If the pool is still imported in a degraded state, do not write to it. If it's not imported, do not create new filesystems on the disks.
  2. Identify the damaged vdev: Use zdb -l on each disk to find which one has unreadable labels. If multiple disks are affected, the pool may be too damaged to recover without a backup.
  3. If the pool is imported but degraded: You can try to replace the damaged disk with a new one using zpool replace. ZFS will resilver the data, and the new disk will get fresh labels. This is the safest option if you have a spare disk.
  4. If the pool is not imported: Try importing with zpool import -f (force). This tells ZFS to ignore the missing labels and use the remaining labels. If the pool has enough valid labels (at least one per vdev), it may import successfully. If it does, immediately back up your data, then replace the failing disk.
  5. If force import fails: You can attempt to manually restore labels from a healthy disk in a mirror or raidz. For a mirror, copy the labels from the good disk to the bad one using dd (e.g., dd if=/dev/good of=/dev/bad bs=256k count=1 and dd if=/dev/good of=/dev/bad bs=256k count=1 seek=... for the end). This is risky and should only be done if you understand the exact geometry. For raidz, this is not possible because the labels are per-disk and not redundant across disks in the same way.
  6. After restoring labels: Run zpool import again. If it succeeds, immediately run a scrub to verify data integrity and consider replacing the disk.

Prevention and Best Practices

  • Regularly check SMART data: Use smartctl -a /dev/sda to monitor reallocated sectors and pending errors. Replace disks before they fail.
  • Always export the pool before removing disks: Use zpool export poolname to write clean labels. This prevents many import issues.
  • Use disk IDs instead of device names: In /etc/zfs/zpool.cache and in zpool import, use /dev/disk/by-id/ to avoid device name changes.
  • Keep backups: ZFS is not a backup. A corrupted label on a single disk in a stripe pool means total data loss. Always have an off-site backup or a mirror/raidz configuration.
  • Update ZFS regularly: Newer versions have better label handling and recovery tools.

Frequently Asked Questions

Can a scrub actually damage ZFS labels?

No. A scrub only reads data and verifies checksums. It never writes to labels. If labels are missing after a scrub, the damage was already there but undetected because the label area is not normally read during normal operation.

What does "pool I/O is currently suspended" mean during import?

This usually indicates that ZFS cannot read a vdev at all, often due to a hardware failure. It's different from "labels missing" and typically means the disk is not responding. Check cables, power, and SMART data.

Can I use zpool import -F to recover from missing labels?

-F (recovery) is for rolling back to a previous transaction group, not for fixing labels. It may help if the pool state is inconsistent, but it won't recreate missing labels. Use -f first, then consider -F if the pool imports but is corrupted.

Is it safe to copy labels from one disk to another in a mirror?

Only if the disks are identical in size and the pool configuration is the same. Copying labels from a healthy disk to a failed one can make the failed disk appear as a valid mirror member, but if the data on the failed disk is also corrupt, the pool may be inconsistent. Always verify with zpool status after.

What if the pool is a stripe (raid0) and one disk has missing labels?

Then the pool is effectively lost. There is no redundancy, and without labels, ZFS cannot identify the disk as part of the pool. You would need to restore from backup. This is why stripes are not recommended for important data.

Should I use zpool clear after a scrub error?

zpool clear resets the error counters on a vdev. It does not fix labels. If the labels are missing, clear won't help. Use it only after you have replaced a disk or fixed a transient error.