Skip to content

Instantly share code, notes, and snippets.

@navaz-alani
Last active December 16, 2021 15:23
Show Gist options
  • Save navaz-alani/4ab5657031334b67577ed3e98073cb77 to your computer and use it in GitHub Desktop.
Save navaz-alani/4ab5657031334b67577ed3e98073cb77 to your computer and use it in GitHub Desktop.
Arch/Artix Linux Installation

Arch/Artix Linux Base Installation

Prepare Installation Media

  • Download the (base) ISO image and create a bootable flash drive
    • Figure out the disk's name on your system; be careful to get this correct otherwise you can very easily destory your current system
      • on Linux, use lsblk to figure out which disk to use
      • on MacOS, use diskutil list to figure out which disk to use
      • make sure you use the disk name, not a partition
        • /dev/diskX on MacOS, NOT /dev/diskXsY (X, Y are positive integers)
        • /dev/sdX on Linux, NOT /dev/sdXY (X is an alphabetical character, Y is a positive integer)
    • Using dd (if on MacOS, do this - others don't seem to work): dd if=[path_to_iso] of=[disk] -bs=4M status=progress
      • if on MacOS, the status=progress argument is not supported - you'll have to use Ctrl+t to send a signal to dd to display its progress
      • also on MacOS, use bs=4m instead
    • Using cat: cat [path_to_iso] > [disk]
    • Using cp: cp [path_to_iso] [disk]

Setup Internet Connection

  • If possible, use an ethernet connection - almost always works out of the box
  • For WiFi in the live environment
    • Artix
      • sudo rfkill unblock wifi
      • connmanctl enable wifi
      • connmanctl agent on
      • connmanctl scan wifi
      • connmanctl services
      • connmanctl connect [service] then enter password
    • Arch
      • nmtui and setup

Partition Disk

  • Figure out if you are on a UEFI system (if on UEFI, the directory /sys/firmware/efi should exist)
  • Run lsblk and find which disk to partition
  • Run cfdisk /dev/[disk] and partition the disk
    • BOOT partition (make it 1G); also set the bootable flag on it
    • ROOT partition (make it more than 100G - this is where software packages will be installed to so make an informed decision based on the packages you expect to install on the system, as well as the amount of storage available)
    • SWAP partition (at least as large as the RAM installed)
      • Swap space is used by the OS in a few conditions; if memory pressure on RAM is very high, the OS may "swap" pages from RAM to disk (specifically to the SWAP partition).
      • Another (arguably important) use for SWAP is to enable hibernation. When the system is called to hibernate, the OS copies all of the contents of RAM into SWAP (which is why SWAP should be at least the size of installed RAM) and shuts down the machine. On startup, the RAM is restored from SWAP and the system can resume.
    • HOME partition (rest of the space)
      • This is so that if you want to reinstall Linux, all of your files in the home directory can be preserved
      • Even if you don't plan to reinstall Linux, it may be wise to have such a partition - some problems may be simple to fix with a reinstall...
  • Format the partitions
    • If running UEFI, format boot partition as FAT-32 (mkfs.fat -F 32 [part]), otherwise just format all partitions as EXT4 (mkfs.ext4 [part])
    • If you created a SWAP partition, format it using mkswap [part] command.
    • You can also use the above mkfs/mkswap commands with the -L [label] argument which will set the partition labels (label should typically be BOOT, ROOT, HOME, SWAP)
  • Mount the partitions
    • ROOT partition on /mnt, BOOT partition on /mnt/boot, HOME partition on /mnt/home
    • mount [root_part] /mnt
    • mkdir /mnt/{boot,home}
    • mount [boot_part] /mnt/boot
    • mount [home_part] /mnt/home
    • If you created a SWAP partition, run the swapon [part] command which will indicate to the OS that the partition can be used for paging/swaping (it's opposite command is swapoff).

Install the System

  • Artix (using runit as the init system)
    • basestrap /mnt base base-devel runit elogind-runit linux linux-firmware vim
    • fstabgen -U /mnt >> /mnt/etc/fstab
  • Arch
    • pacstrap /mnt base base-devel runit elogind-runit linux linux-firmware vim
    • genfstab -U /mnt >> /mnt/etc/fstab

Important: make sure that there are no duplicate entries in the /mnt/etc/fstab (file-system table) file (the fstab file specifies how the partitions should be mounted)

chroot Into the System & Set Up

  • Artix
    • artix-chroot /mnt
  • Arch
    • arch-chroot /mnt
  • You'll probably be in sh, run bash if you want to use that instead
  • Re-arrange the pacman mirrors so that the ones closest to you are at the top (file /etc/pacman.d/mirrorlist); you may get better download speeds
  • (Artix) you may want to add the arch-linux mirrors to pacman so that you can get the software which artix's mirrors don't have yet;
    • Run pacman -S artix-archlinux-support and add the extra, community and multilib mirrors in the /etc/pacman.conf file AFTER the artix mirrors
      [extra]
      Include = /etc/pacman.d/mirrorlist-arch
      
      [community]
      Include = /etc/pacman.d/mirrorlist-arch
      
      [multilib]
      Include = /etc/pacman.d/mirrorlist-arch
      
    • Run pacman-key --populate after this
  • Set timezone ln -sf /usr/share/zoneinfo/[region]/[city] /etc/localtime
  • Update hardware clock hwclock --systohc
  • Select the locales that you want (vim /etc/locale.gen and uncomment the ones you want; probably want en_US.UTF-8 and en_US.ISO-8859-1)
  • locale-gen
  • echo "LANG=en_US.UTF-8" > /etc/locale.conf
  • Install a network manager pacman -S networkmanager networkmanager-runit
  • Run the network manager on boot (generally for a service X, this would be done using the command ln -s /etc/runit/sv/[X] /run/runit/service, but the run/runit directory is not mounted in this environment so run ln -s /etc/runit/sv/NetworkManager /etc/runit/runsvdir/current instead)
  • Give your computer a name echo [comp_name] > /etc/hostname
  • Some sensible defaults in the /etc/hosts file:
    127.0.0.1        localhost
    ::1              localhost
    127.0.1.1        [comp_name].localdomain [comp_name]
    
  • Install bootloader pacman -S grub (also install os-prober if dual booting, and efibootmgr if on EFI system)
  • Install grub on the disk
    • If using a UEFI system, run grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=grub
    • Else run grub-install --recheck /dev/sda
  • grub-mkconfig -o /boot/grub/grub.cfg
  • Set root password with passwd
  • Run exit to exit the chroot environment, unmount -R /mnt to recursively unmount all of the drive and finally reboot (remove the installation media so you don't boot into it again)

Configure User

  • useradd -mG wheel [user] - this creates the user user, creates their home directory and adds them to the wheel group (to be used in sudo setup)
  • Set user's password passwd [user]
  • sudo setup
    • Go to the /etc/sudoers file and uncomment the line which reads %wheel ALL =(ALL) ALL to allow the members of the wheel group to run root commands, as long as they know the password
    • If you want wheel users to also be able to execute commands like shutdown or pacman, you can add the following line %wheel ALL =(ALL) NOPASSWD: [commands] where commands is a comma separated command list (use the absolute path to commands)
    • Also add the line Defaults !tty_tickets to prevent reentering the password when you spawn a new terminal

Graphical Environment (using dwm)

  • Install Xorg server pacman -S xorg-server xorg-xinit
  • Install many fonts
    • pacman -S noto-fonts{,-extra,-cjk,-emoji}
  • Install dwm/dmenu dependencies
    • pacman -S lib{xft,xinerama}
  • Install the software you want (here: terminal kitty, file manager pcmanfm if you need it)
    • pacman -S kitty pcmanfm
  • (Do this as the user you created) get dwm and dmenu
    • git clone https://git.suckless.org/dwm
    • git clone https://git.suckless.org/dmenu
    • Bind the terminal you installed in the dwm/config.h instead of the default st terminal (also make whatever changes to the config you want)
  • In each of the directories, run sudo make install (resolve any dependency errors as necessary)
  • Add the graphical programs which need to be run in ~/.xinitrc (if only dwm needs to run, then add the line exec dwm which should the last line in the file always; other entries should end with & to run in the background)
  • Try running startx which starts your graphical environment and debug any issues that come up (the log file is useful)
    • If you have any issues (such as permissions errors), try rebooting and then trying again
    • Ensure you install the drivers for your graphics card otherwise the command will fail (if you have to do this, reboot and then try startx again)

Sound System

By default alsa, which is a kernel module is installed and can provide a low-level interface to control audio, but this may be too low level for most applications. In addition, many applications use the pulseaudio sound server which provides a higher level interface to control the sound system.

  • To install the pulseaudio server, run pacman -S pulseaudio.
  • A nice way to interface with pulseaudio is the GUI utility pavucontrol (which can be installed using pacman -S pavucontrol).
  • There is also a curses and command line utility which called pulsemixer (which can be installed with pacman -S pulsemixer). It has a nice curses interface which can be used instead of pavucontrol and the command line version can be used in scripts/programming hot-keys.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment