Skip to content

Instantly share code, notes, and snippets.

@dreamcat4
Created April 14, 2020 08:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dreamcat4/fd7d39c47ac361277283641ba6d68e66 to your computer and use it in GitHub Desktop.
Save dreamcat4/fd7d39c47ac361277283641ba6d68e66 to your computer and use it in GitHub Desktop.
How to install zfs (latest) on ubuntu (latest) with kernel (latest), as of 14th April 2020, with the patches
# ======
# install zfs from source (instructions for ubuntu)
# last tested (worked for me!) on ubuntu 19.10, kernel 5.6.2, zfs-0.8.3
#
# https://github.com/zfsonlinux/zfs/wiki/Building-ZFS
# https://github.com/zfsonlinux/zfs/wiki/Custom-Packages#debian-and-ubuntu
sudo apt install -y build-essential pkg-config autoconf libtool gawk alien fakeroot gdebi wget zlib1g-dev uuid-dev libattr1-dev libblkid-dev libselinux-dev libudev-dev libaio-dev parted lsscsi ksh libssl-dev libelf-dev linux-headers-$(uname -r) python3 python3-dev python3-setuptools python3-cffi < /dev/null
git clone https://github.com/zfsonlinux/zfs.git
cd zfs
# checkout latest release
_newest_release="$(git tag | grep -v -E "\-rc" | sort | tail -1)"
git checkout $_newest_release
# for example:
# git checkout zfs-0.8.3
# apply patches
if ! grep "#if defined(HAVE_BLKG_TRYGET_GPL_ONLY)" module/zfs/vdev_disk.c; then
# patch for kernel 5.5
# presumed fixed in 0.8.4
wget -O "zfs-0.8.3-kernel.5.5-dkms-build.2fcab8795c7c493845bfa277d44bc443802000b8.patch" "https://github.com/openzfs/zfs/commit/2fcab8795c7c493845bfa277d44bc443802000b8.patch"
patch -p1 < "zfs-0.8.3-kernel.5.5-dkms-build.2fcab8795c7c493845bfa277d44bc443802000b8.patch"
rm "zfs-0.8.3-kernel.5.5-dkms-build.2fcab8795c7c493845bfa277d44bc443802000b8.patch"
fi
if [ $(echo "5.6 > $(grep "Linux-Maximum:" META | sed -e "s/.*: //g")" | bc) -eq 1 ]; then
# patch for kernel 5.6
# presumed fixed in 0.8.4
if ! grep -q "5.6 API change" config/*; then
wget -O "zfs-Linux-5.6-compat-PR9961_reformatted-patch-for-0.8.3_k5.6.3.patch" "https://gist.githubusercontent.com/satmandu/67cbae9c4d461be0e64428a1707aef1c/raw/ba0fb65f17ccce5b710e4ce86a095de577f7dfe1/k5.6.3.patch"
patch -p1 < "zfs-Linux-5.6-compat-PR9961_reformatted-patch-for-0.8.3_k5.6.3.patch"
rm "zfs-Linux-5.6-compat-PR9961_reformatted-patch-for-0.8.3_k5.6.3.patch"
fi
fi
# build zfs
./autogen.sh
./configure --with-config=user
make -s -j$(nproc)
make -j1 deb-dkms
make -j1 deb-utils
# # build with debugging info
# make -j$(nproc) --print-data-base
# make -j1 --print-data-base deb-dkms
# make -j1 --debug=b
# make -j1 --debug=b deb-dkms
# make sure that newest version of dkms is installed
sudo apt-get install -y dkms
# install new debs
# for file in *.deb; do sudo gdebi -n $file || break; done
for file in *.deb; do echo "installing ${file} ..."; sudo gdebi --non-interactive $file || break; done
# install them again - not sure which method is best, so i do them both
for file in *.deb; do
echo "installing ${file} ..."
sudo apt install -y --allow-downgrades ./${file} || break
done
# add zfs modules to initramfs
# grep -q -E "^zfs$" /etc/modules || echo "zfs" | sudo tee -a /etc/modules > /dev/null
grep -q -E "^zfs$" /etc/initramfs-tools/modules || echo "zfs" | sudo tee -a /etc/initramfs-tools/modules > /dev/null
# enable remounting after boot
sudo systemctl enable zfs-import-cache zfs-import-scan zfs-mount zfs-share zfs-zed zfs.target
# this one was not enabled!
sudo systemctl enable zfs-import.target
# done. nearly time to reboot BUT FIRST
# make sure that the new zfs dkms kernel module was build without error
dkms status
# only reboot into a kernel where the zfs module was correctly build
# if necessary, make sure you have alternative 'known good' kernel versions
# also installed. in case there is any issue with your chosen kernel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment