mirror of
https://github.com/donovanglover/nix-config.git
synced 2025-06-18 07:36:57 +02:00
Migrate install scripts to "four simple steps"
It is only now that I realize that the Arch Wiki is divided into four steps: Pre-installation, Installation, Configuration, and Post-installation. This commit changes my install scripts to follow that same structure, overall making things a lot easier to both understand and maintain as a whole.
This commit is contained in:
parent
b46a84d839
commit
4e7ba005a8
@ -1,17 +1,18 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Make a DOS partition table with one primary ext4 partition and
|
||||
# enable boot for it. Then, create a primary swap partition with
|
||||
# the remaining disk space.
|
||||
#
|
||||
# For example, if your hard drive is 512GB then you'd allocate
|
||||
# just under that for the ext4 partition and the remaining GB to
|
||||
# swap, depending on how much you think you'll need.
|
||||
# This script assumes you already have an active internet connection
|
||||
# (preferably through Ethernet).
|
||||
#
|
||||
# https://wiki.archlinux.org/index.php/Installation_guide
|
||||
|
||||
set -xe
|
||||
|
||||
# Sync the time with one online before doing anything
|
||||
timedatectl set-ntp true
|
||||
|
||||
# Make a DOS partition table with one primary ext4 partition and
|
||||
# enable boot for it. Then, create a primary swap partition with
|
||||
# the remaining disk space.
|
||||
parted /dev/sda mklabel msdos
|
||||
|
||||
parted /dev/sda mkpart primary ext4 1MiB 60GiB
|
||||
@ -19,3 +20,14 @@ parted /dev/sda mkpart primary ext4 1MiB 60GiB
|
||||
parted /dev/sda set 1 boot on
|
||||
|
||||
parted /dev/sda mkpart primary linux-swap 60GiB 100%
|
||||
|
||||
# Format sda1 with ext4 and sda2 with swap
|
||||
mkfs -t ext4 /dev/sda1
|
||||
|
||||
mkswap /dev/sda2
|
||||
|
||||
# Enable the swap partition
|
||||
swapon /dev/sda2
|
||||
|
||||
# Mount the newly created file system (/dev/sda1) to /mnt.
|
||||
mount /dev/sda1 /mnt
|
60
scripts/arch/003-configure
Normal file
60
scripts/arch/003-configure
Normal file
@ -0,0 +1,60 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Once this script finishes, change the root password with passwd,
|
||||
# then unmount /mnt (with umount) and restart the system.
|
||||
#
|
||||
# https://wiki.archlinux.org/index.php/Installation_guide
|
||||
|
||||
set -xe
|
||||
|
||||
$HOSTNAME = "arch"
|
||||
|
||||
# Generate the fstab file (so the filesystem is mounted on boot)
|
||||
genfstab -U /mnt > /mnt/etc/fstab
|
||||
|
||||
# Set the timezone
|
||||
arch-chroot /mnt ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime
|
||||
|
||||
# Generate /etc/adjtime
|
||||
arch-chroot /mnt hwclock --systohc
|
||||
|
||||
# Set the hostname
|
||||
echo "$HOSTNAME" > /mnt/etc/hostname
|
||||
|
||||
# Configure the hosts file (if your system has a permanent IP address, use that instead of 127.0.1.1)
|
||||
echo "127.0.0.1 localhost" >> /mnt/etc/hosts
|
||||
echo "::1 localhost" >> /mnt/etc/hosts
|
||||
echo "127.0.1.1 $HOSTNAME.localdomain $HOSTNAME" >> /mnt/etc/hosts
|
||||
|
||||
# Set the language to English and use the en_US.UTF-8 locale.
|
||||
echo "LANG=en_US.UTF-8" > /mnt/etc/locale.conf
|
||||
echo "en_US.UTF-8 UTF-8" > /mnt/etc/locale.gen
|
||||
|
||||
# Generate the locale.
|
||||
arch-chroot /mnt locale-gen
|
||||
|
||||
# Explicitly set the keymap to US.
|
||||
echo "KEYMAP=us" > /mnt/etc/vconsole.conf
|
||||
|
||||
# Change the terminal font to a larger one (`latarcyrheb-sun32` is also an option)
|
||||
echo "FONT=ter-132n" >> /mnt/etc/vconsole.conf
|
||||
|
||||
# Install grub to the primary partition.
|
||||
arch-chroot /mnt grub-install /dev/sda
|
||||
|
||||
# Prevent the GRUB window from showing at boot, ideal for single OS machines (undo with chroot and mkconfig)
|
||||
sed -i '/GRUB_TIMEOUT/c\GRUB_TIMEOUT=0' /mnt/etc/default/grub
|
||||
|
||||
# This should make the startup process not output anything (not tested)
|
||||
sed -i '/GRUB_CMDLINE_LINUX_DEFAULT/c\GRUB_CMDLINE_LINUX_DEFAULT="quiet show_status=0 rd.udev.log-priority=3 loglevel=3"' /mnt/etc/default/grub
|
||||
|
||||
# Make the configuration file for grub.
|
||||
arch-chroot /mnt grub-mkconfig -o /boot/grub/grub.cfg
|
||||
|
||||
# Change the shell of the root account to fish.
|
||||
arch-chroot /mnt chsh -s /usr/bin/fish
|
||||
|
||||
# Save our hardware information with mkinitcpio. This creates
|
||||
# an initial ramdisk environment that allows us to boot the
|
||||
# Linux kernel.
|
||||
arch-chroot /mnt mkinitcpio -p linux
|
39
scripts/arch/004-postinstall
Normal file
39
scripts/arch/004-postinstall
Normal file
@ -0,0 +1,39 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Common post-install system configuration that doesn't involve any
|
||||
# external packages (besides fish)
|
||||
#
|
||||
# https://wiki.archlinux.org/index.php/General_recommendations
|
||||
|
||||
set -xe
|
||||
|
||||
$USERNAME = "hello"
|
||||
|
||||
# Start and enable the DHCP client daemon service
|
||||
systemctl start dhcpcd.service
|
||||
systemctl enable dhcpcd.service
|
||||
|
||||
# Set the timezone with systemd, and sync it periodically with a remote server
|
||||
timedatectl set-timezone America/New_York
|
||||
timedatectl set-ntp true
|
||||
|
||||
# Font settings (https://old.reddit.com/r/archlinux/comments/5r5ep8)
|
||||
ln -s /etc/fonts/conf.avail/70-no-bitmaps.conf /etc/fonts/conf.d # Disable embedded bitmaps for all fonts
|
||||
ln -s /etc/fonts/conf.avail/10-sub-pixel-rgb.conf /etc/fonts/conf.d # Enable sub-pixel RGB rendering
|
||||
ln -s /etc/fonts/conf.avail/11-lcdfilter-default.conf /etc/fonts/conf.d # Enable the LCD filter (reduces color fringing)
|
||||
|
||||
# Change the systemd wait time from 90s to 30s, mitigating a potential hang at shutdown
|
||||
echo "DefaultTimeoutStartSec=30s" >> /etc/systemd/system.conf
|
||||
echo "DefaultTimeoutStopSec=30s" >> /etc/systemd/system.conf
|
||||
|
||||
# Enable colors in pacman by uncommenting the Color line.
|
||||
sed -i '/Color/s/^#//g' /etc/pacman.conf
|
||||
|
||||
# Give users in the wheel group permission to use sudo
|
||||
echo "%wheel ALL=(ALL) ALL" >> /etc/sudoers
|
||||
|
||||
# Create a new user account with sudo privileges and the fish shell.
|
||||
arch-chroot /mnt useradd -m -g users -G wheel -s /usr/bin/fish $USERNAME
|
||||
|
||||
# Then, set the password equal to the username (change this later).
|
||||
echo "$USERNAME:$USERNAME" | chpasswd
|
@ -1,11 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Sync the time with one online so we have the proper
|
||||
# time before doing anything. Make sure you're connected
|
||||
# to the internet first.
|
||||
#
|
||||
# https://wiki.archlinux.org/index.php/Installation_guide
|
||||
|
||||
set -xe
|
||||
|
||||
timedatectl set-ntp true
|
@ -1,14 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Format sda1 with an ext4 partition and sda2 with a swap partition.
|
||||
# Then, enable swap for sda2.
|
||||
#
|
||||
# https://wiki.archlinux.org/index.php/Installation_guide
|
||||
|
||||
set -xe
|
||||
|
||||
mkfs -t ext4 /dev/sda1
|
||||
|
||||
mkswap /dev/sda2
|
||||
|
||||
swapon /dev/sda2
|
@ -1,9 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Mount the newly created filesystem (/dev/sda1) to /mnt.
|
||||
#
|
||||
# https://wiki.archlinux.org/index.php/Installation_guide
|
||||
|
||||
set -xe
|
||||
|
||||
mount /dev/sda1 /mnt
|
@ -1,10 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Generate the fstab file so that the filesystem is
|
||||
# automatically mounted on boot.
|
||||
#
|
||||
# https://wiki.archlinux.org/index.php/Installation_guide
|
||||
|
||||
set -xe
|
||||
|
||||
genfstab -U /mnt > /mnt/etc/fstab
|
@ -1,25 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Set your timezone and update the hardware clock, assuming
|
||||
# it is currently set to UTC. Note that if you want to use
|
||||
# multiple operating systems on the same hardware, you
|
||||
# shouldn't do this.
|
||||
#
|
||||
# Check whether or not your hardware clock (RTC) is localtime:
|
||||
# timedatectl | grep local
|
||||
#
|
||||
# Change hardware clock to localtime:
|
||||
# timedatectl set-local-rtc 1
|
||||
#
|
||||
# Change hardware clock back to UTC:
|
||||
# timedatectl set-local-rtc 0
|
||||
#
|
||||
# Note that RTC (the hardware clock) stands for "Real Time Clock"
|
||||
#
|
||||
# https://wiki.archlinux.org/index.php/Installation_guide
|
||||
|
||||
set -xe
|
||||
|
||||
arch-chroot /mnt ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime
|
||||
|
||||
arch-chroot /mnt hwclock --systohc
|
@ -1,16 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Set the hostname in all the necessary places.
|
||||
#
|
||||
# Note that if your system has a permanent IP address, that
|
||||
# should be used instead of 127.0.0.1.
|
||||
#
|
||||
# https://wiki.archlinux.org/index.php/Installation_guide
|
||||
|
||||
set -xe
|
||||
|
||||
$HOSTNAME = "arch"
|
||||
|
||||
echo "$HOSTNAME" > /mnt/etc/hostname
|
||||
echo "127.0.1.1 $HOSTNAME.localdomain $HOSTNAME" >> /mnt/etc/hosts
|
||||
|
@ -1,23 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Set the language to English and use the en_US.UTF-8 locale.
|
||||
# Then, generate it.
|
||||
#
|
||||
# Next, explicitly set the keymap to US.
|
||||
#
|
||||
# Note that we also change the terminal font to a bigger one
|
||||
# (terminus-font) since this setting also uses vconsole.conf.
|
||||
# Use `latarcyrheb-sun32` if you want to use the default
|
||||
# terminal font instead.
|
||||
#
|
||||
# https://wiki.archlinux.org/index.php/Installation_guide
|
||||
|
||||
set -xe
|
||||
|
||||
echo "LANG=en_US.UTF-8" > /mnt/etc/locale.conf
|
||||
echo "en_US.UTF-8 UTF-8" > /mnt/etc/locale.gen
|
||||
|
||||
arch-chroot /mnt locale-gen
|
||||
|
||||
echo "KEYMAP=us" > /mnt/etc/vconsole.conf
|
||||
echo "FONT=ter-132n" >> /mnt/etc/vconsole.conf
|
@ -1,14 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Change the systemd wait time from 90s to 10s, preventing the
|
||||
# system from hanging at shutdown.
|
||||
#
|
||||
# https://unix.stackexchange.com/questions/273876
|
||||
# https://old.reddit.com/r/archlinux/comments/4bawf7
|
||||
|
||||
set -xe
|
||||
|
||||
SYSTEMD="/mnt/etc/systemd/system.conf"
|
||||
|
||||
echo "DefaultTimeoutStartSec=10s" >> $SYSTEMD
|
||||
echo "DefaultTimeoutStopSec=10s" >> $SYSTEMD
|
@ -1,11 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Enable colors in pacman by uncommenting the Color line.
|
||||
#
|
||||
# https://wiki.archlinux.org/index.php/Color_output_in_console#pacman
|
||||
|
||||
set -xe
|
||||
|
||||
PACMAN="/mnt/etc/pacman.conf"
|
||||
|
||||
sed -i '/Color/s/^#//g' $PACMAN
|
@ -1,9 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Give the wheel group permission to use the sudo and su commands.
|
||||
#
|
||||
# https://wiki.archlinux.org/index.php/Sudo
|
||||
|
||||
set -xe
|
||||
|
||||
echo "%wheel ALL=(ALL) ALL" >> /mnt/etc/sudoers
|
@ -1,21 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Install grub to the primary partition. Then, make the
|
||||
# configuration file for grub.
|
||||
#
|
||||
# https://wiki.archlinux.org/index.php/Grub
|
||||
|
||||
set -xe
|
||||
|
||||
arch-chroot /mnt grub-install /dev/sda
|
||||
|
||||
# This should work, since /etc/default/grub should exist after
|
||||
# installing the grub package with pacman, although it hasn't
|
||||
# been tested yet. This prevents the GRUB window from showing
|
||||
# at boot, which is ideal for single operating system machines.
|
||||
#
|
||||
# In the future, if you need to use grub, simply chroot into
|
||||
# your system, edit the config file, and grub-mkconfig once more.
|
||||
sed -i '/GRUB_TIMEOUT/c\GRUB_TIMEOUT=0' /etc/default/grub
|
||||
|
||||
arch-chroot /mnt grub-mkconfig -o /boot/grub/grub.cfg
|
@ -1,11 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Save our hardware information with mkinitcpio. This creates
|
||||
# an initial ramdisk environment that allows us to boot the
|
||||
# Linux kernel.
|
||||
#
|
||||
# https://wiki.archlinux.org/index.php/Installation_guide
|
||||
|
||||
set -xe
|
||||
|
||||
arch-chroot /mnt mkinitcpio -p linux
|
@ -1,7 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Change the shell of the root account to fish.
|
||||
#
|
||||
# https://wiki.archlinux.org/index.php/Command-line_shell
|
||||
|
||||
arch-chroot /mnt chsh -s /usr/bin/fish
|
@ -1,23 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Create a new user account with sudo privileges and the fish shell.
|
||||
# Then, and add a password to it.
|
||||
#
|
||||
# Note that the default password will be the same as your username.
|
||||
#
|
||||
# To change the root password, use passwd.
|
||||
# To change the new user's password, use passwd <username>.
|
||||
#
|
||||
# https://wiki.archlinux.org/index.php/Password
|
||||
|
||||
set -xe
|
||||
|
||||
$USERNAME = "hello"
|
||||
|
||||
arch-chroot /mnt useradd -m -g users -G wheel -s /usr/bin/fish $USERNAME
|
||||
|
||||
# This is a workaround to the problem of using pipes with arch-chroot
|
||||
echo "echo $USERNAME:$USERNAME | chpasswd" > /mnt/root/chpasswd.sh
|
||||
chmod +x /mnt/root/chpasswd.sh
|
||||
arch-chroot /mnt /root/chpasswd.sh
|
||||
rm /mnt/root/chpasswd.sh
|
@ -1,15 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# The installation process is done. Unmount the filesystem and
|
||||
# restart the computer in order to boot into the new system.
|
||||
#
|
||||
# Alternatively, you can perform more operations with chroot
|
||||
# before you unmount and reboot.
|
||||
#
|
||||
# https://wiki.archlinux.org/index.php/Installation_guide
|
||||
|
||||
set -xe
|
||||
|
||||
umount /mnt
|
||||
|
||||
reboot
|
Loading…
x
Reference in New Issue
Block a user