diff options
Diffstat (limited to 'zfssetup/stage2.sh')
| -rwxr-xr-x | zfssetup/stage2.sh | 192 |
1 files changed, 0 insertions, 192 deletions
diff --git a/zfssetup/stage2.sh b/zfssetup/stage2.sh deleted file mode 100755 index 90e4e56..0000000 --- a/zfssetup/stage2.sh +++ /dev/null @@ -1,192 +0,0 @@ -#!/usr/bin/env bash -# install arch linux on zfs root, stage two -# - -set -e # halt on any error - -password="welcome" # root password; will force change after login -hostname="velox" -disk=/dev/nvme0n1 - -yay_repo="https://aur.archlinux.org/yay.git" -source_dir="/usr/src" -logfile=/root/zfsarch_stage2.log - -cd # go home - -# --------------------- Add ArchZFS Repository -------------------- - -pacman-key --init -pacman-key --refresh-keys -pacman-key --populate - -curl --fail-early --fail -L https://archzfs.com/archzfs.gpg \ -| pacman-key -a - --gpgdir /etc/pacman.d/gnupg - -pacman-key \ ---lsign-key \ ---gpgdir /etc/pacman.d/gnupg \ -DDF7DB817396A49B2A2723F7403BD972F75D9D76 - -tee -a /etc/pacman.d/mirrorlist-archzfs <<- 'EOF' -## See https://github.com/archzfs/archzfs/wiki -## France -#,Server = https://archzfs.com/$repo/$arch - -## Germany -#,Server = https://mirror.sum7.eu/archlinux/archzfs/$repo/$arch -#,Server = https://mirror.biocrafting.net/archlinux/archzfs/$repo/$arch - -## India -#,Server = https://mirror.in.themindsmaze.com/archzfs/$repo/$arch - -## United States -#,Server = https://zxcvfdsa.com/archzfs/$repo/$arch -EOF - -tee -a /etc/pacman.conf <<- 'EOF' - -#[archzfs-testing] -#Include = /etc/pacman.d/mirrorlist-archzfs - -#,[archzfs] -#,Include = /etc/pacman.d/mirrorlist-archzfs -EOF - -# this #, prefix is a workaround for ci/cd tests -# remove them -sed -i 's|#,||' /etc/pacman.d/mirrorlist-archzfs -sed -i 's|#,||' /etc/pacman.conf -sed -i 's|^#||' /etc/pacman.d/mirrorlist - -# ---------- Install Packages And Linux Compatible Kernel --------- -pacman -Sy - -kernel_compatible_with_zfs="$(pacman -Si zfs-linux \ -| grep 'Depends On' \ -| sed "s|.*linux=||" \ -| awk '{ print $1 }')" -pacman -U --noconfirm https://america.archive.pkgbuild.com/packages/l/linux/linux-"${kernel_compatible_with_zfs}"-x86_64.pkg.tar.zst - -pacman -S --noconfirm zfs-linux zfs-utils - -# ---------------------- Configure Mkinitcpio --------------------- - -sed -i 's|filesystems|zfs filesystems|' /etc/mkinitcpio.conf -mkinitcpio -P - -# ------------------------- General Hostid ------------------------ - -zgenhostid -f -o /etc/hostid - -# ---------------------- Apply Grub Workaround ---------------------- -# Note: This workaround needs to be applied for every GRUB update, as the update will overwrite the changes. - -echo 'export ZPOOL_VDEV_NAME_PATH=YES' >> /etc/profile.d/zpool_vdev_name_path.sh -# shellcheck disable=SC1091 -. /etc/profile.d/zpool_vdev_name_path.sh - -# GRUB fails to detect rpool name, hard code as "rpool" -sed -i "s|rpool=.*|rpool=rpool|" /etc/grub.d/10_linux - -# -------------------------- Install Grub ------------------------- - -mkdir -p /boot/efi/archlinux/grub-bootdir/i386-pc/ -mkdir -p /boot/efi/archlinux/grub-bootdir/x86_64-efi/ -for i in ${DISK}; do - grub-install --target=i386-pc --boot-directory \ - /boot/efi/archlinux/grub-bootdir/i386-pc/ "${i}" -done -grub-install --target x86_64-efi --boot-directory \ - /boot/efi/archlinux/grub-bootdir/x86_64-efi/ --efi-directory \ - /boot/efi --bootloader-id archlinux --removable -if test -d /sys/firmware/efi/efivars/; then - grub-install --target x86_64-efi --boot-directory \ - /boot/efi/archlinux/grub-bootdir/x86_64-efi/ --efi-directory \ - /boot/efi --bootloader-id archlinux -fi - -# Import both bpool and rpool at boot: -echo 'GRUB_CMDLINE_LINUX="zfs_import_dir=/dev/"' >> /etc/default/grub - -# Generate GRUB menu: -mkdir -p /boot/grub -grub-mkconfig -o /boot/grub/grub.cfg -cp /boot/grub/grub.cfg \ - /boot/efi/archlinux/grub-bootdir/x86_64-efi/grub/grub.cfg -cp /boot/grub/grub.cfg \ - /boot/efi/archlinux/grub-bootdir/i386-pc/grub/grub.cfg - -# For both legacy and EFI booting: mirror ESP content: -espdir=$(mktemp -d) -find /boot/efi/ -maxdepth 1 -mindepth 1 -type d -print0 \ -| xargs -t -0I '{}' cp -r '{}' "${espdir}" -find "${espdir}" -maxdepth 1 -mindepth 1 -type d -print0 \ - | xargs -t -0I '{}' sh -vxc "find /boot/efis/ -maxdepth 1 -mindepth 1 -type d -print0 | xargs -t -0I '[]' cp -r '{}' '[]'" - - -### ----------------------- Config Environment --------------------- - -# required software -pacman -S --noconfirm sed networkmanager reflector -systemctl enable NetworkManager -systemctl enable reflector.timer - -# parallel downloads -sed -i "s/^#ParallelDownloads = 5$/ParallelDownloads = 15/" /etc/pacman.conf - -# aur config -sed -i '/^CFLAGS=/s/-march=x86-64 -mtune=generic/-march=native/' /etc/makepkg.conf -sed -i 's/^#RUSTFLAGS="-C opt-level=2"/RUSTFLAGS="-C opt-level=2 -C target-cpu=native"/g' /etc/makepkg.conf -sed -i 's/^#MAKEFLAGS="-j2"/MAKEFLAGS="-j$(nproc)"/g' /etc/makepkg.conf -sed -i 's/^COMPRESSXZ=(xz -c -z -)/COMPRESSXZ=(xz -c -z --threads=0 -)/g' /etc/makepkg.conf -sed -i 's/^COMPRESSZST=(zstd -c -z -q -)/COMPRESSZST=(zstd -c -z -q --threads=0 -)/g' /etc/makepkg.conf - -# set up local time -sudo ln -sf /usr/share/zoneinfo/US/Central /etc/localtime -hwclock --systohc - -# set up locale -echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen -locale-gen -echo "LANG=en_US.UTF-8" > /etc/locale.conf - -# set up hostname -echo "$hostname" > /etc/hostname -echo "127.0.0.1 localhost" >> /etc/hosts -echo "::1 localhost" >> /etc/hosts -echo "127.0.1.1 $hostname.localdomain $hostname" >> /etc/hosts - -# console settings -echo "KEYMAP=us" > /etc/vconsole.conf - -# ------------------------ Enable AUR Helper ------------------------ - -pacman -Syy -pacman -S --needed --noconfirm base-devel git openssh wget -build_dir="$source_dir/yay" -mkdir -p "$build_dir" -chown "$username:$username" -R "/home/$username" -sudo -u "$username" git clone --depth 1 "$yay_repo" "$build_dir" -cd "$build_dir" && sudo -u "$username" makepkg --noconfirm -si - -### ------------------------- Enable ZFS Services ---------------------- -# add kernel modules -pacman -S --noconfirm zfs-dkms - -# enable zfs services -systemctl enable zfs-import-cache -systemctl enable zfs-import.target -systemctl enable zfs-mount.service -systemctl enable zfs-share -systemctl enable zfs-zed -systemctl enable zfs.target - -### ----------------------------- Wrap Up -------------------------- - -# set root password; must change first login -echo "root:$password" | chpasswd -chage -d 0 root - -# --------------------------- Exit Chroot --------------------------- -exit |
