hetzner-dedicated/zfs: Install zfs from source

This commit is contained in:
Akshay Mankar 2023-10-13 17:00:03 +02:00
parent b43348a690
commit 02a4ad2e18
Signed by: axeman
GPG key ID: CA08F3AB62369B89

View file

@ -26,20 +26,27 @@
# * exports of env vars are added throughout the script in case you want to run it manually
export LC_ALL=C
# WARNING: on 2023/07/16 the rescue system of hetzner boots with kernel 6.3.7 which
set -euox pipefail
# ORIGINAL WARNING: on 2023/07/16 the rescue system of hetzner boots with kernel 6.3.7 which
# is by default not supported by the latest debian package. You need to update to debian
# unstable to proceed with the zfs installation.
cat > /etc/apt/preferences.d/90_zfs <<EOF
Package: libnvpair1linux libnvpair3linux libuutil1linux libuutil3linux libzfs2linux libzfs4linux libzpool2linux libzpool4linux spl-dkms zfs-dkms zfs-test zfsutils-linux zfsutils-linux-dev zfs-zed
Pin: release n=bullseye-backports
Pin-Priority: 990
EOF
# NEW WARNING: Upgrading to unstable is too much work, maybe just downloading zfs and building it is easier.
apt update -y
apt install -y dpkg-dev linux-headers-$(uname -r) linux-image-amd64 sudo parted zfs-dkms zfsutils-linux
apt update
apt install -y dpkg-dev linux-headers-$(uname -r) linux-image-amd64 sudo parted
set -euox pipefail
cd "$(mktemp -d)"
wget "$(curl -Ls https://api.github.com/repos/openzfs/zfs/releases/latest| grep -E "browser_download_url.*\.tar.gz\"$"| cut -d '"' -f 4)"
apt update
apt install libssl-dev uuid-dev zlib1g-dev libblkid-dev -y
tar xfv zfs*.tar.gz && rm zfs*.tar.gz
cd zfs*
./configure && make -j "$(nproc)"
make install
ldconfig
modprobe zfs
# hetzner has some weird symlinks to make you install zfs with their script
rm /usr/local/sbin/zfs || true
@ -176,9 +183,6 @@ mdadm --zero-superblock --force $DISK2-part3 || true
# See https://github.com/NixOS/nixpkgs/issues/62444
udevadm trigger
# Sometimes the zfs module is not loaded
modprobe zfs
# taken from https://nixos.wiki/wiki/NixOS_on_ZFS
# somehow there is a weird symlink in the default zfs
zpool create -O mountpoint=none \