Skip to content

Instantly share code, notes, and snippets.

@lvaylet
Last active February 5, 2024 13:28
Show Gist options
  • Save lvaylet/c931e881f4038080b47646be1da6be65 to your computer and use it in GitHub Desktop.
Save lvaylet/c931e881f4038080b47646be1da6be65 to your computer and use it in GitHub Desktop.
Inspired by Arch Linux Installation Guide 2020 - DistroTube

Arch Linux Installation Guide

Create a new VM in VirtualBox or VMWare Player with:

  • 2 CPUs
  • 4096 MB RAM
  • 20 GB disk
  • Enable EFI
  • 128 MB video memory
  • Enable 3D Acceleration
  • The official Arch Linux ISO mounted

With VMWare Player, you might need to edit <VM>.vmx and add/edit the firmware = "efi" line to enable EFI.

Launch the VM and wait for the root@archiso ~ # prompt to show up.

Manual Installation

# If needed, list available console keymaps and modify default US layout
ls /usr/share/kbd/keymaps/**/*.map.gz | less
ls /usr/share/kbd/keymaps/**/*.map.gz | grep -i fr
#loadkeys fr-latin1  # supports most accentuated characters, see https://wiki.archlinux.fr/Clavier#Mapping_fran.C3.A7ais for more details

# Verify boot mode. No errors = UEFI mode. DIrectory does not exist = BIOS mode.
ls /sys/firmware/efi/efivars

# Check network connectivity
ip link
ping -c 3 archlinux.org
ping -c 3 google.com

# Make sure system clock is accurate and check service status
timedatectl set-ntp true
timedatectl status

# List and partition disks
fdisk -l
fdisk /dev/sda

---

# BIOS mode
o (create a new empty DOS partition table)

n ()
p (primary)
<Enter> (partition number)
<Enter> (first sector)
+2G (last sector)

n ()
p ()
<Enter> (partition number)
<Enter> (first sector)
<Enter> (last sector)

t (change a partition type)
1 (partition number)
82 (Linux Swap)

p (print the partition table)
w (write table to disk and exit)

# Format partitions and enable swap
mkswap /dev/sda1
swapon /dev/sda1
mkfs.ext4 /dev/sda2

# Mount root partition
mount /dev/sda2 /mnt

---

# UEFI mode
g (create a new empty GPT partition table)

EFI: n (add a new partition)
     1 (partition number)
     <Enter> (first sector)
     +512M (last sector)  # between 100 MB and 550 MB
Swap: n (add a new partition)
      2 (partition number)
      <Enter> (first sector)
      +2G (last sector)
Root: n (add a new partition)
      3 (partition number)
      <Enter> (first sector)
      <Enter> (last sector)

t (change a partition type)
1 (partition number)
1 (EFI System)
t (change a partition type)
2 (partition number)
19 (Linux Swap)

p (print the partition table)
w (write table to disk and exit)

# Format partitions and enable swap
mkfs.fat -F32 /dev/sda1
mkswap /dev/sda2
swapon /dev/sda2
mkfs.ext4 /dev/sda3

# Mount root partition
mount /dev/sda3 /mnt

---

# Sync pacman repository and install reflector to list fresh and fast mirrors
pacman -Syy
pacman -S reflector
cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak
reflector -c "FR" -f 12 -l 10 -n 12 --save /etc/pacman.d/mirrorlist

# Install essential packages
pacstrap /mnt base linux linux-firmware vim curl git

# Generate file system table (fstab) with UUIDs (-L for labels)
genfstab -U /mnt >> /mnt/etc/fstab
cat /etc/fstab

# Change root into new system
arch-chroot /mnt

# Set time zone and hardware clock
# ln -sf /usr/share/zoneinfo/<REGION>/<CITY> /etc/localtime or timedatectl set-timezone <REGION>/<CITY>
# ls /usr/share/zoneinfo/ or timedatectl list-timezones to list available regions and cities
ln -sf /usr/share/zoneinfo/Europe/Paris /etc/localtime
hwclock --systohc

# Generate locales and set LANG variable
echo 'en_US.UTF-8 UTF-8' >> /etc/locale.gen  # TODO find a sed command to uncomment the matching line(s)
locale-gen
echo 'LANG=en_US.UTF-8' > /etc/locale.conf
export LANG=en_US.UTF-8
# Make non-default keyboard layout permanent
#echo 'KEYMAP=fr-latin1' > /etc/vconsole.conf
#echo /etc/vconsole.conf

# Network configuration
echo arch > /etc/hostname
cat /etc/hostname
cat <<EOT >> /etc/hosts
127.0.0.1    localhost
::1          localhost
127.0.1.1    arch.localdomain  arch
EOT
cat /etc/hosts

# Set root password
passwd

# Create user(s) and add them to wheel group for sudo, audio and video groups for multimedia
useradd -m laurent
passwd laurent
usermod -aG wheel,audio,video laurent
pacman -S sudo
EDITOR=vim visudo
# Uncomment %wheel ALL=(ALL) ALL  # TODO Find an equivalent with sed that works with visudo?

# Install boot loader
pacman -S grub

---

# UEFI mode
pacman -S efibootmgr dosfstools os-prober mtools
mkdir /boot/EFI
mount /dev/sda1 /boot/EFI
grub-install --target=x86_64-efi --bootloader-id=grub_uefi --recheck
grub-mkconfig -o /boot/grub/grub.cfg

---

# BIOS mode
grub-install /dev/sda
grub-mkconfig -o /boot/grub/grub.cfg

---

# Finalize network configuration
pacman -S networkmanager
systemctl enable NetworkManager

# Exit chroot enviroment, unmount all partitions and reboot
exit
umount -R /mnt
reboot  # or shutdown now

Automatic Installation (with picodotdev/alis)

According to the official GitHub repo:

Arch Linux Install Script (or alis) installs unattended, automated and customized Arch Linux system.

Download the scripts with:

curl -sL https://bit.ly/2F3CATp | bash

Edit the configuration and select the packages to install with:

vim alis.conf
vim alis-packages.conf

Here are the settings/variables to modify for a VM and a US keyboard with two locales (US and FR):

KEYS="us"
REFLECTOR="true"
REFLECTOR_COUNTRIES=("France")
TIMEZONE="/usr/share/zoneinfo/Europe/Paris"
LOCALES=("en_US.UTF-8 UTF-8" "fr_FR.UTF-8 UTF-8")
LOCALE_CONF=("LANG=en_US.UTF-8" "LANGUAGE=en_US:en:fr_FR:fr")
KEYMAP="KEYMAP=us"
KEYLAYOUT="us"
USER_NAME="laurent"
BOOTLOADER="grub !refind !systemd"
PACKAGES_INSTALL="true"

Finally, start the installation with:

./alis.sh

Installation could hardly get any simpler :-)

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment