Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
ArchLinux Installation Guide

Arch Install Guide

Foundation

  • Partition a drive on Windows and delete it so that it's free space. Note the size since we'll need it later.

  • Boot into Arch

  • Run fdisk -l to see the partitions.

  • Run parted.

  • Run print free to see the free space and note the Start and End points.

  • Create the following partitions, keeping in mind to replace the start and end values with the appropriate numbers:

    • Boot: No need for this since we are dual booting and will use the Windows EFI System Partition (ESP) directly.
    • /root: mkpart primary ext4 {Start}GiB {Start+20}GiB
    • Swap Space: mkpart primary linux-swap {Start+20}GiB {Start+21}GiB
    • /home: mkpart primary ext4 {Start+21}GiB {End}GiB
  • Check your newly created partitions with fdisk -l and note down their names (e.g. /dev/sda8).

    • Mine are /dev/sda8 for root, /dev/sda9 for swap and /dev/sda10 for home.
  • Time to create the filesystems. You have only created the parititions, you still need to tell Linux how to lay out your filesystem:

    • mkfs.ext4 /dev/sda8
    • mkswap /dev/sda9
    • mkfs.ext4 /dev/sda10
    • Turn on the swap with swapon /dev/sda9
  • Mount the root directory mount /dev/sda8 /mnt

  • Important Mount the ESP:

    • mkdir -p /mnt/boot/
    • With fdisk -l get the device name with type EFI System. Mine is /dev/sda1 (it's usually the first device/sector).
    • mount /dev/sda1 /mnt/boot
  • Mount the home directory:

    • mkdir -p /mnt/home
    • mount /dev/sda10 /mnt/home
  • Set up Wifi to download all the needed packages. We'll use wpa_supplicant.

    • Create a temporary config: /etc/wpa_supplicant/temp.conf
    • Add a network config to it. You may want to google for the config that makes sense for your network. Check notes.
    • Get the network interface with ifconfig. My case was wlp2s0
    • Run wpa_supplicant -B -i wlp2s0 -c /etc/wpa_supplicant/temp.conf.
    • Get an IP address with dhcpcd wlp2s0.
    • Check connectivity with ping google.com
  • Set up pacman GPG keys so that the packages download without issues:

    • pacman-key --init && pacman-key --populate archlinux
    • Edit /etc/pacman.d/gnupg/gpg.conf and change the keyserver line to keyserver hkp://pgp.mit.edu:11371.
  • Install the base system with pacstrap -i /mnt base base-devel. Choose the defaults and hit Y to proceed with installation when prompted. Go grab a coffee while it downloads.

  • Generate the fstab file with genfstab -U /mnt > /mnt/etc/fstab

  • Go to your drive arch-chroot /mnt /bin/bash.

  • IMPORTANT Pick a language else your system may not bootup:

    • Open /etc/locale.gen (nano is a good choice).
    • Uncomment en_US.UTF-8 UTF-8 and en_US ISO-8859-1.
    • Save and exit
    • Run locale-gen.
    • Save the env variable: echo LANG=en_US.UTF-8 > /etc/locale.conf
  • Set the timezone.

    • Mine is EST: `ln -sf /usr/share/zoneinfo/EST5EDT /etc/localtime
    • Read the system time in UTC but return in local time: hwclock --systohc --utc
  • Let's setup our bootloader. I highly recommend reading this first.

    • Create an initial environment to boot in: mkinitcpio -p linux
    • Get grub since it works for both MBR and EFI boot systems: pacman -S grub efibootmgr os-prober
    • Run grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=grub
    • Create a grub config file: grub-mkconfig -o /boot/grub/grub.cfg. You can ignore any warnings that might come up.
  • Install a Boot Manager (systemd-boot) which will take care of the task of starting bootloaders such as GRUB as well as make it super easy to discover and generate the boot menu.

    • Run bootctl --path=/boot install to install systemd-boot. If it gives an error that loader.conf already exists, then delete the file at /boot/loader/loader.conf.
    • Configure the loader.conf by setting the following values:
      default  arch
      timeout  5
      editor   0
      
    • If you don't see a boot menu on startup, see the Notes.
  • Time to add a hostname:

    • echo <whatever you like> > /etc/hostname
    • Edit the file /etc/hosts and in the line with 127.0.0.1 append the hostname after localhost.
    • Install packages to configure Wifi on reboot: pacman -S dialog iw wpa_supplicant
  • Set the root password with passwd. We initially run as root to make sure things worked as expected.

  • Exit chroot and unmount filesystems: umount -R /mnt

  • Reboot!

NOTE In case Windows does not show in GRUB, you can manually edit the GRUB entry by creating a /boot/grub/custom.cfg custom configuration. See the notes for more details.

If you encounter an error that a PARTUUID could not be found, then do the following:

  1. Get the PARTUUID of your /root partition blkid -s PARTUUID -o value /dev/sdxY. Write the PARTUUDI down as you will need it later.
  2. Open the arch.conf with nano /boot/loader/entries/arch.conf.
  3. Replace the existing PARTUUID with the one you wrote down on the line that says: options root=PARTUUID=the-id-you-just-copied rw.

Notes

  • We create different partitions for root and home since that means our user data is separated from the system files, making it easier to organize, recover and even change OSes without affecting our data (which crappy Ubuntu does not do).

  • Wifi Interface Config for GTwifi

    ctrl_interface=/var/run/wpa_supplicant
    network={
        ssid="GTwifi"
        key_mgmt=WPA-EAP
        eap=PEAP
        identity="vagrawal38"
        password="whatever-the-password-is"
        ca_cert="/etc/ssl/certs/AddTrust_External_Root.pem"
        phase1="peaplabel=0"
    }
    
  • The fstab (pronounced "F S Tab") file tells your system what your filesystems are and what they should be called.

  • I have a weird issue where when I boot my machine I need to press the Spacebar in order to see the boot menu. From my research this seems to be a firmware issue in my laptop. Need to investigate more.

  • The Arch Wiki has a great page on how to create a GRUB entry for Windows. Personally tried it and it worked beautifully. You most probably want to look at the section Windows installed in UEFI-GPT Mode menu entry. Placing a copy of my GRUB entry here for reference:

    grub-probe --target=hints_string /boot/EFI/Microsoft/Boot/bootmgfw.efi  # to get $hints_string
    grub-probe --target=fs_uuid /boot/EFI/Microsoft/Boot/bootmgfw.efi  # to get $fs_uuid
    
    if [ "${grub_platform}" == "efi" ]; then
        menuentry "Microsoft Windows Vista/7/8/8.1 UEFI-GPT" {
            insmod part_gpt
            insmod fat
            insmod search_fs_uuid
            insmod chain
            search --fs-uuid --set=root $hints_string $fs_uuid
            chainloader /EFI/Microsoft/Boot/bootmgfw.efi
        }
    fi

Desktop Environment

  • We're in root so let's create a user useradd -m -G wheel -s /bin/bash <username>
  • Set the user password passwd <username>
  • Install sudo so we can run with elevated privileges pacman -S sudo
  • Open up the sudoers list nano /etc/sudoers and uncomment the line near the end that allows the wheel group to use sudo.
  • Login as user su - <username>
  • Update all packages in preparation sudo pacman -Syu
  • Install XOrg Server sudo pacman -S xorg-server xorg-apps
  • Install your environment and display manager sudo pacman -S gnome gdm
  • Logout of your user account into root with logout and run systemctl enable gdm.service and systemctl start gdm.service
  • Login to your account and open a terminal.
  • Install a nicer terminal sudo pacman -S terminator
  • Install the gnome extras sudo pacman -S gnome-extra
  • Install the essentials sudo pacman -S firefox vlc inkscape gimp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment