Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[zfs/en-en] Update zfs.html.markdown #4817

Merged
merged 10 commits into from
May 13, 2024
Merged
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 97 additions & 17 deletions zfs.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ category: tool
tool: zfs
contributors:
- ["sarlalian", "http://github.com/sarlalian"]
- ["81reap", "https://github.com/81reap"]
- ["A1EF", "https://github.com/A1EF"]
filename: LearnZfs.txt
---
Expand All @@ -19,23 +20,24 @@ usability for systems administrators.

### Virtual Devices

A VDEV is similar to a raid device presented by a RAID card, there are several different
types of VDEV's that offer various advantages, including redundancy and speed. In general
VDEV's offer better reliability and safety than a RAID card. It is discouraged to use a
RAID setup with ZFS, as ZFS expects to directly manage the underlying disks.

Types of VDEV's

* mirror (n-way mirrors supported)
* raidz
* raidz1 (1-disk parity, similar to RAID 5)
* raidz2 (2-disk parity, similar to RAID 6)
* raidz3 (3-disk parity, no RAID analog)
* disk
* file (not recommended for production due to another filesystem adding unnecessary layering)

Your data is striped across all the VDEV's present in your Storage Pool, so more VDEV's will
increase your IOPS.
A VDEV (Virtual Device) in ZFS is analogous to a RAID device and simmilaly offers different
benefits in terms of redundancy and performance. In general VDEV's offer better reliability
and safety than a RAID card. It is discouraged to use a RAID setup with ZFS, as ZFS expects
to directly manage the underlying disks.

| VDEV Type | Similar RAID | Notes |
|-----------|----------------|---------------------------------------|
| Stripe | Single disk | No redundancy. Data is not mirrored or parity-protected. |
81reap marked this conversation as resolved.
Show resolved Hide resolved
| Mirror | RAID 1 | Supports n-way mirroring for redundancy. |
| raidz1 | RAID 5 | Single disk parity, offering fault tolerance of one disk failure. |
| raidz2 | RAID 6 | Two-disk parity, can tolerate two disk failures. |
| raidz3 | - | Three-disk parity, can tolerate three disk failures. |
| Disk | - | Represents a single physical disk in a VDEV. |
| File | - | File-based VDEV, not recommended for production as it adds complexity and reduces reliability. |

Data in a ZFS storage pool is striped across all VDEVs. Adding more VDEVs, Logs, or Caches
can increase IOPS (Input/Output Operations Per Second), enhancing performance. It's crucial
to balance VDEVs for optimal performance and redundancy.

### Storage Pools

Expand Down Expand Up @@ -259,6 +261,84 @@ zroot/var none none
```


### Write Log Pool

The ZFS Intent Log (ZIL) is a write log designed to speed up syncronus writes. This is
typically a faster drive or drive partition than the larger storage pools.

```bash
# Add a log pool
$ zpool add mypool/lamb log /dev/sdX

# Check the configureation
$ zpool status mypool/lamb
```

### Read Cache Pool

The Level 2 Adaptive Replacement Cache (L2ARC) extends the primary ARC (in-RAM cache) and is
used for read caching. This is typically a faster drive or drive partition than the larger
storage pools.

```bash
# Add a cache pool
$ zpool add mypool/lamb cache /dev/sdY

# Check the configureation
$ zpool status mypool/lamb
```

### Data Compression

Data compression reduces the amount of space data occupies on disk in excange for some extra
CPU usage. When enabled, it can enhance performance by reducing the amount of disk I/O. It
especially beneficial on systems with more CPU resources than disk bandwidth.

```bash
# Get compression options
$ zfs get -help
...
compression NO YES on | off | lzjb | gzip | gzip-[1-9] | zle | lz4 | zstd | zstd-[1-19] | zstd-fast | zstd-fast-[1-10,20,30,40,50,60,70,80,90,100,500,1000]
...

# Set compression
$ zfs set compression=on mypool/lamb

# Check the configureation
$ zpool get compression mypool/lamb
```

### Encryption at Rest

Encryption allows data to be encrypted on the device at the cost of extra CPU cycles. This
propery can only be set when a dataset is being created.

```bash
# Enable comporession on the pool
$ zpool set feature@encryption=enabled black_hole

# Create an encrypted dataset with a prompt
$ zfs create -o encryption=on -o keyformat=passphrase black_hole/enc

# Check the configureation
$ zfs get encryption black_hole/enc
```

It should be noted that there are parts of the system where the data is not encrypted. See
the table below for a breakdown.

| Component | Encrypted | Notes |
|----------------------|-------------------------------------------|------------------------------------------------------|
| Main Data Storage | Yes | Data in datasets/volumes is encrypted. |
| ZFS Intent Log (ZIL) | Yes | Synchronous write requests are encrypted. |
| L2ARC (Cache) | Yes | Cached data is stored in an encrypted form. |
| RAM (ARC) | No | Data in the primary ARC, in RAM, is not encrypted. |
| Swap Area | Conditional | Encrypted if the ZFS swap dataset is encrypted. |
| ZFS Metadata | Yes | Metadata is encrypted for encrypted datasets. |
| Snapshot Data | Yes | Snapshots of encrypted datasets are also encrypted. |
| ZFS Send/Receive | Conditional | Encrypted during send/receive if datasets are encrypted and `-w` flag is used. |


### Snapshots

ZFS snapshots are one of the things about zfs that are a really big deal
Expand Down