Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
zfs basic usage notes

late 2018 encrypted disk per https://openzfsonosx.org/wiki/Encryption

create new encrypted disk
plug in device
$ diskutil list
important to be absolutely certain of the device
$ sudo zpool create -f -o ashift=12 -O compression=lz4 -O casesensitivity=sensitive -O atime=off -O normalization=formD -O encryption=on -O keylocation=prompt -O keyformat=passphrase NAMEOFIT /dev/disk####
will interactively prompt for passphrase
next time importing plug in the device
import the pool (I assume)
$ sudo zpool import -a
$ zpool status -v
should see whatever was used for NAMEOFIT, now mount that
$ sudo zfs mount -l NAMEOFIT
which will interactively request the passphrase used initially
it'll appear in the finder and at the default mountpoint /Volumes/NAMEOFIT

early 2018 I recently started using the zfs as a way to share external disks between my macOS, Linux and BSD systems. As of late 2017 zfs seems the most robust option for this scenario, with the exception of Windows support. I'm currently moving any Windows machines to virtual or phasing them out, and there's increasing support for Linux in Windows so perhaps zfs will someday work there too--until then shared filesystems of some sort work well (via VirtualBox, ssh, etc).

macOS installer

https://openzfsonosx.org/ Github issues, wiki* and other forums linked from here have excellent, timely, direct responses. Note that encryption support was recently added--I haven't used it yet.

my slightly generalized, basic notes:

plug in drive
$ diskutil list

find device reference "diskN", eg disk42 (confirm size, etc to correlate the appropriate one, NOT your existing drive)
$ sudo zpool create -f -o ashift=12 -O compression=lz4 -O casesensitivity=sensitive -O atime=off -O normalization=formD the-chosen-name /dev/diskN

$ zpool status
should show the new pool and it'll show up in the Finder, now fix permissions as-desired and/or setup directories

to mount (I only have one external device)
$ sudo zpool import -a -f
to unmount
$ sudo zpool export -a

at a later date I installed an updated version of zfs for macOS (they are updated regularly)
plug in drive
$ diskutil list

confirmed zfs device with what was used for a name and the size are present
$ sudo zpool import -a -f

after a moderately long pause the prompt returns
$ sudo zpool status

which returns a super helpful message: status: Some supported features are not enabled on the pool. The pool can....
I follow the suggestion in the message:
$ sudo zpool upgrade the-chosen-name
This reports the newly enabled features and I can now see the volume in /Volumes/ for use.

enable encryption on an existing pool
$ sudo zpool set feature@encryption=enabled the-chosen-name

I can now rsync content around, etc.

raspberry pi install source: mohakshah

build+install the latest release version of "ZFS on Linux" on a Raspberry Pi 3 running Raspbian. The dkms version of ZoL, which saves the hassle of re-compiling the kernel modules after every kernel update. Even though ZoL added support for building dkms packages for debian in version 0.7.3, the build process on a Raspberry Pi 3 is not quite straight-forward.

install dependencies
$ sudo apt-get update
$ sudo apt-get install build-essential autoconf libtool gawk alien fakeroot
$ sudo apt-get install zlib1g-dev uuid-dev libattr1-dev libblkid-dev libselinux-dev libudev-dev libssl-dev parted lsscsi wget ksh

need the kernel headers. Running apt-get upgrade will take care of both installation and upgradation
$ sudo apt-get upgrade raspberrypi-kernel raspberrypi-kernel-headers

get the source zfs and spl from github.com/zfsonlinux/zfs/releases
$ wget https://github.com/zfsonlinux/zfs/releases/download/zfs-?.?.?/spl-?.?.?.tar.gz
$ wget https://github.com/zfsonlinux/zfs/releases/download/zfs-?.?.?/zfs-?.?.?.tar.gz
$ tar -xzf spl-*.tar.gz && tar -xzf zfs-*.tar.gz

compile + install, including fix to makefile
$ cd spl-?.?.?
$ autoreconf --install --force
$ ./configure
$ sed -E 's/(^RPMBUILD = rpmbuild.*)/\1 --target=armhf/' -i Makefile
$ make pkg-utils deb-dkms
$ for deb in *.deb; do sudo dpkg -i "$deb"; done

compile + install, zfs source is much bigger than spl's and hence the build time will also be much longer
$ cd ../zfs-?.?.?/
$ autoreconf --install --force
$ ./configure --with-config=srpm
$ sed -E 's/(^RPMBUILD = rpmbuild.*)/\1 --target=armhf/' -i Makefile
$ make pkg-utils deb-dkms
$ for deb in *.deb; do sudo dpkg -i "$deb"; done

reboot to use

sources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.