Skip to content

Instantly share code, notes, and snippets.

@duyfken
Last active November 7, 2022 05:08
Show Gist options
  • Save duyfken/80089f6e25442ad4721f80f43bf6ccf9 to your computer and use it in GitHub Desktop.
Save duyfken/80089f6e25442ad4721f80f43bf6ccf9 to your computer and use it in GitHub Desktop.
Simple Arch Linux Installation from scratch in the command line ("The Arch Way")

Arch Linux Installation

1. Download the image and liveboot

The images can be found at https://www.archlinux.org/download/

The image can be flashed onto a USB with any software (like balenaEtcher or simply dd) or burned to a CD/DVD.

Boot the image device (via BIOS preferrably as it is that bit easier to setup than UEFI and makes no difference otherwise)

2. List Disks/Partitions

  • fdisk -l

3. Partition Disk/s as/if necessary

If the partitions are already as you'd like (as you're reinstalling your system), go to the next step and just reformat the partition/s you want wiped, ie. root partition, and move on to mounting (step 5)
  • fdisk /dev/sdb

    • Remove existing partition/s (if you want)
    • o if disk is blank to create a MBR partition table
    • Create a root partition
    • If you need hibernation, create a swap partition. Otherwise, don't, and adjust the following partition numbers accordingly.
    • Create a home partition

4. Create filesystems for the partitions (format)

  • mkfs.ext4 /dev/sdb1
  • mkswap /dev/sdb2 (only if you want to create a swap/hibernation partition)
  • swapon /dev/sdb2 (only if you created a swap/hibernation partition)
  • mkfs.ext4 /dev/sdb3

5. Mount file systems

  • mount /dev/sdb1 /mnt
  • mkdir /mnt/home
  • mount /dev/sdb3 /mnt/home

6. Install base packages

  • pacstrap /mnt base linux-lts linux-firmware nano amd-ucode

Swap amd-ucode for intel-ucode if you have a Intel CPU

Install ntfs-3g when installing base packages if you have NTFS partitions you want available on first start

7. Generate the fstab (file system table)

  • genfstab -U /mnt >> /mnt/etc/fstab

8. Change into root in new system

  • arch-chroot /mnt

9. Set Timezone and Clock

  • ln -sf /usr/share/zoneinfo/Australia/Perth /etc/localtime

use timedatectl list-timezones to find your timezone if you don't know it or it's format

  • hwclock --systohc assumes hwclock is set in UTC

10. Set your Locale

  • nano /etc/locale.gen
  • Uncomment en_US.UTF-8 UTF-8, en_AU.UTF-8 UTF-8, en_GB.UTF-8 UTF-8
  • locale-gen
  • nano /etc/locale.conf
LANG=en_AU.UTF-8
LANGUAGE=en_AU:en_GB:en_US

This makes en_AU the default language and then falls back to en_GB and en_US in that order

11. Generate your Hostname and install a CLI Network Manager (Only if staying exclusively CLI)

  • echo <hostname> > /etc/hostname
  • Edit /etc/hosts to contain same
127.0.0.1	localhost
::1		localhost
127.0.1.1	<hostname>.localdomain	<hostname>

swap <hostname> for your actual desired hostname

Only do the following to enable the networkd service if you're going to exclusively use a CLI. Enabling it and installing a GUI will cause problems when NetworkManager or WICD try to take over

  • systemctl enable systemd-networkd.service

12. Activate Sudo & add a User and their passwd

  • pacman -S sudo
  • In /etc/sudoers, uncomment %wheel ALL=(ALL) ALL
  • useradd -m -g users -G wheel -s /bin/bash <username> use -M if user exists in /home, else -m to create userdir
  • passwd <username>

13. Create Bootloader

  • pacman -S grub os-prober (only install os-prober if you have/want other OSes on your system)
  • grub-install /dev/sdb
  • grub-mkconfig -o /boot/grub/grub.cfg

14. Update pacman mirrors and do a update check

  • pacman -S pacman-contrib
  • curl -s "https://archlinux.org/mirrorlist/?country=AU&protocol=https&ip_version=6&use_mirror_status=on" | sed -e 's/^#Server/Server/' -e '/^#/d' | rankmirrors -n 5 -

This selects the IPv6 capable HTTPS mirrors that are located in Australia, sorts them by download speed, and overwrites the /etc/pacman.d/mirrorlist file with the top 5 results

  • pacman -Syu

15a. GUI setup/install - option 1 xfce

  • pacman -S xorg-server xfce4 network-manager-applet lightdm-gtk-greeter gvfs xf86-video-amdgpu pipewire-pulse wireplumber pavucontrol

swap xf86-video-amdgpu for xf86-video-intel or nvidia as needed

xorg-server is the display server, xfce4 is the desktop environment, network-manager-applet is NetworkManager and it's applet for the DE, lightdm-gtk-greeter is the login screen, gvfs is for mounting and trash functionality in file managers, pipewire-pulse is the next generation sound server replacement for and compatible with PulseAudio, wireplumber Pipewire's session manager and pavucontrol is a PulseAudio sound mixer (for GTK+ systems)

  • systemctl enable lightdm.service
  • systemctl enable NetworkManager.service

15b. GUI setup/install - option 2 lxqt

  • pacman -S xorg-server lxqt network-manager-applet networkmanager-qt sddm gvfs xf86-video-amdgpu pipewire-pulse wireplumber pavucontrol-qt

swap xf86-video-amdgpu for xf86-video-intel or nvidia as needed

xorg-server is the display server, lxqt is the desktop environment, network-manager-applet is NetworkManager and it's applet for the DE, sddm is the login screen, gvfs is for mounting and trash functionality in file managers, pipewire-pulse is the next generation sound server replacement for and compatible with PulseAudio, wireplumber Pipewire's session manager and pavucontrol-qt is a PulseAudio sound mixer (for qt systems)

  • systemctl enable sddm.service
  • systemctl enable NetworkManager.service

16. Activate Multilib mirrors run and build 32 bit apps (wine, steam etc.)

  • nano /etc/pacman.conf Uncomment
[multilib]
Include = /etc/pacman.d/mirrorlist

17. Lock out root access for security purposes

Once sudo is properly configured, full root access can be heavily restricted or denied without losing much usability. To disable root, but still allowing to use sudo, you can use: passwd -l root

If you somehow don't value security, you can choose to leave root active, but for the love of God, set a very strong password for the safety of your system if you go down this path! passwd

18. Reboot and enjoy!

  • Reboot to System (safely using these commands)
    • exit to leave chroot
    • manually umount -R /mnt
    • then reboot

19. Install AUR (Arch User Repository) helpers

  • sudo pacman -Sy --needed base-devel git go
  • cd /tmp
  • git clone https://aur.archlinux.org/yay.git && cd yay/
  • makepkg -si CLI AUR helper yay will now be ready to use
  • yay -S pamac-aur Only if proceeding to install a GUI and you want to use GUI software management, as pamac is a GUI AUR helper!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment