3.2 KiB
3.2 KiB
arch-wiki | website | repo | obj |
---|---|---|---|
https://wiki.archlinux.org/title/ZFS | https://openzfs.org/wiki/Main_Page | https://github.com/openzfs/zfs | filesystem |
#refactor
ZFS
ZFS is an advanced filesystem.
ZPool
Create a pool*
zpool create -f -m <mount> <pool> [raidz(2|3)|mirror] <ids>
Pool Status
zpool status -v
Import Pool
zpool import -l -d /dev/disk/by-id <pool> # Import pool
zpool import -a # Import all available pools
zpool import -a -f # Import all available pools with force option
Export Pool
zpool export <pool>
Extend Pool
zpool add <pool> <device-id>
Destroy pool / dataset
zpool destroy <pool>
zfs destroy <pool>/<dataset>
Rename a pool
zpool export oldname
zpool import oldname newname
Upgrade pool
zpool upgrade <pool>
Automount
Specify this for zfs-import-cache.service
to pick up the pool
zpool set cachefile=/etc/zfs/zpool.cache <pool>
Datasets
Creation
Create Dataset
zfs create <nameofzpool>/<nameofdataset>
Create encrypted dataset:
dd if=/dev/random of=/path/to/key bs=1 count=32 # Generate key
zfs create -o encryption=on -o keyformat=raw -o keylocation=file://$KEYLOCATION "$DATASET"
Load all encryption keys
zfs load-key -a
Load all keys at boot with systemd
/etc/systemd/system/zfs-load-key.service:
[Unit]
Description=Load encryption keys
DefaultDependencies=no
After=zfs-import.target
Before=zfs-mount.service
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/zfs load-key -a
StandardInput=tty-force
[Install]
WantedBy=zfs-mount.service
Snapshots
Create snapshot:
zfs snapshot <pool>/<dataset>@<snapshot>
Send and receive:
zfs send -v -w <pool>/<dataset>@<snapshot> | zfs recv <pool>/<newdataset>
Properties
Get properties:
zfs get <property> <pool>/<dataset>
Set properties
zfs set <property>=<value> <pool>/<dataset>
Available Properties
compressratio
: Shows information on compressioncreation
: Get creation datemounted
: Status on mountused
: Information on usagecanmount
: Forbid or enable mountingcasesensitivity
: Choose sensitivitycompression
: Choose compression methodencryption
: Encryption Informationmountpoint
: Specify the mountpointquota
: Filesystem Quotareadonly
: Readonly or Readwritereservation
: Reserved Space
Scrub
Like Btrfs ZFS can heal itself with scrubbing
Start a scrub:
zpool scrub <pool>
Cancel a scrub:
zpool scrub -s <pool>
Autoscrubbing with systemd:
/etc/systemd/system/zfs-scrub@.timer
[Unit]
Description=Monthly zpool scrub on %i
[Timer]
OnCalendar=monthly
AccuracySec=1h
Persistent=true
[Install]
WantedBy=multi-user.target
/etc/systemd/system/zfs-scrub@.service
[Unit]
Description=zpool scrub on %i
[Service]
Nice=19
IOSchedulingClass=idle
KillSignal=SIGINT
ExecStart=/usr/bin/zpool scrub %i
[Install]
WantedBy=multi-user.target