#!/usr/bin/env bash # Longhorn prerequisites on one k3s worker. Run on each worker (141-143): # ssh un-oeil@10.0.0.141 'sudo bash -s' < scripts/prep-worker.sh # # Formats /dev/sdb, the worker's own empty 200 GB disk. On the Proxmox host # that disk is the zvol hdd-mirror/vm-disks/vm-14x-disk-0, separate from # /hdd-mirror/vzdump-backups and hdd-mirror/restic-repo. The script stops if # sdb already has a filesystem or partitions. set -euo pipefail DISK=/dev/sdb MNT=/var/lib/longhorn [ "$(lsblk -dno SIZE "$DISK" | tr -d " ")" = "200G" ] || { echo "$DISK is not the 200G Longhorn disk, stopping."; exit 1; } if [ -n "$(blkid -o value -s TYPE "$DISK" 2>/dev/null)" ] || [ "$(lsblk -no NAME "$DISK" | wc -l)" -gt 1 ]; then if findmnt -no SOURCE "$MNT" | grep -q "^$DISK$"; then echo "$DISK already mounted on $MNT, skipping the disk part." else echo "$DISK already has data and isn't mounted on $MNT, stopping."; exit 1 fi else mkfs.ext4 -L longhorn "$DISK" mkdir -p "$MNT" echo "LABEL=longhorn $MNT ext4 defaults,noatime 0 2" >> /etc/fstab mount "$MNT" fi apt-get update -qq apt-get install -y -qq open-iscsi nfs-common systemctl enable --now iscsid modprobe iscsi_tcp echo iscsi_tcp > /etc/modules-load.d/longhorn.conf # multipathd grabs Longhorn's devices if it's running. systemctl disable --now multipathd.service multipathd.socket 2>/dev/null || true df -h "$MNT"; systemctl is-active iscsid