--- Prompt Section (collect all user input here) ---
Disk Selection
echo "Available disks:"
lsblk -d -o NAME,SIZE,MODEL
while true; do
read -p "Enter Disk (e.g. sda, nvme0n1): " disk_input
disk="/dev/{disk_input%/}"
if [ ! -b "disk" ]; then
echo "Disk $disk does not exist. Try again."
continue
fi
break
done
Hostname
while true; do
read -p "Hostname: " hostname
[[ -z "$hostname" ]] && echo "Hostname cannot be empty." && continue
break
done
Root Password
while true; do
read -s -p "Root password: " root_password
echo
read -s -p "Confirm root password: " root_password2
echo
[[ "rootpassword"!="root_password2" ]] && echo "Passwords do not match." && continue
[[ -z "$root_password" ]] && echo "Password cannot be empty." && continue
break
done
Assistant
User
the printf "[zram0]\nzram-size = ram * 2\ncompression-algorithm = zstd\nswap-priority = 100\nfs-type = swap\n" | sudo tee /etc/systemd/zram-generator.conf
should I keep that is su - part or where?
Assistant
User
Assistant
Username
while true; do
read -p "Username: " user
[[ -z "$user" ]] && echo "Username cannot be empty." && continue
break
done
User Password
while true; do
read -s -p "User password: " user_password
echo
read -s -p "Confirm user password: " user_password2
echo
[[ "userpassword"!="user_password2" ]] && echo "Passwords do not match." && continue
[[ -z "$user_password" ]] && echo "Password cannot be empty." && continue
break
done
Export variables for later use
export disk hostname root_password user user_password
Partition Naming
if [[ "disk"==∗nvme∗]];thenpartprefix="{disk}p"
else
part_prefix="${disk}"
fi
mount -o noatime,compress=lzo,ssd,space_cache=v2,discard=async,subvol=@ "part2"/mntmkdir−p/mnt/home,var,.snapshotsmount−onoatime,compress=lzo,ssd,spacecache=v2,discard=async,subvol=@home"part2" /mnt/home
mount -o noatime,compress=lzo,ssd,space_cache=v2,discard=async,subvol=@var "part2"/mnt/vapart2" /mnt/.snapshots
Your two scripts (install.sh and chroot.sh) form a solid full-system installation automation for Arch Linux with btrfs subvolumes and a pretty comprehensive package setup.
Below are some notes and small improvement suggestions to help ensure the install works smoothly, along with a few points to be cautious about.
Overall notes:
Password Handling:
Exposing passwords as plaintext variables and plaintext files (/root/install.conf) is sometimes necessary during install but be mindful of the security implications. You shred the config file afterward, which is good.
Btrfs Subvolumes:
You are creating subvolumes properly and mounting them with good mount options.
Disk Partitioning:
Your parted commands create:
Partition 1: 1MiB - 1025MiB (ESP)
Partition 2: rest of disk (root btrfs)
Disk Naming and partition suffixes (e.g. /dev/sda1 or /dev/nvme0n1p1) handled well.
Package list is comprehensive – includes base-devel, linux-zen kernel, GUI, Wayland + Sway, tools...
Suggestions / Fixes:
1. Disable set -euo pipefail in interactive prompt section or handle unset variables carefully
set -u dies on unset variables, but your script is only using declared variables so this seems fine.
2. Partition Alignment
You start ESP at 1MiB. Usually, the first available sector is 1MiB, and that’s good for alignment. If you want, verify on a new disk.
You run several commands as user by su - "$user" -c '...'.
Because flatpak remote-add uses sudo tee, normally su -c does not preserve password, so this might fail. Since you just created user, sudo might prompt for password if pw is needed. A better approach might be:
Run the whole block as user without using sudo inside (remove sudo).
Or run with proper env or in a new script.
11. Deleting password config after install
You do:
bash
shred -u /root/install.conf
This is very good practice.
12. Services enabled
Good set of services enabled including clamav and antivirus tools.
13. Package cache cleanup
bash
pacman -Scc --noconfirm
runs full cleaning, freeing disk space.
Final tip: Debugging
If anything breaks during pacstrap or chroot, rerun parts manually for debugging, as automation can hide issues.
If you want, I can help package this into a more modular set of scripts, or help trouble debug specific commands.
Summary
Your scripts are quite good for full Arch automated installs with btrfs + wayland + many packages + user configuration.
If you have any specific question or want to test or fix any part, just ask!
You are switching to the user (su - "$user" -c '...')
Inside that user shell, running sudo tee ...
Possible issues
If the user is not yet configured to use sudo without password inside chroot, this command will fail, because sudo will prompt for a password.
Since this is being run in a non-interactive chroot environment, the prompt will stall or fail.
Also, it is unnecessary to run this as the user with sudo — since your install script (running as root inside chroot already) can write the file directly.
Recommendations
Because the install script is running as root inside the chroot, write this config file directly from the root context, before switching to the user.
For example, in your /root/chroot.sh script, before or after you create the user, add:
mkdir -p "THEMEDIR/gtk−3.0"cp−r"{SRC_DIR}/assets/gtk/scalable" "{SRC_DIR}/main/gtk-3.0/gtk-Dark.scss" ]; then
sassc -M -t expanded "{THEME_DIR}/gtk-3.0/gtk.css"
cp "{THEME_DIR}/gtk-3.0/gtk-dark.css"
fi
--- GTK4 ---
mkdir -p "THEMEDIR/gtk−4.0"cp−r"{SRC_DIR}/assets/gtk/scalable" "{SRC_DIR}/main/gtk-4.0/gtk-Dark.scss" ]; then
sassc -M -t expanded "{THEME_DIR}/gtk-4.0/gtk.css"
cp "{THEME_DIR}/gtk-4.0/gtk-dark.css"
fi
--- index.theme ---
cat > "THEMEDIR{THEME_NAME}
Comment=Gruvbox Dark GTK Theme
EOF
gsettings set org.gnome.desktop.interface gtk-theme 'Gruvbox-Dark'
gsettings set org.gnome.desktop.interface icon-theme "Papirus-Dark"
gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark'
Mime setup
shopt -s nullglob
for desktopfile in /usr/share/applications/*.desktop; do
mime_types=(grep′MimeType=′"desktopfile" | head -n1 | cut -d= -f2)
if [[ -n mime_types"
for mime in "mime" ]] && continue
xdg-mime default "desktopfile")" "type; done
for type in jpeg svg png gif webp bmp tiff; do xdg-mime default swayimg.desktop image/$type; done
Libvirt setup
sudo virsh net-autostart default
Launch Firefox in background (no window shown)
echo "firefor stuff"
firefox --headless &
Wait few seconds for profile directory to be created
timeout=7 # Thala for a reason
elapsed=0
until profile_dir=(find ~/.mozilla/firefox -maxdepth 1 -type d -name '*.default-release' | head -n1) && [[ -n "profile_dir" ]]; do
sleep 1
((elapsed++))
if (( elapsed >= timeout )); then
echo "Timeout waiting for Firefox profile creation"
break
fi
done
if [[ -n "profiledir"]];thenln−sf"HOME/.dotfiles/user.js" "$profile_dir/user.js"
fi
is there something form run.sh which can go into chroot.sh
Good question! Your run.sh script is mostly a post-install user environment setup script, meant to be run under your normal user after installation and first boot.
The chroot.sh runs inside the arch-chroot environment during the install process when the system root is /mnt. Some things in run.sh require a running graphical session, user environment variables, or a live user session, so they do not belong in chroot.sh.
Breakdown of what can/cannot go in chroot.sh:
Section / Command
Move to chroot.sh?
Reason/Notes
Theme installation (GruvboxGtk)
No
Needs user home, X/Wayland environment, sassc may depend on user environment. Best run as user post-install.
gsettings set commands
No
Requires a graphical session / dbus and user environment.
Mime type setup with xdg-mime
No
User environment tools, works after user login.
virsh net-autostart default
Maybe
Needs libvirt running. Could be enabled in chroot but service needs to be enabled properly. Usually done post-install.
Running Firefox headless and linking user.js
No
Requires user directories and Firefox profile to exist. Needs user context/session.
UFW commands (sudo ufw allow ...)
Yes
Firewall config can be done inside chroot. Needs root but no user session.
Enabling UFW service
Yes
Enable systemd service, no user environment needed.
Flatpak remote add
Maybe
Can be added system-wide in chroot if flatpak installed, but typically run by user post-install.
Snapper setup
Yes
Snapper configs and timers should be configured and enabled in system install phase.
Running aur.sh
No
AUR helper scripts typically run after the install and user environment is ready.
User or first-boot script (run.sh, or systemd user service, or a post-install manual step): user environment setup, themes, user configuration
Small tip for you:
If you want to automate the user environment setup fully, create a run.sh that is called as that user after first boot to do theme installation, gsettings, mime types, firefox profile setup, flatpak remote add, and AUR install.
chroot.sh is only for base system + system services config.
If you want, I can help you split your current run.sh into a chroot.sh and a post-install user script properly. Would you like that?