kubectl directpv repair
The kubectl directpv repair command attempts to repair XFS filesystem errors, faults, or corruption on DirectPV-managed drives using the xfs_repair utility.
xfs_repair utility has no guarantee of success or complete recovery.
Always back up critical data before attempting repairs.
Before repairing a drive, you must first suspend it using kubectl directpv suspend drives.
For the complete repair workflow, see Repair Drives.
Syntax
Parameters
DRIVE_ID
Required
The unique identifier of the drive to repair.
Use kubectl directpv list drives to find drive IDs.
--force
Optional
Force log zeroing during repair. Use this flag when the XFS log is corrupted and cannot be replayed.
--disable-prefetch
Optional
Disable prefetching of inode and directory blocks during repair. This may help with repairs on drives experiencing I/O errors.
--dry-run
Optional
Display what repairs would be attempted without making changes. Use this to preview the repair operation.
Global flags
This command supports the following global flags:
| Flag | Description |
|---|---|
--kubeconfig |
Path to the kubeconfig file to use for CLI requests. |
--quiet |
Suppress printing error messages. |
Examples
Repair a single drive
Run xfs_repair on a drive to attempt recovery from filesystem errors or corruption:
kubectl directpv repair 3b562992-f752-4a41-8be4-4e688ae8cd4c
Repair multiple drives
Repair several drives in a single command. Each drive runs as a separate Kubernetes Job:
kubectl directpv repair 3b562992-f752-4a41-8be4-4e688ae8cd4c a1b2c3d4-e5f6-7890-abcd-ef1234567890
Preview repair without making changes
Check what the repair operation would do without modifying the drive. Useful for assessing the extent of filesystem damage before committing to repairs:
kubectl directpv repair 3b562992-f752-4a41-8be4-4e688ae8cd4c --dry-run
Force log zeroing for corrupted log
When standard repair fails because the XFS journal is corrupted and cannot be replayed, force the log to be zeroed. This discards any pending transactions in the log, which may result in additional data loss:
kubectl directpv repair 3b562992-f752-4a41-8be4-4e688ae8cd4c --force
Behavior
Prerequisites
Before running the repair command:
- Identify the drive ID using
kubectl directpv list drives --status=error - Suspend the drive using
kubectl directpv suspend drives
Repair process
The command creates a one-time Kubernetes Job named repair-<DRIVE-ID> that runs the xfs_repair utility on the specified drive.
Monitoring progress
View repair progress and status using kubectl logs:
kubectl logs -n directpv job/repair-3b562992-f752-4a41-8be4-4e688ae8cd4c
Job cleanup
Kubernetes automatically removes the repair job five minutes after completion.
After repair
After a successful repair:
- Resume the drive using
kubectl directpv resume drives. - Verify drive status using
kubectl directpv list drives.
Next steps if the repair fails
If the repair fails:
- Check the job logs for error details.
- Consider using
--forceif log corruption is reported. - The drive may need to be replaced if repair cannot recover it.
For drive replacement procedures, see Replace Drive.