Kazi Server Installation

  1. Booted up from Arch installation
  2. Ran the following
# parted /dev/sda --script mklabel gpt
# parted /dev/sda --script mkpart EFI fat32 1MiB 513MiB
# parted /dev/sda --script set 1 esp on                
# parted /dev/sda --script mkpart ROOT ext4 513MiB 100%
# mkfs.fat -F32 /dev/sda1 
# mkfs.ext4 -F /dev/sda2
# mount /dev/sda2 /mnt 
# mkdir -p /mnt/efiroot
# mount /dev/sda1 /mnt/efiroot 
# pacstrap /mnt base linux-lts linux-firmware intel-ucode dhcpcd sudo openssh gptfdisk efibootmgr
# ROOT_DIR=/mnt
# SYS_NAME=kazi
# ADMIN_USER=ormester
  1. Then pasted this
tee "$ROOT_DIR/install.sh" << EOF
set -eux
echo "INSTALLATION START"
ln -sf /usr/share/zoneinfo/Europe/Budapest /etc/localtime
echo "en_US.UTF-8 UTF-8" > /etc/locale.gen
echo "LANG=en_US.UTF-8" > /etc/locale.conf
echo "KEYMAP=uk" > /etc/vconsole.conf
locale-gen
echo "$SYS_NAME" > /etc/hostname
cat > /etc/hosts << ENDHOSTS
127.0.0.1 localhost
::1 localhost
127.0.1.1 ${SYS_NAME}.localdomain $SYS_NAME
ENDHOSTS

systemctl enable dhcpcd.service
systemctl enable sshd.service

useradd --create-home --user-group ${ADMIN_USER}
mkdir /home/${ADMIN_USER}/.ssh
tee /home/${ADMIN_USER}/.ssh/authorized_keys << ENDKEY
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDb4L67dBYOITq1fWzP0fcNby4iqiqe4WJD3L+gZ3mjwmz9kKkQtKNsBT1e9iHeYgjtczoftmVzdz8pFW0mhzrTmbTroC6Bkvd137JlXieLfiNQgYKMk+Qkx9qCgOuXe7KvuEqvS5iTB5S8iIkkvueIqfEwwjHNl2k8MQe/udIy7GhDEAo0657x0OpfoeztJFZwQQYN0k2s+iU/7USsuVaitTyczBV3fviLj03/SvJguSrE/71PfEDO7GGjVu6Xt7WDndZJmfS5KZ2qDc0kFsa5MheG7rqVsWOyzvcmavLH6tbBqvVHMH5nwT4Nef6MngL3eaNDxF0z8QMLZ0tWdzQJlOPI4a7Iwi1pb1W2KMiEztLpVk0gFDAJNe0V/zCVgLeO0wegg6ztJwVsZVJ444Bh3yd4LFfFMMHzTtgsC1dHK1We2ySw9nT+3Lc8ffvEOAX1xz4TZaVXf+01tiGAJSvTMuuXGYnrzXTVGIej+MLsqN1T1VVM3NZ2oaPi/iXKFvVbk31+hfH98ezSHlEQ59C1ED3hoXhavz33BbPvFvtJMKIUmwXyZkFDJqHMA8zMLFiYzKb+vWQI9VgMgD6uy6cNDo28q7MYeGSVRlQrCcTuBoo/v8OKB6UDiem5PFRVyI2ZYWRDsC04IwDOkmZAd457L9daPwEyq6/MZyZbY2R3sQ== mlakat
ENDKEY
chown -R ${ADMIN_USER}:${ADMIN_USER} /home/${ADMIN_USER}/.ssh
chmod 0644 /home/${ADMIN_USER}/.ssh/authorized_keys
chmod 0755 /home/${ADMIN_USER}/.ssh
gpasswd --add ${ADMIN_USER} wheel

echo "INSTALLATION END"
EOF
arch-chroot "$ROOT_DIR" /bin/bash /install.sh
rm -f "$ROOT_DIR/install.sh"

tee "$ROOT_DIR/etc/sudoers.d/wheel" << EOF
%wheel ALL=(ALL) NOPASSWD: ALL
EOF
# genfstab -U /mnt >> /mnt/etc/fstab
# arch-chroot /mnt bootctl --path=/efiroot install

Then

TARGET_ROOT=/mnt
SYS_NAME=kazi
ROOT_DEVICE=/dev/sda2

mkdir -p /mnt/efiroot/EFI/kazi
tee "$TARGET_ROOT/etc/mkinitcpio-${SYS_NAME}.conf" << ENDMKINIT
MODULES=()
BINARIES=()
FILES=()
HOOKS=(base udev autodetect keyboard keymap consolefont modconf block filesystems fsck)
ENDMKINIT

ESP_DIR="/efiroot/EFI/${SYS_NAME}"
tee "$TARGET_ROOT/etc/mkinitcpio.d/linux-lts.preset" << ENDPRESET
ALL_config="/etc/mkinitcpio.conf"
ALL_kver="${ESP_DIR}/vmlinuz-linux-lts"

cp -af /boot/vmlinuz-linux-lts "${ESP_DIR}/"
[[ -e /boot/intel-ucode.img ]] && cp -af /boot/intel-ucode.img "${ESP_DIR}/"

PRESETS=('${SYS_NAME}')

${SYS_NAME}_config="/etc/mkinitcpio-${SYS_NAME}.conf"
${SYS_NAME}_image="${ESP_DIR}/initramfs-linux-lts-${SYS_NAME}.img"
ENDPRESET

arch-chroot "$TARGET_ROOT" pacman -S --noconfirm linux-lts

ROOT_UUID=$(blkid -o value -s UUID $ROOT_DEVICE)

tee "$TARGET_ROOT/efiroot/loader/entries/${SYS_NAME}.conf" << EOF
title   Arch ${SYS_NAME}
linux   /EFI/${SYS_NAME}/vmlinuz-linux-lts
initrd  /EFI/${SYS_NAME}/intel-ucode.img
initrd  /EFI/${SYS_NAME}/initramfs-linux-lts-${SYS_NAME}.img
options root="UUID=$ROOT_UUID" rw
EOF

echo "${SYS_NAME}" > $TARGET_ROOT/etc/hostname

cat > $TARGET_ROOT/etc/hosts << ENDHOSTS
127.0.0.1 localhost
::1 localhost
127.0.1.1 ${SYS_NAME}.localdomain ${SYS_NAME}
ENDHOSTS

sync