summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xinstall-artix.sh70
-rw-r--r--min.sh173
2 files changed, 59 insertions, 184 deletions
diff --git a/install-artix.sh b/install-artix.sh
index 9f8a0ad..23ff0da 100755
--- a/install-artix.sh
+++ b/install-artix.sh
@@ -13,7 +13,7 @@ boot_size=512M
# DUEL-BOOT (i.e. a shared boot partition is used)
# Note:
-# - ensure BOOT, SWAP, & ROOT are set to the correct partitions
+# - ensure BOOT & ROOT are set to the correct partitions
# - when enabled, the boot partition will NOT be formatted
# - boot partition must be ready to use (i.e. created/formatted)
duel_boot=false
@@ -188,12 +188,28 @@ mount -o "${options},subvol=@snapshots" "${root}" /mnt/.snapshots \
mount -o "nodatacow,subvol=@swap" "${root}" /mnt/.swap
# Create swap file
-btrfs filesystem mkswapfile \
- --size "$swap_size" \
- --uuid clear \
- /mnt/.swap/swapfile
+# btrfs filesystem mkswapfile \
+# --size "$swap_size" \
+# --uuid clear \
+# /mnt/.swap/swapfile
+# btrfs property set /mnt/.swap compression none
+# swapon /mnt/.swap/swapfile
+
+# SWAP FILE
+swapfile=/mnt/.swap/swapfile
+# create an empty file
+truncate -s 0 $swapfile
+# set to copy-on-write
+chattr +Cm $swapfile
+# preallocate file size to swap size
+fallocate -l $swap_size $swapfile
+# restrict access to swap file
+chmod 0600 $swapfile
+# initialise the swap file (note: LABEL is required for bootloader)
+mkswap -L SWAP $swapfile
+# ensure compression is disabled
btrfs property set /mnt/.swap compression none
-swapon /mnt/.swap/swapfile
+swapon $swapfile
# Mount boot partition.
mount "${boot}" /mnt/boot
@@ -211,10 +227,15 @@ fi
basestrap /mnt base base-devel dinit seatd-dinit pam_rundir booster
# Install Linux & utilities
+
basestrap /mnt \
linux linux-firmware \
- refind btrfs-progs artools-base gdisk \
- git nano man-{db,pages} "${ucode}" \
+ grub efibootmgr os-prober \
+ btrfs-progs \
+ git nano man-{db,pages} "${ucode}"
+
+# req. for refind bootloader
+# basestrap /mnt refind artools-base gdisk
# Install crypt service
if [[ "${encrypt}" == true ]]; then
@@ -252,7 +273,7 @@ artix-chroot /mnt bash -c \
artix-chroot /mnt bash -c "hwclock -w"
# Set default text editor
-echo "export EDITOR=vim" >> /mnt/etc/profile
+echo "export EDITOR=nano" >> /mnt/etc/profile
# Set hostname
echo "${hostname}" > /mnt/etc/hostname
@@ -297,8 +318,35 @@ echo "compress: zstd -9 -T0
modules: btrfs" > /mnt/etc/booster.yaml
artix-chroot /mnt bash -c "/usr/lib/booster/regenerate_images"
-# Install rEFInd
-artix-chroot /mnt bash -c "refind-install"
+# SETUP BOOTLOADER
+# --------------------------------------------------------------------
+# Set devices
+## add swap for hibernation
+devices="resume=LABEL=SWAP"
+
+## when using a btrfs swapfile, an offset is required for hibernation to work
+## https://man.archlinux.org/man/btrfs.5#HIBERNATION
+devices+=" resume_offset=\"$(btrfs inspect-internal map-swapfile -r $swapfile)\""
+
+## add cryptdevice partition if enabled
+[[ "${encrypt}" == true ]] && devices+=" cryptdevice=LABEL=LUKS:root"
+
+# Set command options
+grub_cmds="loglevel=3 net.iframes=0 quiet splash"
+
+# Replace default grub commands
+sed "s/^GRUB_CMDLINE_LINUX_DEFAULT=.*$/GRUB_CMDLINE_LINUX_DEFAULT=\"${grub_cmds} ${devices}\"/" \
+ -i /mnt/etc/default/grub
+
+# Enable os-prober to detect other operating systems
+if [[ $duel_boot == true ]]; then
+ echo "GRUB_DISABLE_OS_PROBER=false" >> /mnt/etc/default/grub
+fi
+
+# Install grub bootloader
+grub_options="--target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB"
+artix-chroot /mnt bash -c "grub-install ${grub_options}"
+artix-chroot /mnt bash -c "grub-mkconfig -o /boot/grub/grub.cfg"
# FEATURES
# ====================================================================
diff --git a/min.sh b/min.sh
deleted file mode 100644
index 90cf60b..0000000
--- a/min.sh
+++ /dev/null
@@ -1,173 +0,0 @@
-#!/bin/bash
-
-# CONFIG
-# ======================================================
-# Drive
-drive="/dev/DRIVE"
-root="/dev/DRIVE1"
-boot="/dev/DRIVE2"
-
-# System
-timezone=Europe/London
-locale=en_GB
-user=blake
-user_groups=wheel,video,audio,input,seat
-hostname=ArtixPC
-
-# INSTALLATION
-# ======================================================
-
-# Ensure nothing mounted
-umount -R /mnt &> /dev/null
-
-# Init shell environment
-set -e
-
-# Checks
-[[ "${drive}" == "/dev/DRIVE" ]] \
- && { echo "You forgot to set the DRIVE option!"; exit; }
-
-echo "Checking for internet connection..."
-ping -c 3 artixlinux.org 2>&1 /dev/null \
- || { echo "No internet connection found"; exit; }
-
-# Enable ntpd to update time
-dinitctl start ntpd
-
-# Calculate SWAP size
-pacman --needed --noconfirm -Sy bc
-ram_kB=$(awk 'FNR==1 {print $2}' /proc/meminfo)
-ram_gb=$(bc <<< "${ram_kB} / 1000^2")
-[[ "${ram_gb}" -lt 1 ]] && { echo "Not enough ram for SWAP"; exit; }
-[[ -z "${swap_size}" || "${swap_size}" == auto ]] \
- && swap_size="$(bc <<< "sqrt(${ram_gb}) * 4")G"
-
-# Request confirmation
-drive_bytes=$(blockdev --getsize64 "${drive}")
-drive_size="$(bc <<< "${drive_bytes} / 1000000000")G"
-echo "
-================ CONFIRM INSTALLATION ================
-DRIVE: ${drive} (size: ${drive_size})
-ROOT: ${root}
-BOOT: ${boot}
-------------------------------------------------------
-!!! CAUTION: ALL data from ${drive} will be erased !!!
-------------------------------------------------------
-Are you sure you want install?
-"
-unset input
-read -rp "Type YES (in uppercase letters) to begin installation: " input
-[[ "${input}" != "YES" ]] && exit
-
-# Create partitions
-wipefs -a "${drive}"
-layout=',+,L\n'
-[[ -d /sys/firmware/efi/efivars/ ]] && layout=",1G,U,*\n${layout}"
-printf "%s" "$layout" | sfdisk -qf -X gpt ${drive}
-
-# Make file-systems
-[[ -d /sys/firmware/efi/efivars/ ]] && mkfs.fat -n BOOT -F 32 "${boot}"
-mkfs.ext4 -qfL ROOT "$root"
-
-# Mount
-mount "${root}" /mnt && mkdir /mnt/boot
-[[ -d /sys/firmware/efi/efivars/ ]] && mount "${boot}" /mnt/boot
-
-# Make Swap
-fallocate -l "$swap_size" /mnt/swapfile && chmod 600 /mnt/swapfile
-mkswap /mnt/swapfile
-
-# Get CPU type & install microcode
-ucode=amd-ucode
-[[ $(grep "vendor_id" /proc/cpuinfo) == *Intel* ]] && ucode=intel-ucode
-
-# Sync packages
-pacman -Syy
-
-# Install base packages
-basestrap /mnt base base-devel dinit seatd-dinit pam_rundir
-
-# Install Linux & utilities
-basestrap /mnt \
- linux-{firmware,headers} "${ucode}" \
- grub efibootmgr os-prober \
- git nano man-{db,man-pages} bc btop
-
-# Install services
-basestrap /mnt {iwd,openntpd,cronie,openssh,ufw}-dinit
-
-# Enable DHCP client for iwd
-printf "[General]\nEnableNetworkConfiguration=true" >> /mnt/etc/iwd/main.conf
-
-# Enable services
-services="ufw iwd openntpd cronie"
-for service in $services; do
- artix-chroot /mnt bash -c "dinitctl enable $service"
-done
-
-# Generate file-system table
-fstabgen -U /mnt >> /mnt/etc/fstab
-
-# Set swappiness levels
-mkdir -p /mnt/etc/sysctl.d/
-echo vm.swappiness=10 > /mnt/etc/sysctl.d/99-swappiness.conf
-
-# Set locale
-printf "%s.UTF-8 UTF-8\n%s ISO-8859-1" "$locale" "$locale" >> /mnt/etc/locale.gen
-printf "LANG=%s.UTF-8\nexport LC_COLLATE=C" "$locale" > /mnt/etc/locale.conf
-artix-chroot /mnt bash -c "locale-gen"
-
-# Set timezone
-artix-chroot /mnt bash -c \
- "ln -sf /usr/share/zoneinfo/${timezone} /etc/localtime && hwclock -w"
-
-# Set default text editor
-echo "export EDITOR=nano" >> /mnt/etc/profile
-
-# Set hostname
-echo "$hostname" > /mnt/etc/hostname
-
-# Set root password
-artix-chroot /mnt bash -c "echo root:artix | chpasswd"
-
-# Add new user
-artix-chroot /mnt bash -c "useradd -mG ${user_groups} ${user}"
-artix-chroot /mnt bash -c "echo \"${user}:artix\" | chpasswd"
-
-# Set user privileges
-echo "
-Cmnd_Alias STAT = /usr/bin/ufw status
-Cmnd_Alias PACMAN = /usr/bin/checkupdates
-Cmnd_Alias REBOOT = /bin/halt,/bin/reboot
-Defaults pwfeedback
-%wheel ALL=(ALL) ALL
-${user} ALL=(ALL) NOPASSWD:PACMAN,REBOOT,STAT
-" >> /mnt/etc/sudoers
-
-# Add PACMAN download style
-# Set MAKEFLAGS to match CPU threads for faster compiling
-cp /etc/makepkg.conf /etc/makepkg.conf.bak
-sed "s/#MAKEFLAGS=\".*\"/MAKEFLAGS=\"-j$(nproc)\"/" \
- -i /mnt/etc/makepkg.conf
-
-# Configure GRUB
-# install grub
-grub_options="--target=i386-pc --recheck ${drive}"
-[[ -d /sys/firmware/efi/efivars/ ]] \
- && grub_options="--target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB"
-
-artix-chroot /mnt bash -c \
- "grub-install ${grub_options} && grub-mkconfig -o /boot/grub/grub.cfg"
-
-# FINISH
-umount -R /mnt
-swapoff -a
-set +x
-
-echo "
-======================================================================
- Installation Finished
-======================================================================
-"
-echo "You can now reboot and log into system"
-echo "NOTE: AFTER reboot be sure to enable the firewall with 'ufw enable'"