A complex simple script to install Arch Linux
- Shell 100%
| install | ||
| README.md | ||
A complex simple Arch installation script
Background
I wanted a script that I could use to quickly set up Arch Linux in a virtual machine. That script quickly grew to support features and became what it is today.
Features
- Allows for using a configuration file from a URL to set parameters
- Gets a list of possible disks to use; if there is only one, it uses it
- Allows for complex disk setup by bypassing configuring disks altogether and letting the user configure disks manually beforehand
- Allows for creation of a user along with setting a password for the user
- Allows for downloading an authorized_keys file to be used by root and, if created, the user
- Allows for setting root's password. If a user is created, it will use that user's password unless root's password is set explicitly
- Allows for doing LUKS encryption with a password
- Allows for installing with ext4, xfs, and btrfs
- Creates default set of btrfs subvolumes (when choosing btrfs): @ @home @usr @var @opt @tmp @srv
- Allows for specifying additional btrfs subvolumes
- Allows for adding an additional pacman repo for installing custom packages
- Allows for specifying additional packages beyond a minimal installation
- Allows for setting a hostname and domainname
- Allows for setting a Git URL containing a repository of user configurations This repository will be copied to ~username/.config and supports with copying from the base of the repository or a .config directory inside the repo
- Allows for skipping the "Ready?" prompt
Opinionated Package/Configuration Choices
- systemd-boot
- Network Manager
- Bash
- neovim
- pipewire
- htop
- sudo
- UEFI
Caveats
- Hard codes using the whole disk
- Hard codes creating /boot with 1G and swap using the size of RAM (or 100m for VMs)
- Script does not do any network setup. Network Manager
Help text
usage: install [-h] [-t] [-x|-X] [-Q] [-c CONF] [-k KEYFILE|-K] [-j DOWNLOADS]
[-d DISK|-D] [-e ENCPASS|-E] [-f FILESYSTEM|-F] [-b SUBVOLS]
[-s ADDREPO|-S] [-a PKGLIST|-A] [-h HOSTNAME|-H] [-n DOMAINNAME|-N]
[-u USERNAME|-U] [-p USERPASS|-P] [-r ROOTPASS|-R] [-g GITURL|-G]
-h : this help text
-t : test mode
-x : start without prompting to start after gathering any needed input
-X : print values and exit
-Q : print secrets (passwords and passphrases) in summary
-c CONF : Use or download config file (local file or URL)
-K : prompt for user ssh authorized_keys file (local file or url)
-k KEYFILE : specify user ssh authorized_keys file (local file or url)
-j DOWNLOADS : specify the number of parallel downloads (default: 16)
-D : do not prompt for disk setup (default: prompt)
-d DISK : specify disk_device DISK (e.g. vda) (default: prompt)
-E : prompt for disk encryption and password (default: no encryption)
-e ENCPASS : specify encryption password for luks (default: no encryption)
-F : prompt for filesystem type for system disk (default: ext4)
-f FILESYSTEM : specify filesystem type for system disk (default: ext4)
-b SUBVOLS : list of additional btrfs subvolumes
-S : prompt for repo server to add to /etc/pacman.conf
-s ADDREPO : specify repo server to add to /etc/pacman.conf
-A : prompt for additional package list
-a PKGLIST : specify additional package list
-H : prompt for hostname (default: archlinux)
-h HOSTNAME : specify hostname (default: archlinux)
-N : prompt for network domain name (default: localdomain)
-n DOMAINNAME : specify network domain name (default: localdomain)
-U : prompt for username
-u USERNAME : specify username
-P : prompt for user password (default: password)
-p USERPASS : specify user password (default: password)
-R : prompt for root password (default: user password (-p))
-r ROOTPASS : specify root password (default: user password (-p))
-G : prompt for Git URL for user config files
-g GITURL : specify Git URL for user config files
NOTE: Specifying -D will bypass disk setup. /mnt must already be mounted
WARNING: If there is only one available disk, the script will use it automatically
IT WILL NOT PROMPT in this case
Use -a/-A to add packages like a window manager and other packages
If a window manager is added, supporting packages will automatically
be added too
If choosing btrfs, @ @home @usr @var @opt @tmp @srv will be created; to add additional subvolumes
use -b '@foo=/path/to/mnt1 @bar=/path2'
Additional repo server format (added with -S or '-s repo') must be added with
the format: name=repo_url (e.g. )
To prevent an additional repo to be added to /etc/pacman.conf, use '-s none'
Example Configuration File
username = mike
password = mysupersecretpassword
key_file = https://erdely.in/authorized_keys
repo_server = home=https://repo.erdely.in/Systems/Arch/aur/
hostname = mytesthost
domainname = erdelynet.com
git_url = https://git.erdelynet.com/mike/minimal-dotfiles
root_password = extrasecurepassword
encryption_password = encryption password goes here
pkg_list = sway niri firefox
filesystem = btrfs
subvols = @vms=/var/lib/libvirt/images @docker=/var/lib/docker
# disk_device = sda
# parallel_downloads = 4
Example Uses
curl -sL erdely.in/arch/install | bash -- -s -c erdely.in/arch/configbash ./install -d vda -f btrfs -u testuser -p testpassword1 -e encpass123