Your two scripts (install.sh and chroot.sh) look thoughtfully organized and cover all the important steps to automate Arch Linux installation with Btrfs subvolumes, necessary packages, user setup, configuration, and services.
Below are some suggestions, corrections, and tips to help ensure your installer works smoothly:
1. install.sh script
a. Partition naming for NVMe:
if [[ "$disk" == *nvme* ]]; then
part_prefix="${disk}p"
else
part_prefix="${disk}"
fi
✅ Correctly handles /dev/nvme0n1p1 vs /dev/sda1.
b. Partitioning with parted:
Make sure parted commands don't fail due to existing partitions or errors:
parted -s "$disk" mklabel gpt
parted -s "$disk" mkpart ESP fat32 1MiB 1025MiB
parted -s "$disk" set 1 esp on
parted -s "$disk" mkpart primary btrfs 1025MiB 100%
- Consider checking/dropping existing partitions first (
wipefs or sgdisk --zap-all) to avoid problems.
- Also, after partitioning, waiting a second or running
partprobe may be necessary so the kernel detects partitions before formatting.
c. Formatting:
mkfs.vfat -F 32 -n EFI "$part1"
mkfs.btrfs -f -L ROOT "$part2"
This is fine.
d. Btrfs subvolumes:
You create them under a mounted raw partition, then unmount and remount subvolumes with options:
mount "$part2" /mnt
btrfs subvolume create /mnt/@
btrfs subvolume create /mnt/@home
btrfs subvolume create /mnt/@var
btrfs subvolume create /mnt/@snapshots
umount /mnt
mount -o noatime,compress=lzo,ssd,space_cache=v2,discard=async,subvol=@ "$part2" /mnt
mkdir -p /mnt/{home,var,.snapshots}
mount -o noatime,compress=lzo,ssd,space_cache=v2,discard=async,subvol=@home "$part2" /mnt/home
mount -o noatime,compress=lzo,ssd,space_cache=v2,discard=async,subvol=@var "$part2" /mnt/var
mount -o noatime,compress=zstd,ssd,space_cache=v2,discard=async,subvol=@snapshots "$part2" /mnt/.snapshots
✅ Nice and clean. You might want to consider disabling compress on @var or @snapshots depending on usage, but defaults are fine.
e. Pacstrap - reflector usage:
reflector --country 'India' --latest 10 --age 24 --sort rate --save /etc/pacman.d/mirrorlist
if ! pacstrap /mnt "${install_pkgs[@]}"; then
echo "pacstrap failed. Please check the package list and network connection."
exit 1
fi
-
You set the mirrorlist on your live environment (/etc/pacman.d/mirrorlist) right before pacstrap. That only affects your live environment, not the target install.
-
Usually, you'd prefer to set your mirrorlist inside /mnt/etc/pacman.d/mirrorlist before pacstrap, or let pacstrap download from live mirrorlist as it runs.
-
Your chroot.sh contains reflector call too for the target environment.
Suggestion: You can keep as-is, but reflect on your network conditions.
f. Package list typo:
ttf-iosevkaterm-nerd
Seems a typo/missing space in:
ttc-iosevka ttf-iosevkaterm-nerd
Likely you meant:
ttf-iosevka ttf-iosevka-term-nerd
Correct these package names to avoid pacman errors.
g. genfstab
genfstab -U /mnt > /mnt/etc/fstab
✅ Good.
h. Passing install variables:
You export sensitive passwords in plaintext via install.conf. While this works, be sure that file is immediately deleted in the chroot environment.
You do:
chmod 600 /mnt/root/install.conf
...
✅ Good to limit permissions.
i. arch-chroot:
arch-chroot /mnt /root/chroot.sh
✅ Clean.
2. chroot.sh script
a. Hostname and hosts:
echo "127.0.1.1 $hostname.localdomain $hostname" >> /etc/hosts
Recommend appending to /etc/hosts instead of overwriting after the first line.
In your script, you do:
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
✅ Good, explicitly setting all three.
b. Locale generation localization:
sed -i 's/^#en_US.UTF-8/en_US.UTF-8/g' /etc/locale.gen
✅ Correct to uncomment.
c. Sudoers setup:
echo "%wheel ALL=(ALL) ALL" > /etc/sudoers
echo "Defaults timestamp_timeout=-1" >> /etc/sudoers
Warning: Overwriting /etc/sudoers is risky.
Better to append or use visudo style editing:
echo "%wheel ALL=(ALL) ALL" >> /etc/sudoers
echo "Defaults timestamp_timeout=-1" >> /etc/sudoers
Or safer:
echo "%wheel ALL=(ALL) ALL" | tee -a /etc/sudoers
echo "Defaults timestamp_timeout=-1" | tee -a /etc/sudoers
Or put those in /etc/sudoers.d/ files instead to avoid breaking sudo altogether.
d. Bootloader:
grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB
✅ Standard.
e. Refreshing and enabling reflector, pacman configs:
Looks good.
f. As user cloning dotfiles:
This snippet:
su - "$user" -c '
# commands
'
✅ Correct to run as that user.
g. Polkit, firefox, and cleanup:
ln -sf /home/"$user"/.dotfiles/policies.json /etc/firefox/policies/policies.json
shred -u /root/install.conf
✅ Good to remove password file securely.
h. Systemd services enable:
systemctl enable NetworkManager libvirtd sshd ananicy-cpp.service fstrim.timer ollama.service ly.service acpid power-profiles-daemon.service cronie.service
freshclam
systemctl enable clamav-daemon.service clamav-freshclam.service
✅ Looks fine.
i. Cache cleanup:
pacman -Scc --noconfirm
✅ Good to clean cache.
Overall notes and improvements:
-
A set -x debugging line might help during testing.
-
Ensure the live environment has all needed commands and permissions.
-
You might want to add a sync and small sleep after partitioning and formatting steps to let udev settle.
-
Your password passing via /root/install.conf is okay here but consider more secure options for real deployments.
-
Consider adding echo status messages or logging more verbose to track progress.
If you want, I can help you create a single combined annotated version or help troubleshoot specific errors! But overall your scripts are solid for a customized Arch install with Btrfs and modern packages.