ZFS Build Script

The following shell script (zfs-build-latest.sh) will automatically download the latest OpenZFS release and compile it

Requirements:

  • Build tools (gcc, make etc)
  • autoconf
  • jq (cli json parser)
  • openssl-dev
  • kernel headers that match your installed kernel
  • curl
  • zstandard libs (if zstd support is required)
  • you will have to install other missing libs if required
sudo eopkg it -c system.devel
sudo eopkg it git linux-current-headers libelf-devel libtirpc-devel 
sudo eopkg it jq curl-devel openssl-11-devel
#!/bin/sh

curl -s https://api.github.com/repos/openzfs/zfs/releases/latest > git-release.json
tag=$(jq -r ".tag_name" git-release.json)
jq '.assets[] | select(.content_type == "application/gzip")' git-release.json >latest-asset.json

url=$(jq -r '.browser_download_url' latest-asset.json)
file=$(jq -r '.name' latest-asset.json)

echo "Latest Release: ${tag} : ${file} -> ${url}"
previousTag=""

if [ -f "previous-tag.txt" ]
then
  previousTag=$(cat previous-tag.txt)
fi

if [ "${previousTag}" = "${tag}" ]
then
  echo "Already downloaded this version, compiling..."
fi


if [ ! -f "${file}" ]
then
  echo "Downloading ${url}"
  curl -L "${url}" -O
fi

rm -rf "${tag}"
tar zxf "${file}"
cd "${tag}"

# We try to determine the latest kernel headers here, sometimes this may not work as intended.

./autogen.sh
./configure --with-linux=/usr/src/$(ls -t /usr/src/ | grep linux-headers | head -n 1)
make -j$(nproc)

cd ..
echo "${tag}" >previous-tag.txt

echo "Now you can install with the following commands:"
echo "cd ${tag} && sudo make install && sudo depmod"

Configuration guide here: http://blog.twbc.net/2019/01/07/solus-linux-openzfs/