#!/bin/bash source .env mount -o remount,size=4G /run/archiso/cowspace complele_install_script_generator() { cat << 'SCRIPT_EOF' #!/bin/bash pacman -Syu nvidia-utils SCRIPT_EOF } # === DISKS PREPARE === disks_prepare() { sgdisk --zap-all /dev/$_SYS_DEV sgdisk -n 1:0:+$_EFI_SIZE -t 1:ef00 -c 1:"EFI" /dev/$_SYS_DEV sgdisk -n 2:0:+$_SWAP_SIZE -t 2:8200 -c 2:"SWAP" /dev/$_SYS_DEV sgdisk -n 3:0:0 -t 3:8309 -c 3:"LUKS-Data" /dev/$_SYS_DEV sgdisk -p /dev/$_SYS_DEV sgdisk --zap-all /dev/${_HEADER_DEV} sgdisk -n 1:0:+16M -t 1:8309 -c 1:"LUKS-Header" /dev/${_HEADER_DEV} sgdisk -p /dev/${_HEADER_DEV} sync #HEADER_PART=/dev/${_HEADER_DEV}1 wipefs -a /dev/${_HEADER_DEV}1 wipefs -a /dev/${_SYS_DEV}1 wipefs -a /dev/${_SYS_DEV}3 echo -n "$_LUKS_PASS" | cryptsetup luksFormat --type luks2 --batch-mode --key-file - --header /dev/${_HEADER_DEV}1 /dev/${_SYS_DEV}3 echo -n "$_LUKS_PASS" | cryptsetup open /dev/${_SYS_DEV}3 --header /dev/${_HEADER_DEV}1 --key-file - cryptroot _LUKS_UUID=$(cryptsetup luksUUID /dev/${_SYS_DEV}3 --header /dev/${_HEADER_DEV}1) echo "LUKS UUID: $_LUKS_UUID" ls /dev/mapper/cryptroot } # 2 === FS INIT === fs_init() { mkfs.btrfs -f -L arch /dev/mapper/cryptroot mkfs.fat -F 32 /dev/${_SYS_DEV}1 mount /dev/mapper/cryptroot /mnt cd /mnt btrfs subvolume create @ btrfs subvolume create @home btrfs subvolume create @snapshots btrfs subvolume create @var btrfs subvolume create @var_log btrfs subvolume create @var_cache cd / umount /mnt mount -o defaults,noatime,compress=zstd,ssd,space_cache=v2,autodefrag,subvol=@ /dev/mapper/cryptroot /mnt mkdir -p /mnt/{home,var,tmp,boot,snapshots} mount -o defaults,noatime,compress=zstd,ssd,space_cache=v2,autodefrag,subvol=@home /dev/mapper/cryptroot /mnt/home mount -o defaults,noatime,compress=zstd,space_cache=v2,subvol=@snapshots /dev/mapper/cryptroot /mnt/snapshots mount -o defaults,noatime,space_cache=v2,subvol=@var /dev/mapper/cryptroot /mnt/var mkdir -p /mnt/var/{log,cache} mount -o defaults,noatime,space_cache=v2,nodatacow,subvol=@var_log /dev/mapper/cryptroot /mnt/var/log mount -o defaults,noatime,space_cache=v2,nodatacow,subvol=@var_cache /dev/mapper/cryptroot /mnt/var/cache mount -o fmask=0077,dmask=0077 /dev/${_SYS_DEV}1 /mnt/boot mkswap /dev/${_SYS_DEV}2 swapon /dev/${_SYS_DEV}2 } # 3 === SYSTEM INSTALL === install_system() { #echo $_LUKS_UUID #_LUKS_UUID=$(cryptsetup luksUUID --header /dev/${_HEADER_DEV}1 /dev/${_SYS_DEV}) _DATA_PARTUUID=$(blkid -s PARTUUID -o value /dev/${_SYS_DEV}3) _HEADER_PARTUUID=$(blkid -s PARTUUID -o value /dev/${_HEADER_DEV}1) pacstrap -c -K /mnt base base-devel linux linux-firmware btrfs-progs mdadm nano sof-firmware intel-ucode iwd dhcpcd vim cryptsetup networkmanager openssh efibootmgr git ly genfstab -U /mnt >> /mnt/etc/fstab arch-chroot /mnt /bin/bash < /etc/locale.conf printf "KEYMAP=ru\nFONT=cyr-sun16" > /etc/vconsole.conf echo "$_HOSTNAME" > /etc/hostname bootctl --path=/boot install #Создаем пункт загрузки printf "title Arch Linux\nlinux /vmlinuz-linux\ninitrd /intel-ucode.img\ninitrd /initramfs-linux.img\noptions rd.luks.name=${_LUKS_UUID}=cryptroot rd.luks.data=${_LUKS_UUID}=/dev/disk/by-partuuid/${_DATA_PARTUUID} rd.luks.options=${_LUKS_UUID}=header=/dev/disk/by-partuuid/${_HEADER_PARTUUID} root=/dev/mapper/cryptroot rw rootflags=subvol=@" > /boot/loader/entries/arch.conf # Правим хуки sed -i 's/^HOOKS=(.*/HOOKS=(base systemd autodetect microcode modconf kms keyboard sd-vconsole block sd-encrypt filesystems fsck)/' /etc/mkinitcpio.conf mkinitcpio -P # Финальнве шаги useradd -m -G wheel -s /bin/bash ${_USERNAME} sed -i '/%wheel ALL=(ALL:ALL) ALL/s/^# *//' /etc/sudoers echo "root:${_ROOT_PASS}" | chpasswd echo "${_USERNAME}:${_USER_PASS}" | chpasswd systemctl enable NetworkManager systemctl enable sshd $(complele_install_script_generator) > /home/${_USERNAME}/complete_install.sh chmod +x /home/${_USERNAME}/complete_install.sh systemctl enable ly@tty2.service systemctl disable getty@tty2.service systemctl mask getty@tty2.service EOF } disks_prepare fs_init install_system echo "DONE! " #umount -R /mnt #cryptsetup close cryptroot #mdadm --stop /dev/md0 #reboot