Skip to content

Instantly share code, notes, and snippets.

@adriaPerez
Last active April 1, 2021 09:14
Show Gist options
  • Save adriaPerez/7fbe94222bf2e745961bf4b6472203e4 to your computer and use it in GitHub Desktop.
Save adriaPerez/7fbe94222bf2e745961bf4b6472203e4 to your computer and use it in GitHub Desktop.
ArchLinux installation

Arch Linux
Intel® Core™ i7-4790K 4.0Ghz
2x8GB DDR3 1866 PC3-14900
GeForce GTX 970/PCIe/SSE2
MSI Z97 Gaming 5

  1. Download the iso from the Archlinux Oficial Download Page.

  2. Make sure the checksum of the downloaded iso is the same that the previous download page says:

    Windows: fciv.exe -both <iso_file>
    Unix: md5sum <iso_file> && sha1sum <iso_file>
    
  3. Make a bootable USB with the downloaded iso.

    Windows: Rufus (Make sure to use 'ISO image', 'Quick format', 'FAT32', 'GPT + UEFi')
    Unix: sudo dd if=/path_to_arch_.iso of=/dev/sdX (you can use lsblk to check the devices)
    
    When using the unix method, you can monitor the progress using: https://askubuntu.com/questions/215505/how-do-you-monitor-the-progress-of-dd
    
  4. Check the BIOS is properly configured and boot with the USB:

    Boot mode = UEFI
    fast boot = disabled
    Windows 8/10 feature (aka secure boot) = disabled.
    
  5. Make sure you have a valid internet connection ping -c 3 google.com. If you don't have one, you can connect via wifi:

    # Retrieve the wireless interface name
    iw dev
    # Enable the wireless interface
    ip link set INTERFACE_NAME up
    # Run 'rfkill unblock all' If you get the error "RTNETLINK answers: Operation not possible due to RF-kill"
    # Setup the wifi connection
    wpa_passphrase "WIFI_SSID" "WIFI_PASSPHRASE" > /tmp/wpa_setup.tmp
    wpa_supplicant -B -i INTERFACE_NAME -c /tmp/wpa_setup.tmp
    dhcpcd INTERFACE_NAME
    # Check that everything went ok
    ping -c 3 google.com
  6. Erase everything in the disk you will be installing arch in, and perform a secure wipe of the generated free space, so it's later indistinguishable from data written by dm-crypt.

    # Spot your disk (format like sdX)
    lsblk
    # Destroy GPT and MBR
    sgdisk --zap-all /dev/sdX
    # Create a temporary encrypted container
    cryptsetup open --type plain /dev/sdX container --key-file /dev/random
    # Check "/dev/mapper/container" exists in this list:
    fdisk -l
    # Override the container with zeros
    dd if=/dev/zero of=/dev/mapper/container status=progress
    # Close the container
    cryptsetup close container
    reboot
  7. Create partitions (if enough space, create separate partitions for root/home instead, as explained here)

    lsblk
    cgdisk /dev/sdX
    [New] Press Enter
    First Sector: Leave this blank ->press Enter
    Size in sectors: 512MiB ->press Enter
    Hex Code: EF00 press Enter
    Enter new partition name: boot ->press Enter
    [New] Press Enter
    First Sector: Leave this blank ->press Enter
    Size in sectors: Leave this blank ->press Enter
    Hex Code: Leave this blank ->press Enter
    Enter new partition name: Leave this blank ->press Enter
    [Write]
    yes
    [Quit]
    reboot
  8. Setup LVM on LUKS file system

    # Set up file system for the boot aprtition
    mkfs.vfat -F32 /dev/sdX1
    # Make sure you have all they keys needed for your passphrase
    loadkeys es
    # Set up LUKS on the main partition
    cryptsetup -c aes-xts-plain64 -s 512 -h sha512 -i 5000 -y --use-random luksFormat /dev/sdX2
    # Open the container
    cryptsetup open --type luks /dev/sdX2 lvm
    # The decrypted container is now available at /dev/mapper/lvm
    # Create a physical volume on top of the opened LUKS container
    pvcreate /dev/mapper/lvm
    # Create a volume group
    vgcreate ArchLinux /dev/mapper/lvm
    # Create logical volumes (omiting a home lv and only doing 0.5*RAM swap, since hibernation won't be used)
    lvcreate -L 8G ArchLinux -n swap
    lvcreate -l 100%FREE ArchLinux -n root
    # Check the created volumes
    lvdisplay -v /dev/ArchLinux
    # Format filesystem on each lv
    mkfs.ext4 /dev/mapper/ArchLinux-root
    mkswap /dev/mapper/ArchLinux-swap
  9. Install ArchLinux

    # Mount the filesystems
    mount /dev/mapper/ArchLinux-root /mnt
    mkdir /mnt/home
    swapon /dev/mapper/ArchLinux-swap
    mkdir /mnt/boot
    mount /dev/sdX1 /mnt/boot
    # Ensure the time clock is accurate
    timedatectl set-ntp true
    # Uncomment the top 6 mirrors
    cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.backup
    sed -i 's/^#Server/Server/' /etc/pacman.d/mirrorlist.backup
    rankmirrors -n 6 /etc/pacman.d/mirrorlist.backup > /etc/pacman.d/mirrorlist
    # Install ArchLinux base and development files plus some usefull utils
    # For any options that come up just press enter or type y and press enter
    pacstrap -i /mnt base base-devel zsh vim git openssh
    # Generate fstabfile
    genfstab -U -p /mnt >> /mnt/etc/fstab
  10. Configure ArchLinux

    # Chroot into the installed system
    arch-chroot /mnt
    # Uncomment your locale
    nano /etc/locale.gen # ctrl+W to search for en_GB.UTF-8
    # Generate locale
    locale-gen
    # Set it as your language
    echo LANG=en_GB.UTF-8 > /etc/locale.conf
    export LANG=en_GB.UTF-8
    # Set time zone (all of them in: ls /usr/share/zoneinfo/)
    ln -s /usr/share/zoneinfo/Europe/Madrid > /etc/localtime
    # Configure keymap
    echo KEYMAP=es >> /etc/vconsole.conf
    # Set up the clock
    hwclock --systohc --utc
    # Set up the host name
    echo adria > /etc/hostname
    nano /etc/hosts
    # Add a matching entry for your hostname
    127.0.1.1 adria.localdomain adria
    # Enable multilib
    nano /etc/pacman.conf
    # Uncomment:
    #[multilib]
    #Include = /etc/pacman.d/mirrorlist
    # Update pacman
    pacman -Sy
    # Set a password for root
    passwd
    # Set your user
    useradd -m -g users -G wheel,storage,power,audio -s /bin/zsh adria
    passwd adria
    # Add sudo privilegies
    EDITOR=vim visudo
    # Uncomment %wheel ALL=(ALL) ALL
    # In the next line add: Defaults rootpw
    vim /etc/mkinitcpio.conf
    # Add 'ext4' 'nvidia' 'nvidia_modeset' 'nvidia_uvm' 'nvidia_drm' to MODULES (check https://wiki.archlinux.org/index.php/Kernel_mode_setting#Early_KMS_start for an updated list of modules to load)
    # Add 'keymap' 'encrypt' and 'lvm2' before 'filesystem' in HOOKS
    # Save and exit vim
    # Regenerate initrd
    mkinitcpio -p linux
  11. Create boot loder

    # Enable intel microcode updates
    pacman -S intel-ucode
    # Mount EFI variables (ignore if is already mounted)
    mount -t efivarfs efivarfs /sys/firmware/efi/efivars
    # Install boot manager
    bootctl install
    # Get UUID of LUKS partition
    blkid -s UUID -o value /dev/sdX2
    # Configure boot (replace <UUID> with the previous uuid)
    echo title Arch Linux >> /boot/loader/entries/arch.conf
    echo linux /vmlinuz-linux >> /boot/loader/entries/arch.conf
    echo initrd  /intel-ucode.img >> /boot/loader/entries/arch.conf
    echo initrd /initramfs-linux.img >> /boot/loader/entries/arch.conf
    echo options cryptdevice=UUID=<UUID>:luks root=/dev/mapper/ArchLinux-root quiet rw >> /boot/loader/entries/arch.conf
    echo default arch > /boot/loader/loader.conf
    echo timeout 0 >> /boot/loader/loader.conf
    echo editor no >> /boot/loader/loader.conf
    # Install nvidia drivers BEFORE first boot
    pacman -S nvidia
    # Reboot
    exit
    umount -R /mnt
    swapoff -a
    reboot # Remember to remove the usb
  12. Customize it and make it user friendly

    # Disable the annoying 'beep' pc speaker
    modprobe -r pcspkr
    # Install internet interface
    ip link # ignore lo, use the other one in the next command as <ADAPTER>, example: enp3s0
    sudo systemctl enable dhcpcd@<ADAPTER>.service
    reboot
    # Install printer service
    sudo pacman -S cups cups-pdf samba avahi
    systemctl enable org.cups.cupsd.service
    systemctl start org.cups.cupsd.service
    systemctl enable avahi-daemon.service
    systemctl start avahi-daemon.service
    # Config nvidia
    sudo pacman -Syy
    sudo pacman -Syu
    sudo nvidia-xconfig
    # Install desktop manager
    sudo pacman -S gnome gdm gnome-calendar gnome-tweak-tool
    sudo systemctl enable gdm.service
    sudo pacman -S networkmanager
    sudo systemctl disable dhcpcd@<ADAPTER>.service
    sudo systemctl enable NetworkManager
    reboot
    
    # Install Oh My Zsh
    sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
    # Install VLC
    sudo pacman -S vlc
    # Install Firefox
    sudo pacman -S firefox
    # Install docker
    pacman -S docker docker-compose
    systemctl enable docker.service
    sudo usermod -aG docker $USER
    # Install redshift
    pacman -S redshift
    # Go to the config path and paste + customize the settings
    # It's important that you update at least the latitude/longitude coords
    # Path+settings+info: https://wiki.archlinux.org/index.php/Redshift#Manual_setup
    vim <REDSHIFT_CONFIG_PATH>
    # Install trizen
    sudo pacman -S gettext json-c
    git clone https://aur.archlinux.org/trizen.git
    cd trizen && makepkg -sri && cd .. && rm -rf ./trizen
    # Add official sublime text repo
    curl -O https://download.sublimetext.com/sublimehq-pub.gpg
    sudo pacman-key --add sublimehq-pub.gpg && sudo pacman-key --lsign-key 8A8F901A && rm sublimehq-pub.gpg
    echo -e "\n[sublime-text]\nServer = https://download.sublimetext.com/arch/dev/x86_64" | sudo tee -a /etc/pacman.conf
    # Install utils
    sudo pacman -S arc-gtk-theme telegram-desktop pacman-contrib
    trizen -S spotify slack-desktop chrome-gnome-shell-git
    # Make sure every update of the 'systemd-boot' is handled correctly
    trizen -S systemd-boot-pacman-hook

Check out cool terminal themes:

Usefull programs/GNOME extensions:

@adriaPerez
Copy link
Author

adriaPerez commented Sep 13, 2017

Update:

  • An official version for the gtk theme is now available. Use sudo pacman -S arc-gtk-theme instead of pacaur gtk-theme-arc.
  • Stable version for sublime 3 now exists, instead of installing the aur version use the official pacman repo.

@adriaPerez
Copy link
Author

adriaPerez commented Dec 18, 2017

Update:

  • pacaur is no longer mantained. Use trizen instead.

@adriaPerez
Copy link
Author

Update:

  • An official version for the AUR telegram-desktop-bin is now available. Use pacman -S telegram-desktop instead.

@adriaPerez
Copy link
Author

Update:

  • You now need to install pacman-contrib for the archlinux-updates-indicator extension to work.

@adriaPerez
Copy link
Author

Update

  • Added installation of the printer service

@adriaPerez
Copy link
Author

Update:

  • Replaced the recommended gnome extension topicons for topicons-redux since the former is no longer maintained.

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