How to Install Arch Linux

Bill - 27 January, 2021
Reading time 4 mins

I have an old Laptop, it has 4GB of RAM and low spec CPU. So I decided to put Arch Linux in it. I was a bit struggle with the installation steps (I'm using Manjaro though :D) but I successfully installed it.

The installation steps is actually explained very well on arch linux official website. But in this post, I just want to share what I've done and maybe it'll be usefull for you in case you also want to try to install Arch Linux.

Let's get started

First, you need to download the ISO file from the Download page. I was using USB flash drive, please refer to Pre-installation section for more details. Be sure to disable Secure Boot on your machine, because Arch Linux installation images do not support Secure Boot.

Installation

I assume you've already logged in on the live environment. You need to connect to the internet to be able to install the packages, check set up a network connection in the live environment for the details.

For example you might want to use iwctl to connect to your WiFi network.

# ip addr                                        <== check your WiFi interface name
# iwctl
    [iwd]# station wlan0 scan                    <== `wlan0` is an example of WiFi interface name
    [iwd]# station wlan0 connect SSID_NAME
    [iwd]# exit
# ping archlinux.org

Through the virtual console, set up the system time and date by typing timedatectl set-ntp true. Then we need to set up our Partitions. I'm using LVM in this example, so feel free to choose your own Partition type.

  • Partition the disks

    Select the block device, in this case X is an example like /dev/sdb, /dev/sdc, it might be different on your system.

    # lsblk              <== to identify a block device
    
    # fdisk /dev/sdX     <== don't forget to change the X
    n (to add a new partition)
    p (for primary partition)
    1 (default partition number)
    (accept default start)
    (accept default end)
    t (to change partition type)
    8e (for LVM partition when using MBR)
    i (to verify)
    w (save and quit)
    

    Alternatively, you can use cfdisk, for example cfdisk /dev/sdX, then select gpt label. Please remember, if you have an EFI System partition, you'll need to install efibootmgr for your machine, we'll do it later. To verify if your machine support EFI System or not, please run: ls /sys/firmware/efi/efivars, if there's an output from that command, you're absolutely need an EFI System partition, if not, then you need a BIOS Boot partition, create 512M size partition with one of those type.

  • Create LVM partition

    After you finished set up the partition, we need to create our LVM disk layout. I have 500GB of storage available, I'll use all of it as a single boot (Linux only). Run the following command step by step. (Again, don't forget to change the X)

    # pvcreate /dev/sdX1               <== create physical volumes
    
    # vgcreate vg1 /dev/sdX1           <== create volume groups (vg1 is my group name, you can change it)
    
    == Create logical volumes ==
    # lvcreate -L 100G -n root vg1     <== 100GB of /root system
    # lvcreate -L 4G -n swap vg1       <== 4GB of swap
    # lvcreate -l 100%FREE -n home vg1 <== the rest of available storage after allocation as /home partition
    
    == Format the partitions ==
    # mkfs.ext4 /dev/vg1/root
    # mkfs.ext4 /dev/vg1/home
    # mkswap /dev/vg1/swap
    # swapon /dev/vg1/swap
    
    == Mount the file systems ==
    # mount /dev/vg1/root /mnt
    # mkdir /mnt/home
    # mount /dev/vg1/home /mnt/home
    

    If you have EFI System partition, please format the partition with the following command:

    # mkfs.fat -F32 /dev/sdX1              <==  change `1` depends on your `EFI System` partition number
    # mkdir /mnt/efi
    # mount /dev/sdX1 /mnt/efi
    
  • Install packages

    We're ready to install our essential packages. Since we're still in the virtual console of the live boot environment, pacstrap is the only tool we have to install packages. Run the following command and wait until it finished.

    # pacstrap /mnt base base-devel vi lvm2 dhclient dhcp dhcpcd linux linux-firmware mkinitcpio git iwd iw wpa_supplicant dialog netctl ifplugd nano networkmanager sudo
    
  • Configure the system

    We're almost finished, next step is go through the following steps and you'll safe.

    # genfstab -U /mnt >> /mnt/etc/fstab
    
    # arch-chroot /mnt /bin/bash
    
    # locale-gen
    
    # vi /etc/locale.gen
    LANG=en_US.UTF-8      <== uncomment this
    
    # tzselect
    # ln -s /usr/share/zoneinfo/Zone/SubZone /etc/localtime   <== change your zone
    
    # hwclock --systohc --utc
    
    # vi /etc/mkinitcpio.conf
    HOOKS="...lvm2 filesystems..."    <== put lvm2 inside HOOKS
    
    # mkinitcpio -p linux
    
    # vi etc/hostname
    
    # vi /etc/hosts
    127.0.0.1       localhost
    ::1             localhost
    127.0.1.1       your_hostname.localdomain       your_hostname
    
    # useradd -G wheel,audio,video -m your_username
    # passwd your_username
    
    # passwd     <== to create `root` password
    
    # EDITOR=vi visudo
    %wheel ALL=(ALL) ALL     <== uncomment this
    
    # pacman -S grub                <== Only for BIOS Boot
    # pacman -S grub efibootmgr     <== Only for EFI System
    
    # grub-install --target=i386-pc /dev/sdX   <== change the X, Only for BIOS Boot
    # grub-install --target=x86_64-efi --efi-directory=/efi/ --bootloader-id=arch_grub     <== Only if you use efi boot mode
    
    # grub-mkconfig -o /boot/grub/grub.cfg
    
    # systemctl enable dhcpcd
    # systemctl enable NetworkManager
    
    # exit (from `chroot`)
    
    # reboot
    

Finally, we're successully installed Arch Linux. The next step is choose your Graphical user interface maybe like GNOME, KDE, etc. If you have problems with the installation steps, feel free to hit me up or refer to Arch Linux installation guide.

# Linux - Blog posts