Benutzer-Werkzeuge

Webseiten-Werkzeuge


commands-zfs

Sammlung nützlicher Befehle

ZFS Commands

list ZFS volumes with exact numbers

zfs list -p

get a property (e.g. canmount) for all present datasets

zfs get -t filesystem canmount

list all snapshots of a volume and its child volumes

zfs list -r -t snapshot -o name,creation,space tank/usr

delete all ZFS snapshots

# the following also deletes children dataset/zvol
zfs destroy -rv tank/dataset_or_zvol@%
# the following greps only snapshots of exactly that dataset/zvol
zfs list -H -o name -t snapshot | grep '^tank/dataset_or_zvol@' | xargs -n1 zfs destroy

delete certain ZFS snapshots (e.g. ezjail's basejail from year 2016)

zfs list -t snapshot -H -o name | grep "basejail@2016" | xargs -n1 echo
zfs list -t snapshot -H -o name | grep "basejail@2016" | xargs -n1 zfs destroy

create a ZVOL of 15 GiB

zfs create -V15G -o volmode=dev tank/vm/diskimage
file /dev/zvol/tank/vm/diskimage

promote a cloned volume

zfs snapshot tank/test/foo@first
zfs snapshot tank/test/foo@second
zfs clone tank/test/foo@second tank/test/bar
zfs snapshot tank/test/foo@third
zfs snapshot tank/test/bar@fourth
zfs list -r -t snapshot -o name,creation -s creation tank/test
# NAME                           CREATION
# tank/test/foo@first   Sun Feb  4 17:03 2018
# tank/test/foo@second  Sun Feb  4 17:04 2018
# tank/test/foo@third   Sun Feb  4 17:05 2018
# tank/test/bar@fourth  Sun Feb  4 17:06 2018
zfs promote tank/test/bar
# after this as if "foo" was cloned from "bar"
zfs list -r -t snapshot -o name,creation -s creation tank/test
# NAME                           CREATION
# tank/test/bar@first   Sun Feb  4 17:03 2018
# tank/test/bar@second  Sun Feb  4 17:04 2018
# tank/test/foo@third   Sun Feb  4 17:05 2018
# tank/test/bar@fourth  Sun Feb  4 17:06 2018

create a pool with a natively encrypted dataset

## create the pool (native encryption is available e.g. in “OpenZFS on OS X”)
zpool create -O encryption=on -O keylocation=prompt -O keyformat=passphrase zextern /dev/disk2s2
## before unplugging the drive
zpool export zextern
## when re-attaching the drive
zpool import zextern
zfs mount -l zextern
Cookies helfen bei der Bereitstellung von Inhalten. Durch die Nutzung dieser Seiten erklären Sie sich damit einverstanden, dass Cookies auf Ihrem Rechner gespeichert werden. Weitere Information
commands-zfs.txt · Zuletzt geändert: 2019/07/01 21:06 von alex