Skip to content

Commit

Permalink
update to new rescue (#43)
Browse files Browse the repository at this point in the history
updated to new rescue, added script for ubuntu 22
  • Loading branch information
terem42 committed Apr 21, 2023
1 parent e26d27f commit ad8f762
Show file tree
Hide file tree
Showing 6 changed files with 906 additions and 52 deletions.
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![shellcheck](https://github.com/terem42/zfs-hetzner-vm/actions/workflows/shellcheck.yml/badge.svg)](https://github.com/terem42/zfs-hetzner-vm/actions/workflows/shellcheck.yml)

Scripts to install Debian 11, 10 or Ubuntu 20, 18 with ZFS root on Hetzner root servers (virtual and dedicated).<br/>
Scripts to install Debian 11, 10 or Ubuntu 18 LTS, 20 LTS, 22 LTS with ZFS root on Hetzner root servers (virtual and dedicated).<br/>
__WARNING:__ all data on the disk will be destroyed.

## How to use:
Expand All @@ -12,28 +12,34 @@ __WARNING:__ all data on the disk will be destroyed.
* Click "enable rescue and power cycle", add SSH key to the rescue console, set it OS to linux64, then press mount rescue and power cycle" button.
* connect via SSH to rescue console, and run the script from this repo.

Debian 10 minimal setup with SSH server

````bash
wget -qO- https://raw.githubusercontent.com/terem42/zfs-hetzner-vm/master/hetzner-debian10-zfs-setup.sh | bash -
````

Debian 11 minimal setup with SSH server

````bash
wget -qO- https://raw.githubusercontent.com/terem42/zfs-hetzner-vm/master/hetzner-debian11-zfs-setup.sh | bash -
````

Ubuntu 20 LTS minimal setup with SSH server
Ubuntu 18.04 LTS minimal setup with SSH server

````bash
wget -qO- https://raw.githubusercontent.com/terem42/zfs-hetzner-vm/master/hetzner-ubuntu20-zfs-setup.sh | bash -
wget -qO- https://raw.githubusercontent.com/terem42/zfs-hetzner-vm/master/hetzner-ubuntu18-zfs-setup.sh | bash -
````

Debian 10 minimal setup with SSH server
Ubuntu 20 LTS minimal setup with SSH server

````bash
wget -qO- https://raw.githubusercontent.com/terem42/zfs-hetzner-vm/master/hetzner-debian10-zfs-setup.sh | bash -
wget -qO- https://raw.githubusercontent.com/terem42/zfs-hetzner-vm/master/hetzner-ubuntu20-zfs-setup.sh | bash -
````

Ubuntu 18.04 LTS minimal setup with SSH server
Ubuntu 22 LTS minimal setup with SSH server

````bash
wget -qO- https://raw.githubusercontent.com/terem42/zfs-hetzner-vm/master/hetzner-ubuntu18-zfs-setup.sh | bash -
wget -qO- https://raw.githubusercontent.com/terem42/zfs-hetzner-vm/master/hetzner-ubuntu22-zfs-setup.sh | bash -
````

Answer script questions about desired hostname and ZFS ARC cache size.
Expand Down
34 changes: 20 additions & 14 deletions hetzner-debian10-zfs-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ function initial_load_debian_zed_cache {

SECONDS=0

while (( SECONDS++ <= 120 )); do
while (( SECONDS++ <= 300 )); do
if [[ -e /mnt/etc/zfs/zfs-list.cache/rpool ]] && (( $(find /mnt/etc/zfs/zfs-list.cache/rpool -type f -printf '%s' 2> /dev/null) > 0 )); then
success=1
break
Expand Down Expand Up @@ -494,13 +494,7 @@ done
echo "======= installing zfs on rescue system =========="
echo "zfs-dkms zfs-dkms/note-incompatible-licenses note true" | debconf-set-selections
apt-get install --yes software-properties-common
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 8CF63AD3F06FC659
add-apt-repository 'deb http://ppa.launchpad.net/jonathonf/zfs/ubuntu focal main'
apt update
apt install --yes zfs-dkms zfsutils-linux
add-apt-repository -r 'deb http://ppa.launchpad.net/jonathonf/zfs/ubuntu focal main'
apt update
find /usr/local/sbin/ -type l -exec rm {} +
echo "y" | zfs
zfs --version

echo "======= partitioning the disk =========="
Expand Down Expand Up @@ -543,14 +537,14 @@ echo "======= create zfs pools and datasets =========="

# shellcheck disable=SC2086
zpool create \
"$v_bpool_tweaks" -O canmount=off -O devices=off \
-o cachefile=/etc/zfs/zpool.cache \
$v_bpool_tweaks -O canmount=off -O devices=off \
-o cachefile=/etc/zpool.cache \
-O mountpoint=/boot -R $c_zfs_mount_dir -f \
$v_bpool_name $pools_mirror_option "${bpool_disks_partitions[@]}"

# shellcheck disable=SC2086
echo -n "$v_passphrase" | zpool create \
-o cachefile=/etc/zfs/zpool.cache \
-o cachefile=/etc/zpool.cache \
$v_rpool_tweaks \
"${encryption_options[@]}" \
-O mountpoint=/ -R $c_zfs_mount_dir -f \
Expand Down Expand Up @@ -741,7 +735,7 @@ echo "======= set root password =========="
chroot_execute "echo root:$(printf "%q" "$v_root_password") | chpasswd"

echo "======= setting up zfs cache =========="
cp /etc/zfs/zpool.cache /mnt/etc/zfs/zpool.cache
cp /etc/zpool.cache /mnt/etc/zfs/zpool.cache

echo "========setting up zfs module parameters========"
chroot_execute "echo options zfs zfs_arc_max=$((v_zfs_arc_max_mb * 1024 * 1024)) >> /etc/modprobe.d/zfs.conf"
Expand Down Expand Up @@ -817,10 +811,22 @@ esac
configure_networking
ip route add 172.31.1.1/255.255.255.255 dev ens3
ip route add default via 172.31.1.1 dev ens3
ip route add 172.31.1.1/255.255.255.255 dev eth0
ip route add default via 172.31.1.1 dev eth0
CONF

cat > "$c_zfs_mount_dir/etc/network/interfaces" <<'CONF'
auto lo
iface lo inet loopback
iface lo inet6 loopback
auto eth0
iface eth0 inet dhcp
iface eth0 inet6 dhcp
CONF

chmod 755 "$c_zfs_mount_dir/etc/network/interfaces"

echo "======= update initramfs =========="
chroot_execute "update-initramfs -u -k all"

Expand Down
22 changes: 9 additions & 13 deletions hetzner-debian11-zfs-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -495,13 +495,7 @@ done
echo "======= installing zfs on rescue system =========="
echo "zfs-dkms zfs-dkms/note-incompatible-licenses note true" | debconf-set-selections
apt-get install --yes software-properties-common
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 8CF63AD3F06FC659
add-apt-repository 'deb http://ppa.launchpad.net/jonathonf/zfs/ubuntu focal main'
apt update
apt install --yes zfs-dkms zfsutils-linux
add-apt-repository -r 'deb http://ppa.launchpad.net/jonathonf/zfs/ubuntu focal main'
apt update
find /usr/local/sbin/ -type l -exec rm {} +
echo "y" | zfs
zfs --version

echo "======= partitioning the disk =========="
Expand Down Expand Up @@ -545,14 +539,14 @@ echo "======= create zfs pools and datasets =========="
# shellcheck disable=SC2086
zpool create \
$v_bpool_tweaks -O canmount=off -O devices=off \
-o cachefile=/etc/zfs/zpool.cache \
-o cachefile=/etc/zpool.cache \
-O mountpoint=/boot -R $c_zfs_mount_dir -f \
$v_bpool_name $pools_mirror_option "${bpool_disks_partitions[@]}"

# shellcheck disable=SC2086
echo -n "$v_passphrase" | zpool create \
$v_rpool_tweaks \
-o cachefile=/etc/zfs/zpool.cache \
-o cachefile=/etc/zpool.cache \
"${encryption_options[@]}" \
-O mountpoint=/ -R $c_zfs_mount_dir -f \
$v_rpool_name $pools_mirror_option "${rpool_disks_partitions[@]}"
Expand Down Expand Up @@ -718,7 +712,7 @@ if [[ $v_zfs_experimental == "1" ]]; then
chroot_execute "apt update"
chroot_execute "apt install -t zfs-debian-experimental --yes zfs-initramfs zfs-dkms zfsutils-linux"
else
chroot_execute "apt install --yes zfs-initramfs zfs-dkms zfsutils-linux"
chroot_execute "apt install -t bullseye-backports --yes zfs-initramfs zfs-dkms zfsutils-linux"
fi
chroot_execute 'cat << DKMS > /etc/dkms/zfs.conf
# override for /usr/src/zfs-*/dkms.conf:
Expand All @@ -743,7 +737,7 @@ chroot_execute "echo root:$(printf "%q" "$v_root_password") | chpasswd"

echo "======= setting up zfs cache =========="

cp /etc/zfs/zpool.cache /mnt/etc/zfs/zpool.cache
cp /etc/zpool.cache /mnt/etc/zfs/zpool.cache

echo "========setting up zfs module parameters========"
chroot_execute "echo options zfs zfs_arc_max=$((v_zfs_arc_max_mb * 1024 * 1024)) >> /etc/modprobe.d/zfs.conf"
Expand Down Expand Up @@ -820,12 +814,14 @@ esac
configure_networking
ip route add 172.31.1.1/255.255.255.255 dev ens3
ip route add default via 172.31.1.1 dev ens3
ip route add 172.31.1.1/255.255.255.255 dev eth0
ip route add default via 172.31.1.1 dev eth0
CONF

chmod 755 "$c_zfs_mount_dir/usr/share/initramfs-tools/scripts/init-premount/static-route"

chmod 755 "$c_zfs_mount_dir/etc/network/interfaces"

echo "======= update initramfs =========="
chroot_execute "update-initramfs -u -k all"

Expand Down
14 changes: 4 additions & 10 deletions hetzner-ubuntu18-zfs-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -462,13 +462,7 @@ done
echo "======= installing zfs on rescue system =========="
echo "zfs-dkms zfs-dkms/note-incompatible-licenses note true" | debconf-set-selections
apt-get install --yes software-properties-common
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 8CF63AD3F06FC659
add-apt-repository 'deb http://ppa.launchpad.net/jonathonf/zfs/ubuntu focal main'
apt update
apt install --yes zfs-dkms zfsutils-linux
add-apt-repository -r 'deb http://ppa.launchpad.net/jonathonf/zfs/ubuntu focal main'
apt update
find /usr/local/sbin/ -type l -exec rm {} +
echo "y" | zfs
zfs --version

echo "======= partitioning the disk =========="
Expand Down Expand Up @@ -512,14 +506,14 @@ echo "======= create zfs pools and datasets =========="
# shellcheck disable=SC2086
zpool create \
$v_bpool_tweaks -O canmount=off -O devices=off \
-o cachefile=/etc/zfs/zpool.cache \
-o cachefile=/etc/zpool.cache \
-O mountpoint=/boot -R $c_zfs_mount_dir -f \
$v_bpool_name $pools_mirror_option "${bpool_disks_partitions[@]}"

# shellcheck disable=SC2086
echo -n "$v_passphrase" | zpool create \
$v_rpool_tweaks \
-o cachefile=/etc/zfs/zpool.cache \
-o cachefile=/etc/zpool.cache \
"${encryption_options[@]}" \
-O mountpoint=/ -R $c_zfs_mount_dir -f \
$v_rpool_name $pools_mirror_option "${rpool_disks_partitions[@]}"
Expand Down Expand Up @@ -724,7 +718,7 @@ echo "======= set root password =========="
chroot_execute "echo root:$(printf "%q" "$v_root_password") | chpasswd"

echo "======= setting up zfs cache =========="
cp /etc/zfs/zpool.cache /mnt/etc/zfs/zpool.cache
cp /etc/zpool.cache /mnt/etc/zfs/zpool.cache

echo "========setting up zfs module parameters========"
chroot_execute "echo options zfs zfs_arc_max=$((v_zfs_arc_max_mb * 1024 * 1024)) >> /etc/modprobe.d/zfs.conf"
Expand Down
15 changes: 7 additions & 8 deletions hetzner-ubuntu20-zfs-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -461,9 +461,8 @@ done

echo "======= installing zfs on rescue system =========="
echo "zfs-dkms zfs-dkms/note-incompatible-licenses note true" | debconf-set-selections
apt update
apt install -t bullseye-backports --yes zfs-dkms zfsutils-linux
find /usr/local/sbin/ -type l -exec rm {} +
apt-get install --yes software-properties-common
echo "y" | zfs
zfs --version

echo "======= partitioning the disk =========="
Expand Down Expand Up @@ -507,14 +506,14 @@ echo "======= create zfs pools and datasets =========="
# shellcheck disable=SC2086
zpool create \
$v_bpool_tweaks -O canmount=off -O devices=off \
-o cachefile=/etc/zfs/zpool.cache \
-o cachefile=/etc/zpool.cache \
-O mountpoint=/boot -R $c_zfs_mount_dir -f \
$v_bpool_name $pools_mirror_option "${bpool_disks_partitions[@]}"

# shellcheck disable=SC2086
echo -n "$v_passphrase" | zpool create \
$v_rpool_tweaks \
-o cachefile=/etc/zfs/zpool.cache \
-o cachefile=/etc/zpool.cache \
"${encryption_options[@]}" \
-O mountpoint=/ -R $c_zfs_mount_dir -f \
$v_rpool_name $pools_mirror_option "${rpool_disks_partitions[@]}"
Expand Down Expand Up @@ -675,10 +674,10 @@ chroot_execute "rm -f /etc/localtime /etc/timezone"
chroot_execute "dpkg-reconfigure tzdata -f noninteractive "

echo "======= installing latest kernel============="
chroot_execute "DEBIAN_FRONTEND=noninteractive apt install --yes linux-headers${v_kernel_variant}-hwe-18.04 linux-image${v_kernel_variant}-hwe-18.04"
chroot_execute "DEBIAN_FRONTEND=noninteractive apt install --yes linux-headers${v_kernel_variant} linux-image${v_kernel_variant}"
if [[ $v_kernel_variant == "-virtual" ]]; then
# linux-image-extra is only available for virtual hosts
chroot_execute "DEBIAN_FRONTEND=noninteractive apt install --yes linux-image-extra-virtual-hwe-20.04"
chroot_execute "DEBIAN_FRONTEND=noninteractive apt install --yes linux-image-extra-virtual"
fi


Expand Down Expand Up @@ -720,7 +719,7 @@ echo "======= set root password =========="
chroot_execute "echo root:$(printf "%q" "$v_root_password") | chpasswd"

echo "======= setting up zfs cache =========="
cp /etc/zfs/zpool.cache /mnt/etc/zfs/zpool.cache
cp /etc/zpool.cache /mnt/etc/zfs/zpool.cache

echo "========setting up zfs module parameters========"
chroot_execute "echo options zfs zfs_arc_max=$((v_zfs_arc_max_mb * 1024 * 1024)) >> /etc/modprobe.d/zfs.conf"
Expand Down
Loading

0 comments on commit ad8f762

Please sign in to comment.