ZFS Setup And Management
ZFS Pool Setup and Management
This guide covers the main commands required to create, inspect, maintain, expand, troubleshoot, and destroy ZFS pools on Linux/Proxmox.
Warning: Commands such as
zpool create,zpool destroy,zfs destroy, and disk wiping commands can permanently erase data. Always verify device names first.
1. Identify Disks
List disks:
| |
Show disk model and serial numbers:
| |
List persistent disk IDs:
| |
For ZFS pools, prefer persistent disk paths such as:
| |
rather than:
| |
Creating a ZFS Pool
RAIDZ2 Example
Example using 8 disks:
| |
Specify a mount point:
| |
Recommended Pool Properties
Enable automatic trimming for SSD pools:
| |
Check:
| |
Enable automatic expansion:
| |
Check:
| |
Creating ZFS Datasets
Create a dataset:
| |
Create additional datasets:
| |
List datasets:
| |
Dataset Mount Points
Check mount point:
| |
Set mount point:
| |
Disable automatic mounting:
| |
Re-enable:
| |
Mount dataset:
| |
Mount all datasets:
| |
Unmount:
| |
Compression
Enable compression:
| |
Or on a specific dataset:
| |
Check compression:
| |
Check compression ratio:
| |
Record Size
Check:
| |
For large media files:
| |
For general use:
| |
Record size affects newly written data only.
Atime
Disable access-time updates:
| |
Check:
| |
This can reduce unnecessary writes.
Pool Status
Basic status:
| |
Specific pool:
| |
Verbose status:
| |
Show persistent/full disk paths:
| |
Pool Capacity
| |
More detailed dataset usage:
| |
Show all properties:
| |
ZFS I/O Monitoring
Pool I/O:
| |
Detailed per-disk I/O:
| |
Refresh every second:
| |
Refresh every 5 seconds:
| |
Show latency statistics where supported:
| |
Scrubbing
Start a scrub:
| |
Check scrub progress:
| |
Stop a running scrub:
| |
A scrub checks all stored data against ZFS checksums and attempts to repair corrupted data using redundancy.
Disk Errors
Check for errors:
| |
Clear recorded errors after fixing the cause:
| |
Clear errors for a specific disk:
| |
Offline / Online a Disk
Take a disk offline:
| |
Bring it back online:
| |
Replace a Failed Disk
Find the failed disk:
| |
Replace it:
| |
Monitor resilvering:
| |
Or:
| |
Detach / Remove Devices
For mirrored pools, detach a disk:
| |
detachis generally for mirrors. It cannot simply remove a member disk from RAIDZ.
Add Another VDEV
Example adding another RAIDZ2 vdev:
| |
Adding a vdev permanently changes the pool layout. Verify the command carefully before running it.
Expanding After Replacing Disks
After replacing disks with larger disks:
| |
Or enable automatic expansion:
| |
Snapshots
Create snapshot:
| |
List snapshots:
| |
Create recursive snapshot:
| |
Rollback:
| |
Delete snapshot:
| |
Snapshot Clones
Clone a snapshot:
| |
Remove clone:
| |
Sending and Receiving ZFS Data
Create a snapshot:
| |
Send to another pool:
| |
Send over SSH:
| |
Incremental Replication
Create two snapshots:
| |
Send only the changes:
| |
Export a Pool
Useful before moving disks to another machine:
| |
Import a Pool
List available pools:
| |
Import:
| |
Force import if required:
| |
Import using persistent disk IDs:
| |
Rename a Pool
Export it:
| |
Import using the new name:
| |
Destroy a Dataset
| |
Destroy recursively:
| |
This permanently deletes the dataset and its data.
Destroy a Pool
| |
Warning: This permanently destroys the ZFS pool.
Disk Information
Check SMART information:
| |
Using a persistent ID:
| |
Short SMART test:
| |
Long SMART test:
| |
Useful ZFS ARC Commands
View ARC statistics:
| |
Live ARC statistics:
| |
Check current ARC size:
| |
Check ZFS Version
| |
Pool History
View commands that have modified the pool:
| |
Verbose history:
| |
This is particularly useful when troubleshooting configuration changes.
Common Health Check
A useful quick check:
| |
For detailed live I/O:
| |
For recent pool operations:
| |
Typical Recommended Dataset Setup
Example:
| |
Result:
| |
Recommended Routine Maintenance
Check pool health:
| |
Check capacity:
| |
Monitor disk activity:
| |
Run a scrub:
| |
Monitor scrub:
| |
Check SMART health periodically:
| |
For important storage, schedule regular scrubs and SMART tests rather than relying on manual checks alone.