mirror of
https://github.com/terem42/zfs-hetzner-vm.git
synced 2025-12-23 07:18:37 +00:00
Compare commits
1 Commits
encr
...
terem42-pa
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4c29270339 |
10
README.md
10
README.md
@@ -2,7 +2,7 @@
|
||||
|
||||
[](https://github.com/terem42/zfs-hetzner-vm/actions/workflows/shellcheck.yml)
|
||||
|
||||
Scripts to install Debian 10, 11, 12 or Ubuntu 18 LTS, 20 LTS, 22 LTS 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:
|
||||
@@ -24,12 +24,6 @@ Debian 11 minimal setup with SSH server
|
||||
wget -qO- https://raw.githubusercontent.com/terem42/zfs-hetzner-vm/master/hetzner-debian11-zfs-setup.sh | bash -
|
||||
````
|
||||
|
||||
Debian 12 minimal setup with SSH server
|
||||
|
||||
````bash
|
||||
wget -qO- https://raw.githubusercontent.com/terem42/zfs-hetzner-vm/master/hetzner-debian12-zfs-setup.sh | bash -
|
||||
````
|
||||
|
||||
Ubuntu 18.04 LTS minimal setup with SSH server
|
||||
|
||||
````bash
|
||||
@@ -54,7 +48,7 @@ To cope with network failures its higly recommended to run the commands above in
|
||||
Example of screen utility usage:
|
||||
|
||||
````bash
|
||||
export LC_ALL=en_US.UTF-8 && screen -S zfs
|
||||
screen -S zfs
|
||||
````
|
||||
To detach from screen console, hit Ctrl-d then a
|
||||
To reattach, type `screen -r zfs`
|
||||
|
||||
@@ -17,8 +17,6 @@ set -o errexit
|
||||
set -o pipefail
|
||||
set -o nounset
|
||||
|
||||
export TMPDIR=/tmp
|
||||
|
||||
# Variables
|
||||
v_bpool_name=
|
||||
v_bpool_tweaks=
|
||||
@@ -494,20 +492,9 @@ for kver in $(find /lib/modules/* -maxdepth 0 -type d | grep -v "$(uname -r)" |
|
||||
done
|
||||
|
||||
echo "======= installing zfs on rescue system =========="
|
||||
echo "zfs-dkms zfs-dkms/note-incompatible-licenses note true" | debconf-set-selections
|
||||
# echo "y" | zfs
|
||||
# linux-headers-generic linux-image-generic
|
||||
apt install --yes software-properties-common dpkg-dev dkms
|
||||
rm -f "$(which zfs)"
|
||||
rm -f "$(which zpool)"
|
||||
echo -e "deb http://deb.debian.org/debian/ testing main contrib non-free\ndeb http://deb.debian.org/debian/ testing main contrib non-free\n" >/etc/apt/sources.list.d/bookworm-testing.list
|
||||
echo -e "Package: src:zfs-linux\nPin: release n=testing\nPin-Priority: 990\n" > /etc/apt/preferences.d/90_zfs
|
||||
apt update
|
||||
apt install -t testing --yes zfs-dkms zfsutils-linux
|
||||
rm /etc/apt/sources.list.d/bookworm-testing.list
|
||||
rm /etc/apt/preferences.d/90_zfs
|
||||
apt update
|
||||
export PATH=$PATH:/usr/sbin
|
||||
echo "zfs-dkms zfs-dkms/note-incompatible-licenses note true" | debconf-set-selections
|
||||
apt-get install --yes software-properties-common
|
||||
echo "y" | zfs
|
||||
zfs --version
|
||||
|
||||
echo "======= partitioning the disk =========="
|
||||
@@ -573,7 +560,9 @@ zfs create -o canmount=noauto -o mountpoint=/boot "$v_bpool_name/BOOT/debian"
|
||||
zfs mount "$v_bpool_name/BOOT/debian"
|
||||
|
||||
zfs create "$v_rpool_name/home"
|
||||
zfs create -o mountpoint=/root "$v_rpool_name/home/root"
|
||||
zfs create -o canmount=off "$v_rpool_name/var"
|
||||
zfs create -o canmount=off "$v_rpool_name/var/lib"
|
||||
zfs create "$v_rpool_name/var/log"
|
||||
zfs create "$v_rpool_name/var/spool"
|
||||
|
||||
@@ -624,7 +613,7 @@ ff02::2 ip6-allrouters
|
||||
ff02::3 ip6-allhosts
|
||||
CONF
|
||||
|
||||
ip6addr_prefix=$(ip -6 a s | grep -E "inet6.+global" | sed -nE 's/.+inet6\s(([0-9a-z]{1,4}:){4,4}).+/\1/p' | head -n 1)
|
||||
ip6addr_prefix=$(ip -6 a s | grep -E "inet6.+global" | sed -nE 's/.+inet6\s(([0-9a-z]{1,4}:){4,4}).+/\1/p')
|
||||
|
||||
cat <<CONF > /mnt/etc/systemd/network/10-eth0.network
|
||||
[Match]
|
||||
@@ -638,6 +627,9 @@ CONF
|
||||
chroot_execute "systemctl enable systemd-networkd.service"
|
||||
chroot_execute "systemctl enable systemd-resolved.service"
|
||||
|
||||
|
||||
cp /etc/resolv.conf $c_zfs_mount_dir/etc/resolv.conf
|
||||
|
||||
echo "======= preparing the jail for chroot =========="
|
||||
for virtual_fs_dir in proc sys dev; do
|
||||
mount --rbind "/$virtual_fs_dir" "$c_zfs_mount_dir/$virtual_fs_dir"
|
||||
@@ -769,8 +761,7 @@ if [[ $v_encrypt_rpool == "1" ]]; then
|
||||
echo "=========set up dropbear=============="
|
||||
|
||||
chroot_execute "apt install --yes dropbear-initramfs"
|
||||
|
||||
mkdir -p "$c_zfs_mount_dir/etc/dropbear-initramfs"
|
||||
|
||||
cp /root/.ssh/authorized_keys "$c_zfs_mount_dir/etc/dropbear-initramfs/authorized_keys"
|
||||
|
||||
cp "$c_zfs_mount_dir/etc/ssh/ssh_host_rsa_key" "$c_zfs_mount_dir/etc/ssh/ssh_host_rsa_key_temp"
|
||||
@@ -797,7 +788,6 @@ CONF
|
||||
|
||||
echo "========running packages upgrade==========="
|
||||
chroot_execute "apt upgrade --yes"
|
||||
chroot_execute "apt purge cryptsetup* --yes"
|
||||
|
||||
echo "===========add static route to initramfs via hook to add default routes for Hetzner due to Debian/Ubuntu initramfs DHCP bug ========="
|
||||
mkdir -p "$c_zfs_mount_dir/usr/share/initramfs-tools/scripts/init-premount"
|
||||
@@ -830,7 +820,7 @@ auto lo
|
||||
iface lo inet loopback
|
||||
iface lo inet6 loopback
|
||||
|
||||
allow-hotplug eth0
|
||||
auto eth0
|
||||
iface eth0 inet dhcp
|
||||
iface eth0 inet6 dhcp
|
||||
CONF
|
||||
|
||||
@@ -17,8 +17,6 @@ set -o errexit
|
||||
set -o pipefail
|
||||
set -o nounset
|
||||
|
||||
export TMPDIR=/tmp
|
||||
|
||||
# Variables
|
||||
v_bpool_name=
|
||||
v_bpool_tweaks=
|
||||
@@ -495,20 +493,9 @@ for kver in $(find /lib/modules/* -maxdepth 0 -type d | grep -v "$(uname -r)" |
|
||||
done
|
||||
|
||||
echo "======= installing zfs on rescue system =========="
|
||||
echo "zfs-dkms zfs-dkms/note-incompatible-licenses note true" | debconf-set-selections
|
||||
# echo "y" | zfs
|
||||
# linux-headers-generic linux-image-generic
|
||||
apt install --yes software-properties-common dpkg-dev dkms
|
||||
rm -f "$(which zfs)"
|
||||
rm -f "$(which zpool)"
|
||||
echo -e "deb http://deb.debian.org/debian/ testing main contrib non-free\ndeb http://deb.debian.org/debian/ testing main contrib non-free\n" >/etc/apt/sources.list.d/bookworm-testing.list
|
||||
echo -e "Package: src:zfs-linux\nPin: release n=testing\nPin-Priority: 990\n" > /etc/apt/preferences.d/90_zfs
|
||||
apt update
|
||||
apt install -t testing --yes zfs-dkms zfsutils-linux
|
||||
rm /etc/apt/sources.list.d/bookworm-testing.list
|
||||
rm /etc/apt/preferences.d/90_zfs
|
||||
apt update
|
||||
export PATH=$PATH:/usr/sbin
|
||||
echo "zfs-dkms zfs-dkms/note-incompatible-licenses note true" | debconf-set-selections
|
||||
apt-get install --yes software-properties-common
|
||||
echo "y" | zfs
|
||||
zfs --version
|
||||
|
||||
echo "======= partitioning the disk =========="
|
||||
@@ -574,7 +561,9 @@ zfs create -o canmount=noauto -o mountpoint=/boot "$v_bpool_name/BOOT/debian"
|
||||
zfs mount "$v_bpool_name/BOOT/debian"
|
||||
|
||||
zfs create "$v_rpool_name/home"
|
||||
zfs create -o mountpoint=/root "$v_rpool_name/home/root"
|
||||
zfs create -o canmount=off "$v_rpool_name/var"
|
||||
zfs create -o canmount=off "$v_rpool_name/var/lib"
|
||||
zfs create "$v_rpool_name/var/log"
|
||||
zfs create "$v_rpool_name/var/spool"
|
||||
|
||||
@@ -625,7 +614,7 @@ ff02::2 ip6-allrouters
|
||||
ff02::3 ip6-allhosts
|
||||
CONF
|
||||
|
||||
ip6addr_prefix=$(ip -6 a s | grep -E "inet6.+global" | sed -nE 's/.+inet6\s(([0-9a-z]{1,4}:){4,4}).+/\1/p' | head -n 1)
|
||||
ip6addr_prefix=$(ip -6 a s | grep -E "inet6.+global" | sed -nE 's/.+inet6\s(([0-9a-z]{1,4}:){4,4}).+/\1/p')
|
||||
|
||||
cat <<CONF > /mnt/etc/systemd/network/10-eth0.network
|
||||
[Match]
|
||||
@@ -639,7 +628,8 @@ CONF
|
||||
chroot_execute "systemctl enable systemd-networkd.service"
|
||||
chroot_execute "systemctl enable systemd-resolved.service"
|
||||
|
||||
#cp /etc/resolv.conf $c_zfs_mount_dir/etc/resolv.conf
|
||||
|
||||
cp /etc/resolv.conf $c_zfs_mount_dir/etc/resolv.conf
|
||||
|
||||
echo "======= preparing the jail for chroot =========="
|
||||
for virtual_fs_dir in proc sys dev; do
|
||||
@@ -774,22 +764,21 @@ if [[ $v_encrypt_rpool == "1" ]]; then
|
||||
echo "=========set up dropbear=============="
|
||||
|
||||
chroot_execute "apt install --yes dropbear-initramfs"
|
||||
|
||||
mkdir -p "$c_zfs_mount_dir/etc/dropbear/initramfs"
|
||||
cp /root/.ssh/authorized_keys "$c_zfs_mount_dir/etc/dropbear/initramfs/authorized_keys"
|
||||
|
||||
cp /root/.ssh/authorized_keys "$c_zfs_mount_dir/etc/dropbear-initramfs/authorized_keys"
|
||||
|
||||
cp "$c_zfs_mount_dir/etc/ssh/ssh_host_rsa_key" "$c_zfs_mount_dir/etc/ssh/ssh_host_rsa_key_temp"
|
||||
chroot_execute "ssh-keygen -p -i -m pem -N '' -f /etc/ssh/ssh_host_rsa_key_temp"
|
||||
chroot_execute "/usr/lib/dropbear/dropbearconvert openssh dropbear /etc/ssh/ssh_host_rsa_key_temp /etc/dropbear/initramfs/dropbear_rsa_host_key"
|
||||
chroot_execute "/usr/lib/dropbear/dropbearconvert openssh dropbear /etc/ssh/ssh_host_rsa_key_temp /etc/dropbear-initramfs/dropbear_rsa_host_key"
|
||||
rm -rf "$c_zfs_mount_dir/etc/ssh/ssh_host_rsa_key_temp"
|
||||
|
||||
cp "$c_zfs_mount_dir/etc/ssh/ssh_host_ecdsa_key" "$c_zfs_mount_dir/etc/ssh/ssh_host_ecdsa_key_temp"
|
||||
chroot_execute "ssh-keygen -p -i -m pem -N '' -f /etc/ssh/ssh_host_ecdsa_key_temp"
|
||||
chroot_execute "/usr/lib/dropbear/dropbearconvert openssh dropbear /etc/ssh/ssh_host_ecdsa_key_temp /etc/dropbear/initramfs/dropbear_ecdsa_host_key"
|
||||
chroot_execute "/usr/lib/dropbear/dropbearconvert openssh dropbear /etc/ssh/ssh_host_ecdsa_key_temp /etc/dropbear-initramfs/dropbear_ecdsa_host_key"
|
||||
chroot_execute "rm -rf /etc/ssh/ssh_host_ecdsa_key_temp"
|
||||
rm -rf "$c_zfs_mount_dir/etc/ssh/ssh_host_ecdsa_key_temp"
|
||||
|
||||
rm -rf "$c_zfs_mount_dir/etc/dropbear/initramfs/dropbear_dss_host_key"
|
||||
rm -rf "$c_zfs_mount_dir/etc/dropbear-initramfs/dropbear_dss_host_key"
|
||||
fi
|
||||
|
||||
echo "============setup root prompt============"
|
||||
@@ -802,7 +791,6 @@ CONF
|
||||
|
||||
echo "========running packages upgrade==========="
|
||||
chroot_execute "apt upgrade --yes"
|
||||
chroot_execute "apt purge cryptsetup* --yes"
|
||||
|
||||
echo "===========add static route to initramfs via hook to add default routes for Hetzner due to Debian/Ubuntu initramfs DHCP bug ========="
|
||||
mkdir -p "$c_zfs_mount_dir/usr/share/initramfs-tools/scripts/init-premount"
|
||||
|
||||
@@ -17,8 +17,6 @@ set -o errexit
|
||||
set -o pipefail
|
||||
set -o nounset
|
||||
|
||||
export TMPDIR=/tmp
|
||||
|
||||
# Variables
|
||||
v_bpool_name=
|
||||
v_bpool_tweaks=
|
||||
@@ -495,21 +493,9 @@ for kver in $(find /lib/modules/* -maxdepth 0 -type d | grep -v "$(uname -r)" |
|
||||
done
|
||||
|
||||
echo "======= installing zfs on rescue system =========="
|
||||
|
||||
echo "zfs-dkms zfs-dkms/note-incompatible-licenses note true" | debconf-set-selections
|
||||
# echo "y" | zfs
|
||||
# linux-headers-generic linux-image-generic
|
||||
apt install --yes software-properties-common dpkg-dev dkms
|
||||
rm -f "$(which zfs)"
|
||||
rm -f "$(which zpool)"
|
||||
echo -e "deb http://deb.debian.org/debian/ testing main contrib non-free\ndeb http://deb.debian.org/debian/ testing main contrib non-free\n" >/etc/apt/sources.list.d/bookworm-testing.list
|
||||
echo -e "Package: src:zfs-linux\nPin: release n=testing\nPin-Priority: 990\n" > /etc/apt/preferences.d/90_zfs
|
||||
apt update
|
||||
apt install -t testing --yes zfs-dkms zfsutils-linux
|
||||
rm /etc/apt/sources.list.d/bookworm-testing.list
|
||||
rm /etc/apt/preferences.d/90_zfs
|
||||
apt update
|
||||
export PATH=$PATH:/usr/sbin
|
||||
echo "zfs-dkms zfs-dkms/note-incompatible-licenses note true" | debconf-set-selections
|
||||
apt-get install --yes software-properties-common
|
||||
echo "y" | zfs
|
||||
zfs --version
|
||||
|
||||
echo "======= partitioning the disk =========="
|
||||
@@ -546,7 +532,7 @@ echo "======= create zfs pools and datasets =========="
|
||||
|
||||
pools_mirror_option=
|
||||
if [[ ${#v_selected_disks[@]} -gt 1 ]]; then
|
||||
if dialog --defaultno --yesno "Do you want to use mirror mode for ${v_selected_disks[*]}?" 30 100; then
|
||||
if dialog --defaultno --yesno "Do you want to use mirror mode for ${v_selected_disks[@]}?" 30 100; then
|
||||
pools_mirror_option=mirror
|
||||
fi
|
||||
fi
|
||||
@@ -576,8 +562,9 @@ zfs create -o canmount=noauto -o mountpoint=/boot "$v_bpool_name/BOOT/debian"
|
||||
zfs mount "$v_bpool_name/BOOT/debian"
|
||||
|
||||
zfs create "$v_rpool_name/home"
|
||||
#zfs create -o mountpoint=/root "$v_rpool_name/home/root"
|
||||
zfs create -o mountpoint=/root "$v_rpool_name/home/root"
|
||||
zfs create -o canmount=off "$v_rpool_name/var"
|
||||
zfs create -o canmount=off "$v_rpool_name/var/lib"
|
||||
zfs create "$v_rpool_name/var/log"
|
||||
zfs create "$v_rpool_name/var/spool"
|
||||
|
||||
@@ -628,7 +615,7 @@ ff02::2 ip6-allrouters
|
||||
ff02::3 ip6-allhosts
|
||||
CONF
|
||||
|
||||
ip6addr_prefix=$(ip -6 a s | grep -E "inet6.+global" | sed -nE 's/.+inet6\s(([0-9a-z]{1,4}:){4,4}).+/\1/p' | head -n 1)
|
||||
ip6addr_prefix=$(ip -6 a s | grep -E "inet6.+global" | sed -nE 's/.+inet6\s(([0-9a-z]{1,4}:){4,4}).+/\1/p')
|
||||
|
||||
cat <<CONF > /mnt/etc/systemd/network/10-eth0.network
|
||||
[Match]
|
||||
@@ -640,6 +627,10 @@ Address=${ip6addr_prefix}:1/64
|
||||
Gateway=fe80::1
|
||||
CONF
|
||||
chroot_execute "systemctl enable systemd-networkd.service"
|
||||
chroot_execute "systemctl enable systemd-resolved.service"
|
||||
|
||||
|
||||
cp /etc/resolv.conf $c_zfs_mount_dir/etc/resolv.conf
|
||||
|
||||
echo "======= preparing the jail for chroot =========="
|
||||
for virtual_fs_dir in proc sys dev; do
|
||||
@@ -705,11 +696,10 @@ chroot_execute "dpkg-reconfigure console-setup -f noninteractive"
|
||||
chroot_execute "setupcon"
|
||||
|
||||
chroot_execute "rm -f /etc/localtime /etc/timezone"
|
||||
chroot_execute "dpkg-reconfigure tzdata -f noninteractive"
|
||||
chroot_execute "dpkg-reconfigure tzdata -f noninteractive "
|
||||
|
||||
echo "======= installing latest kernel============="
|
||||
# linux-headers-generic linux-image-generic
|
||||
chroot_execute "apt install --yes linux-image${v_kernel_variant}-amd64 linux-headers${v_kernel_variant}-amd64 dpkg-dev"
|
||||
chroot_execute "apt install --yes linux-image${v_kernel_variant}-amd64 linux-headers${v_kernel_variant}-amd64"
|
||||
|
||||
echo "======= installing aux packages =========="
|
||||
chroot_execute "apt install --yes man wget curl software-properties-common nano htop gnupg"
|
||||
@@ -736,6 +726,8 @@ echo "======= installing OpenSSH and network tooling =========="
|
||||
chroot_execute "apt install --yes openssh-server net-tools"
|
||||
|
||||
echo "======= setup OpenSSH =========="
|
||||
mkdir -p "$c_zfs_mount_dir/root/.ssh/"
|
||||
cp /root/.ssh/authorized_keys "$c_zfs_mount_dir/root/.ssh/authorized_keys"
|
||||
sed -i 's/#PasswordAuthentication yes/PasswordAuthentication no/g' "$c_zfs_mount_dir/etc/ssh/sshd_config"
|
||||
sed -i 's/#PubkeyAuthentication yes/PubkeyAuthentication yes/g' "$c_zfs_mount_dir/etc/ssh/sshd_config"
|
||||
chroot_execute "rm /etc/ssh/ssh_host_*"
|
||||
@@ -773,22 +765,21 @@ if [[ $v_encrypt_rpool == "1" ]]; then
|
||||
echo "=========set up dropbear=============="
|
||||
|
||||
chroot_execute "apt install --yes dropbear-initramfs"
|
||||
|
||||
mkdir -p "$c_zfs_mount_dir/etc/dropbear/initramfs"
|
||||
cp /root/.ssh/authorized_keys "$c_zfs_mount_dir/etc/dropbear/initramfs/authorized_keys"
|
||||
|
||||
cp /root/.ssh/authorized_keys "$c_zfs_mount_dir/etc/dropbear-initramfs/authorized_keys"
|
||||
|
||||
cp "$c_zfs_mount_dir/etc/ssh/ssh_host_rsa_key" "$c_zfs_mount_dir/etc/ssh/ssh_host_rsa_key_temp"
|
||||
chroot_execute "ssh-keygen -p -i -m pem -N '' -f /etc/ssh/ssh_host_rsa_key_temp"
|
||||
chroot_execute "/usr/lib/dropbear/dropbearconvert openssh dropbear /etc/ssh/ssh_host_rsa_key_temp /etc/dropbear/initramfs/dropbear_rsa_host_key"
|
||||
chroot_execute "/usr/lib/dropbear/dropbearconvert openssh dropbear /etc/ssh/ssh_host_rsa_key_temp /etc/dropbear-initramfs/dropbear_rsa_host_key"
|
||||
rm -rf "$c_zfs_mount_dir/etc/ssh/ssh_host_rsa_key_temp"
|
||||
|
||||
cp "$c_zfs_mount_dir/etc/ssh/ssh_host_ecdsa_key" "$c_zfs_mount_dir/etc/ssh/ssh_host_ecdsa_key_temp"
|
||||
chroot_execute "ssh-keygen -p -i -m pem -N '' -f /etc/ssh/ssh_host_ecdsa_key_temp"
|
||||
chroot_execute "/usr/lib/dropbear/dropbearconvert openssh dropbear /etc/ssh/ssh_host_ecdsa_key_temp /etc/dropbear/initramfs/dropbear_ecdsa_host_key"
|
||||
chroot_execute "/usr/lib/dropbear/dropbearconvert openssh dropbear /etc/ssh/ssh_host_ecdsa_key_temp /etc/dropbear-initramfs/dropbear_ecdsa_host_key"
|
||||
chroot_execute "rm -rf /etc/ssh/ssh_host_ecdsa_key_temp"
|
||||
rm -rf "$c_zfs_mount_dir/etc/ssh/ssh_host_ecdsa_key_temp"
|
||||
|
||||
rm -rf "$c_zfs_mount_dir/etc/dropbear/initramfs/dropbear_dss_host_key"
|
||||
rm -rf "$c_zfs_mount_dir/etc/dropbear-initramfs/dropbear_dss_host_key"
|
||||
fi
|
||||
|
||||
echo "============setup root prompt============"
|
||||
@@ -799,13 +790,8 @@ export LS_OPTIONS='--color=auto -h'
|
||||
eval "\$(dircolors)"
|
||||
CONF
|
||||
|
||||
echo "========= add root pubkey for login via SSH"
|
||||
mkdir -p "$c_zfs_mount_dir/root/.ssh/"
|
||||
cp /root/.ssh/authorized_keys "$c_zfs_mount_dir/root/.ssh/authorized_keys"
|
||||
|
||||
echo "========running packages upgrade and autoremove==========="
|
||||
echo "========running packages upgrade==========="
|
||||
chroot_execute "apt upgrade --yes"
|
||||
chroot_execute "apt purge cryptsetup* --yes"
|
||||
|
||||
echo "===========add static route to initramfs via hook to add default routes for Hetzner due to Debian/Ubuntu initramfs DHCP bug ========="
|
||||
mkdir -p "$c_zfs_mount_dir/usr/share/initramfs-tools/scripts/init-premount"
|
||||
@@ -840,8 +826,6 @@ chmod 755 "$c_zfs_mount_dir/etc/network/interfaces"
|
||||
echo "======= update initramfs =========="
|
||||
chroot_execute "update-initramfs -u -k all"
|
||||
|
||||
chroot_execute "apt remove cryptsetup* --yes"
|
||||
|
||||
echo "======= update grub =========="
|
||||
chroot_execute "update-grub"
|
||||
|
||||
@@ -17,8 +17,6 @@ set -o errexit
|
||||
set -o pipefail
|
||||
set -o nounset
|
||||
|
||||
export TMPDIR=/tmp
|
||||
|
||||
# Variables
|
||||
v_bpool_name=
|
||||
v_bpool_tweaks=
|
||||
@@ -462,20 +460,9 @@ for kver in $(find /lib/modules/* -maxdepth 0 -type d | grep -v "$(uname -r)" |
|
||||
done
|
||||
|
||||
echo "======= installing zfs on rescue system =========="
|
||||
echo "zfs-dkms zfs-dkms/note-incompatible-licenses note true" | debconf-set-selections
|
||||
# echo "y" | zfs
|
||||
# linux-headers-generic linux-image-generic
|
||||
apt install --yes software-properties-common dpkg-dev dkms
|
||||
rm -f "$(which zfs)"
|
||||
rm -f "$(which zpool)"
|
||||
echo -e "deb http://deb.debian.org/debian/ testing main contrib non-free\ndeb http://deb.debian.org/debian/ testing main contrib non-free\n" >/etc/apt/sources.list.d/bookworm-testing.list
|
||||
echo -e "Package: src:zfs-linux\nPin: release n=testing\nPin-Priority: 990\n" > /etc/apt/preferences.d/90_zfs
|
||||
apt update
|
||||
apt install -t testing --yes zfs-dkms zfsutils-linux
|
||||
rm /etc/apt/sources.list.d/bookworm-testing.list
|
||||
rm /etc/apt/preferences.d/90_zfs
|
||||
apt update
|
||||
export PATH=$PATH:/usr/sbin
|
||||
echo "zfs-dkms zfs-dkms/note-incompatible-licenses note true" | debconf-set-selections
|
||||
apt-get install --yes software-properties-common
|
||||
echo "y" | zfs
|
||||
zfs --version
|
||||
|
||||
echo "======= partitioning the disk =========="
|
||||
@@ -541,7 +528,9 @@ zfs create -o canmount=noauto -o mountpoint=/boot "$v_bpool_name/BOOT/ubuntu"
|
||||
zfs mount "$v_bpool_name/BOOT/ubuntu"
|
||||
|
||||
zfs create "$v_rpool_name/home"
|
||||
zfs create -o mountpoint=/root "$v_rpool_name/home/root"
|
||||
zfs create -o canmount=off "$v_rpool_name/var"
|
||||
zfs create -o canmount=off "$v_rpool_name/var/lib"
|
||||
zfs create "$v_rpool_name/var/log"
|
||||
zfs create "$v_rpool_name/var/spool"
|
||||
|
||||
@@ -592,7 +581,7 @@ ff02::2 ip6-allrouters
|
||||
ff02::3 ip6-allhosts
|
||||
CONF
|
||||
|
||||
ip6addr_prefix=$(ip -6 a s | grep -E "inet6.+global" | sed -nE 's/.+inet6\s(([0-9a-z]{1,4}:){4,4}).+/\1/p' | head -n 1)
|
||||
ip6addr_prefix=$(ip -6 a s | grep -E "inet6.+global" | sed -nE 's/.+inet6\s(([0-9a-z]{1,4}:){4,4}).+/\1/p')
|
||||
|
||||
cat <<CONF > /mnt/etc/systemd/network/10-eth0.network
|
||||
[Match]
|
||||
@@ -607,7 +596,6 @@ CONF
|
||||
chroot_execute "systemctl enable systemd-networkd.service"
|
||||
chroot_execute "systemctl enable systemd-resolved.service"
|
||||
|
||||
#cp /etc/resolv.conf $c_zfs_mount_dir/etc/resolv.conf
|
||||
|
||||
mkdir -p "$c_zfs_mount_dir/etc/cloud/cloud.cfg.d/"
|
||||
cat > "$c_zfs_mount_dir/etc/cloud/cloud.cfg.d/99-disable-network-config.cfg" <<CONF
|
||||
@@ -617,6 +605,7 @@ CONF
|
||||
|
||||
rm -rf $c_zfs_mount_dir/etc/network/interfaces.d/50-cloud-init.cfg
|
||||
|
||||
cp /etc/resolv.conf $c_zfs_mount_dir/etc/resolv.conf
|
||||
|
||||
echo "======= preparing the jail for chroot =========="
|
||||
for virtual_fs_dir in proc sys dev; do
|
||||
@@ -769,6 +758,18 @@ if [[ $v_encrypt_rpool == "1" ]]; then
|
||||
rm -rf "$c_zfs_mount_dir/etc/ssh/ssh_host_ecdsa_key_temp"
|
||||
|
||||
rm -rf "$c_zfs_mount_dir/etc/dropbear-initramfs/dropbear_dss_host_key"
|
||||
|
||||
cd "$c_zfs_mount_dir/root"
|
||||
wget http://ftp.de.debian.org/debian/pool/main/libt/libtommath/libtommath1_1.1.0-3_amd64.deb
|
||||
wget http://ftp.de.debian.org/debian/pool/main/d/dropbear/dropbear-bin_2018.76-5_amd64.deb
|
||||
wget http://ftp.de.debian.org/debian/pool/main/d/dropbear/dropbear-initramfs_2018.76-5_all.deb
|
||||
|
||||
chroot_execute "dpkg -i /root/libtommath1_1.1.0-3_amd64.deb"
|
||||
chroot_execute "dpkg -i /root/dropbear-bin_2018.76-5_amd64.deb"
|
||||
chroot_execute "dpkg -i /root/dropbear-initramfs_2018.76-5_all.deb"
|
||||
|
||||
rm $c_zfs_mount_dir/root/*.deb
|
||||
cd /root
|
||||
fi
|
||||
|
||||
echo "============setup root prompt============"
|
||||
@@ -781,7 +782,6 @@ CONF
|
||||
|
||||
echo "========running packages upgrade==========="
|
||||
chroot_execute "apt upgrade --yes"
|
||||
chroot_execute "apt purge cryptsetup* --yes"
|
||||
|
||||
echo "===========add static route to initramfs via hook to add default routes due to Ubuntu initramfs DHCP bug ========="
|
||||
mkdir -p "$c_zfs_mount_dir/usr/share/initramfs-tools/scripts/init-premount"
|
||||
@@ -805,8 +805,8 @@ esac
|
||||
|
||||
configure_networking
|
||||
|
||||
ip route add 172.31.1.1/255.255.255.255 dev eth0
|
||||
ip route add default via 172.31.1.1 dev eth0
|
||||
ip route add 172.31.1.1/255.255.255.255 dev ens3
|
||||
ip route add default via 172.31.1.1 dev ens3
|
||||
CONF
|
||||
|
||||
chmod 755 "$c_zfs_mount_dir/usr/share/initramfs-tools/scripts/init-premount/static-route"
|
||||
|
||||
@@ -17,8 +17,6 @@ set -o errexit
|
||||
set -o pipefail
|
||||
set -o nounset
|
||||
|
||||
export TMPDIR=/tmp
|
||||
|
||||
# Variables
|
||||
v_bpool_name=
|
||||
v_bpool_tweaks=
|
||||
@@ -462,20 +460,9 @@ for kver in $(find /lib/modules/* -maxdepth 0 -type d | grep -v "$(uname -r)" |
|
||||
done
|
||||
|
||||
echo "======= installing zfs on rescue system =========="
|
||||
echo "zfs-dkms zfs-dkms/note-incompatible-licenses note true" | debconf-set-selections
|
||||
# echo "y" | zfs
|
||||
# linux-headers-generic linux-image-generic
|
||||
apt install --yes software-properties-common dpkg-dev dkms
|
||||
rm -f "$(which zfs)"
|
||||
rm -f "$(which zpool)"
|
||||
echo -e "deb http://deb.debian.org/debian/ testing main contrib non-free\ndeb http://deb.debian.org/debian/ testing main contrib non-free\n" >/etc/apt/sources.list.d/bookworm-testing.list
|
||||
echo -e "Package: src:zfs-linux\nPin: release n=testing\nPin-Priority: 990\n" > /etc/apt/preferences.d/90_zfs
|
||||
apt update
|
||||
apt install -t testing --yes zfs-dkms zfsutils-linux
|
||||
rm /etc/apt/sources.list.d/bookworm-testing.list
|
||||
rm /etc/apt/preferences.d/90_zfs
|
||||
apt update
|
||||
export PATH=$PATH:/usr/sbin
|
||||
echo "zfs-dkms zfs-dkms/note-incompatible-licenses note true" | debconf-set-selections
|
||||
apt-get install --yes software-properties-common
|
||||
echo "y" | zfs
|
||||
zfs --version
|
||||
|
||||
echo "======= partitioning the disk =========="
|
||||
@@ -541,7 +528,9 @@ zfs create -o canmount=noauto -o mountpoint=/boot "$v_bpool_name/BOOT/ubuntu"
|
||||
zfs mount "$v_bpool_name/BOOT/ubuntu"
|
||||
|
||||
zfs create "$v_rpool_name/home"
|
||||
zfs create -o mountpoint=/root "$v_rpool_name/home/root"
|
||||
zfs create -o canmount=off "$v_rpool_name/var"
|
||||
zfs create -o canmount=off "$v_rpool_name/var/lib"
|
||||
zfs create "$v_rpool_name/var/log"
|
||||
zfs create "$v_rpool_name/var/spool"
|
||||
|
||||
@@ -592,7 +581,7 @@ ff02::2 ip6-allrouters
|
||||
ff02::3 ip6-allhosts
|
||||
CONF
|
||||
|
||||
ip6addr_prefix=$(ip -6 a s | grep -E "inet6.+global" | sed -nE 's/.+inet6\s(([0-9a-z]{1,4}:){4,4}).+/\1/p' | head -n 1)
|
||||
ip6addr_prefix=$(ip -6 a s | grep -E "inet6.+global" | sed -nE 's/.+inet6\s(([0-9a-z]{1,4}:){4,4}).+/\1/p')
|
||||
|
||||
cat <<CONF > /mnt/etc/systemd/network/10-eth0.network
|
||||
[Match]
|
||||
@@ -616,7 +605,7 @@ CONF
|
||||
|
||||
rm -rf $c_zfs_mount_dir/etc/network/interfaces.d/50-cloud-init.cfg
|
||||
|
||||
#cp /etc/resolv.conf $c_zfs_mount_dir/etc/resolv.conf
|
||||
cp /etc/resolv.conf $c_zfs_mount_dir/etc/resolv.conf
|
||||
|
||||
echo "======= preparing the jail for chroot =========="
|
||||
for virtual_fs_dir in proc sys dev; do
|
||||
@@ -755,7 +744,7 @@ done
|
||||
if [[ $v_encrypt_rpool == "1" ]]; then
|
||||
echo "=========set up dropbear=============="
|
||||
chroot_execute "apt install --yes dropbear-initramfs"
|
||||
|
||||
|
||||
cp /root/.ssh/authorized_keys "$c_zfs_mount_dir/etc/dropbear-initramfs/authorized_keys"
|
||||
|
||||
cp "$c_zfs_mount_dir/etc/ssh/ssh_host_rsa_key" "$c_zfs_mount_dir/etc/ssh/ssh_host_rsa_key_temp"
|
||||
@@ -794,7 +783,6 @@ CONF
|
||||
|
||||
echo "========running packages upgrade==========="
|
||||
chroot_execute "apt upgrade --yes"
|
||||
chroot_execute "apt purge cryptsetup* --yes"
|
||||
|
||||
echo "===========add static route to initramfs via hook to add default routes due to Ubuntu initramfs DHCP bug ========="
|
||||
mkdir -p "$c_zfs_mount_dir/usr/share/initramfs-tools/scripts/init-premount"
|
||||
|
||||
@@ -17,8 +17,6 @@ set -o errexit
|
||||
set -o pipefail
|
||||
set -o nounset
|
||||
|
||||
export TMPDIR=/tmp
|
||||
|
||||
# Variables
|
||||
v_bpool_name=
|
||||
v_bpool_tweaks=
|
||||
@@ -462,20 +460,9 @@ for kver in $(find /lib/modules/* -maxdepth 0 -type d | grep -v "$(uname -r)" |
|
||||
done
|
||||
|
||||
echo "======= installing zfs on rescue system =========="
|
||||
echo "zfs-dkms zfs-dkms/note-incompatible-licenses note true" | debconf-set-selections
|
||||
# echo "y" | zfs
|
||||
# linux-headers-generic linux-image-generic
|
||||
apt install --yes software-properties-common dpkg-dev dkms
|
||||
rm -f "$(which zfs)"
|
||||
rm -f "$(which zpool)"
|
||||
echo -e "deb http://deb.debian.org/debian/ testing main contrib non-free\ndeb http://deb.debian.org/debian/ testing main contrib non-free\n" >/etc/apt/sources.list.d/bookworm-testing.list
|
||||
echo -e "Package: src:zfs-linux\nPin: release n=testing\nPin-Priority: 990\n" > /etc/apt/preferences.d/90_zfs
|
||||
apt update
|
||||
apt install -t testing --yes zfs-dkms zfsutils-linux
|
||||
rm /etc/apt/sources.list.d/bookworm-testing.list
|
||||
rm /etc/apt/preferences.d/90_zfs
|
||||
apt update
|
||||
export PATH=$PATH:/usr/sbin
|
||||
echo "zfs-dkms zfs-dkms/note-incompatible-licenses note true" | debconf-set-selections
|
||||
apt-get install --yes software-properties-common
|
||||
echo "y" | zfs
|
||||
zfs --version
|
||||
|
||||
echo "======= partitioning the disk =========="
|
||||
@@ -541,8 +528,9 @@ zfs create -o canmount=noauto -o mountpoint=/boot "$v_bpool_name/BOOT/ubuntu"
|
||||
zfs mount "$v_bpool_name/BOOT/ubuntu"
|
||||
|
||||
zfs create "$v_rpool_name/home"
|
||||
#zfs create -o mountpoint=/root "$v_rpool_name/home/root"
|
||||
zfs create -o mountpoint=/root "$v_rpool_name/home/root"
|
||||
zfs create -o canmount=off "$v_rpool_name/var"
|
||||
zfs create -o canmount=off "$v_rpool_name/var/lib"
|
||||
zfs create "$v_rpool_name/var/log"
|
||||
zfs create "$v_rpool_name/var/spool"
|
||||
|
||||
@@ -593,7 +581,7 @@ ff02::2 ip6-allrouters
|
||||
ff02::3 ip6-allhosts
|
||||
CONF
|
||||
|
||||
ip6addr_prefix=$(ip -6 a s | grep -E "inet6.+global" | sed -nE 's/.+inet6\s(([0-9a-z]{1,4}:){4,4}).+/\1/p' | head -n 1)
|
||||
ip6addr_prefix=$(ip -6 a s | grep -E "inet6.+global" | sed -nE 's/.+inet6\s(([0-9a-z]{1,4}:){4,4}).+/\1/p')
|
||||
|
||||
cat <<CONF > /mnt/etc/systemd/network/10-eth0.network
|
||||
[Match]
|
||||
@@ -617,6 +605,8 @@ CONF
|
||||
|
||||
rm -rf $c_zfs_mount_dir/etc/network/interfaces.d/50-cloud-init.cfg
|
||||
|
||||
cp /etc/resolv.conf $c_zfs_mount_dir/etc/resolv.conf
|
||||
|
||||
echo "======= preparing the jail for chroot =========="
|
||||
for virtual_fs_dir in proc sys dev; do
|
||||
mount --rbind "/$virtual_fs_dir" "$c_zfs_mount_dir/$virtual_fs_dir"
|
||||
@@ -755,22 +745,33 @@ done
|
||||
if [[ $v_encrypt_rpool == "1" ]]; then
|
||||
echo "=========set up dropbear=============="
|
||||
chroot_execute "apt install --yes dropbear-initramfs"
|
||||
|
||||
mkdir -p "$c_zfs_mount_dir/etc/dropbear/initramfs"
|
||||
cp /root/.ssh/authorized_keys "$c_zfs_mount_dir/etc/dropbear/initramfs/authorized_keys"
|
||||
|
||||
cp /root/.ssh/authorized_keys "$c_zfs_mount_dir/etc/dropbear-initramfs/authorized_keys"
|
||||
|
||||
cp "$c_zfs_mount_dir/etc/ssh/ssh_host_rsa_key" "$c_zfs_mount_dir/etc/ssh/ssh_host_rsa_key_temp"
|
||||
chroot_execute "ssh-keygen -p -i -m pem -N '' -f /etc/ssh/ssh_host_rsa_key_temp"
|
||||
chroot_execute "/usr/lib/dropbear/dropbearconvert openssh dropbear /etc/ssh/ssh_host_rsa_key_temp /etc/dropbear/initramfs/dropbear_rsa_host_key"
|
||||
chroot_execute "/usr/lib/dropbear/dropbearconvert openssh dropbear /etc/ssh/ssh_host_rsa_key_temp /etc/dropbear-initramfs/dropbear_rsa_host_key"
|
||||
rm -rf "$c_zfs_mount_dir/etc/ssh/ssh_host_rsa_key_temp"
|
||||
|
||||
cp "$c_zfs_mount_dir/etc/ssh/ssh_host_ecdsa_key" "$c_zfs_mount_dir/etc/ssh/ssh_host_ecdsa_key_temp"
|
||||
chroot_execute "ssh-keygen -p -i -m pem -N '' -f /etc/ssh/ssh_host_ecdsa_key_temp"
|
||||
chroot_execute "/usr/lib/dropbear/dropbearconvert openssh dropbear /etc/ssh/ssh_host_ecdsa_key_temp /etc/dropbear/initramfs/dropbear_ecdsa_host_key"
|
||||
chroot_execute "/usr/lib/dropbear/dropbearconvert openssh dropbear /etc/ssh/ssh_host_ecdsa_key_temp /etc/dropbear-initramfs/dropbear_ecdsa_host_key"
|
||||
chroot_execute "rm -rf /etc/ssh/ssh_host_ecdsa_key_temp"
|
||||
rm -rf "$c_zfs_mount_dir/etc/ssh/ssh_host_ecdsa_key_temp"
|
||||
|
||||
rm -rf "$c_zfs_mount_dir/etc/dropbear/initramfs/dropbear_dss_host_key"
|
||||
rm -rf "$c_zfs_mount_dir/etc/dropbear-initramfs/dropbear_dss_host_key"
|
||||
|
||||
cd "$c_zfs_mount_dir/root"
|
||||
wget http://ftp.de.debian.org/debian/pool/main/libt/libtommath/libtommath1_1.2.0-6_amd64.deb
|
||||
wget http://ftp.de.debian.org/debian/pool/main/d/dropbear/dropbear-bin_2020.81-3_amd64.deb
|
||||
wget http://ftp.de.debian.org/debian/pool/main/d/dropbear/dropbear-initramfs_2020.81-3_all.deb
|
||||
|
||||
chroot_execute "dpkg -i /root/libtommath1_1.2.0-6_amd64.deb"
|
||||
chroot_execute "dpkg -i /root/dropbear-bin_2020.81-3_amd64.deb"
|
||||
chroot_execute "dpkg -i /root/dropbear-initramfs_2020.81-3_all.deb"
|
||||
|
||||
rm $c_zfs_mount_dir/root/*.deb
|
||||
cd /root
|
||||
fi
|
||||
|
||||
echo "============setup root prompt============"
|
||||
@@ -783,7 +784,6 @@ CONF
|
||||
|
||||
echo "========running packages upgrade==========="
|
||||
chroot_execute "apt upgrade --yes"
|
||||
chroot_execute "apt purge cryptsetup* --yes"
|
||||
|
||||
echo "===========add static route to initramfs via hook to add default routes due to Ubuntu initramfs DHCP bug ========="
|
||||
mkdir -p "$c_zfs_mount_dir/usr/share/initramfs-tools/scripts/init-premount"
|
||||
|
||||
Reference in New Issue
Block a user