How To Automate Your Arch Linux Installation With Archinstall Script

How To Automate Your Arch Linux Installation With Archinstall Script

how-to-install-arch-linux-with-archinstall-script

Hi all, welcome to MusaBase!. In this article, I'll guide you through installing Arch Linux with the archinstall script and make your Arch Linux installation easier. Without further ado, let's get started.









Step 1: Partitioning & Formatting Storage Disk

1.1: Boot into the Arch Linux Live Installation Environment

  • Reboot your PC.
  • Press F9, F10, F11, F12, Esc, or Del, (depending on your motherboard) to enter BIOS/UEFI settings.
  • Locate and disable Secure Boot.
  • Save changes and exit.
  • When prompted, press the key to select a boot device (e.g., F9) depending on your motherboard.
  • Choose your USB drive as the boot device.
  • You should see the Arch Linux boot menu, similar to this one:

  • Press Enter on Arch Linux install medium (x86_64, UEFI) .
  • After a few seconds, you will be in the Arch Linux live installation environment.

1.2: Partitioning with cfdisk

Next, we need to partition the hard disk to create a boot and root parititon. You can use fdisk, gparted or cfdisk. In this guide, I'll use cfdisk because it's convenient and provides an easy-to-use text-based "graphical interface".

  • If you have more than one drive connected, list all storage devices with:
lsblk
  • Now run the following command to open the cfdisk interface.
  • Select gpt as the partition table and press Enter.
cfdisk /dev/sdb

1.2.1: Create the Boot Parititon

  • In the cfdisk interface, select Free Space and press Enter.
  • Allocate around 512 MB to 1 GB depending on your needs. (.e.g., 1G or 512M) with capital G for Gigabytes and M for Megabytes
  • Next on the bottom options menu select [ Type ] and press Enter to open Partition Type/Filesystem menu.
  • Choose EFI System and press Enter.
  • Setting the boot partition table to EFI is essential because without it the firmware won't be able to locate and execute the bootloader.

1.2.2: Create the Root Partiton

  • Next, select Free Space again, then choose [ New ] from the bottom menu and press Enter.
  • Allocate the desired size for your root partition. If you plan to create a separate /home partition, allocate accordingly. In this example, we'll give 15GB to the root partition reserve space for swap partition.

1.2.3: Create a Swap Partition (Optional)

This step is optional, if you want to create a Swap Partition for your system then follow this or skip to next step.

  • Select Free Space then choose [ New ] and press Enter.
  • Allocate around 4GB (or as needed) and press Enter.
  • Next, with the Swap Partition highlighted, select [ Type ] and choose Linux swap partition type from the menu and press Enter.

1.2.4: Write the Partition Changes

This step is crucial, without writing the changes, your new partitions won't be created.

  • Navigate to [ Write ] in the bottom options menu and press Enter.
  • Type yes when prompted and press Enter.
  • Finall, select [ Quit ] to exit cfdisk.

1.3: Format the Parititons

Now that all required partitions have been created, let's format them before installing Arch Linux. First, run lsblk command to list all attached storage devices and their partitions. It's an easy way to identify partitions avoidformatting the wrong one:

Partitioned Hard-drive sdb

1.3.1: Format the Boot Partition

  • Run the following command:
mkfs.vfat -F32 /dev/sdb1

1.3.2: Format the Root Partition

  • Run the following command:
mkfs.ext4 /dev/sdb2
format the root partition

1.3.3: Make Swap Area (Optional if you created a swap partition)
  • If you created a swap partition, run the following command (replace sdb3 with your swap partition name):
mkswap /dev/sdb3
making a swap area



Step 2: Updating & Synchronizing the Live Environment (Optional)

Before running the arhcinstall script, I need to cover a few preliminary steps to ensure it doesn't fail. You can skip ahead to the installation section if you wish, but if you encounter any errors, return to this step and try again.

2.1: Keys Activation

  • Run these two commands consecutively:
pacman-key --init
pacman-key --populate archlinux

2.1: Synchronize and Update the Local Package Database

  • Run the following command:
pacman -Sy

2.2: Update the Keyring

  • Run the following command:
pacman -S archlinux-keyring

2.3: Install or Update the archinstall Script

  • Run the following command:
pacman -S archinstall




Step 3: Install Arch Linux with archinstall Script

3.1: Run the archinstall Script

  • Finally, run the following command to start the installer:
archinstall

3.2: Mounting Partitions

  • Navigate to Disk Configuration and press Enter.
  • Select Partition press Enter.
  • Select Manual Partitioning and press Enter.
  • Choose the disk you partitioned for Arch Linux and press Enter, for me it's /dev/sdb.
choose-disk

3.2.1: Mount the Boot Partition

  • Select the boot partition created in Step 1 (Efi System) and press Enter.
  • Select Assign mountpoint and press Enter.
  • When prompted, enter the mountpoint and press Enter:
/boot

3.2.2: Mount the Root Partition

  • Select the root partition created in Step 1 (formatted as ext4) and press Enter.
  • Select Assign mountpoint and press Enter.
  • When prompted, enter the mountpouint and press Enter:
/

3.2.3: Confirm the Partition Layout & Exit

  • If you created additional partitions (e.g., /home), mount them now in the same way.
  • After moutning every partition, select Confirm and exit and press Enter.
  • Select Back and press Enter to return to the archinstall main menu.
confirming-mounted-partition-points

3.3: Disable Swap in archinstall

  • Even if you didn't create a swap partition in Step 1, you still need to disable this options. Leaving it enabled can cuase installation errors.
  • From the archinstall main menu, select Swap and press Enter.
  • On the prompted options select no and press Enter.

3.4: Select a Bootloader

  • Select Bootloader and press Enter.
  • Choose GRUB and press Enter.

3.5: Set the Hostname

  • Select Hostname and press Enter.
  • Replace the default hostname (archlinux) with your desired hostname (e.g., MusaBase) and press Enter.

3.6: Set the Root Password

  • Select Root password and press Enter.
  • Enter a strong password for the root account, then re-enter it to confirm.

3.7: Create a User Account

3.7.1: Add a User

  • Select User account and press Enter.
  • Choose Add a user and press Enter.
  • When prompted, type your username (e.g., john) and press Enter.

3.7.2: Set User's Password

  • Enter a password for the new user and re-enter it to confirm.

  • When asked "if you want to make this user a superuser (sudo) ?", i am choosing yes.
  • Choose yes or no according to your needs and press Enter.

3.7.3: Confirm & Exit

  • Optionally create additional users. When finished, select Confirm and exit and press Enter.

3.8: Choose a Profile

  • Select Profile and press Enter and then choose Type.

3.8.1: Desktop Environment

  • Choose Desktop and press Enter.
  • I'm going with KDE Plasma as my Desktop Environmentbut you can choose your preferred desktop environment and press Enter.

3.8.2: Choose Graphics Drivers

  • Select Graphics driver and press Enter.
  • I'm going with All open-source but you can choose only NVIDIA or AMD or Intel depending on your needs and press Enter.

3.8.3: Choose Greeter or Display Manager

  • Next, select Greeter and press Enter.
  • Again choose your preffered Greeter such as Lightdm or sddm and press Enter. I'm choosing sddm

  • All configuration for Profile would look similar to this:
profile-configuration-in-archinstall

3.9: Configure Audio

  • Select Audio and press Enter.
  • Choose an audio server. I'm going with pulseaudio but you can pick the other option if you prefer.

3.10: Configure the Network

  • Select Network configuration and press Enter.
  • Choose NetworkManager. If you select another tool, ensure it's configured for internet access in the installed system.

3.11: Install Arch Linux

I've left all other settings at their defaults such as the kernel and ecryption options beacuse i dont need them now. I'm not installing extra pacakges now, I'll add them after installation. Let's move on to the installation process:

  • Select Install and press Enter.
  • When prompted to confirm your configuration, chooseyes and press Enter. The installation will then begin.

3.12: Reboot

  • Once the installation finishes, you will be prompted to reboot.
  • Reboot now to begin the next phase:
rebooting-system-after-installation-finished



Step 4: Boot into the Freshly Installed Arch Linux System

After rebooting, you will see the GRUB menu with a few options:

grub-bootloader

4.1: Login with User Account

  • Select Arch Linux and press Enter.
  • After a few seconds, you will see the SDDM graphical interface with your local User's account which you created during the installation.
  • At the prompt, enter the password for your user and press Enter.
sddm-login-screen

  • After a few seconds, you will inside your system.

4.2: Grant Sudo Privileges to Your Local User (Optional)

Note: Follow this step if you didn't add your user as Super-User or Sudo and if you didn't create your user with sudo then follow this step.

4.2.1: Switch to Super-User (root)

  • Open terminal by pressing CTRL + ALT + T.
  • Run this command to switch user to the suerp-user account. When prompted, enter the root password you set during installation:
su

4.2.2: Install the Nano Text Editor

  • Next, run the following command to install nano, a command line text editor:
pacman -S nano

4.2.3: Enable sudo for the Wheel Group

  • Now, we need to edit the sudoers file (visudo)to grant sudo rights to members of the wheel group.
  • Run:
EDITOR=nano visudo
editor-nano-visudo
  • It will open up sudoers file in nano:
visudo-file
  • Press the Down Key () to navigate to downward in the file.
  • Navigate all the way to bottom and look for line contatining:
# %wheel ALL=(ALL:ALL) ALL
  • Uncomment the line by deleting # from the start of the line.
  • Next, press Ctrl + O to save changes then press Enter to apply the changes, then press Ctrl + X to exit the file.

4.2.4: Add your User to the Wheel Group

  • Run the following command:
usermod -aG wheel musabase
adding-user-to-wheel-group

4.2.5: Change back to Local User

Now, that your user has sudo privileges, switch back from the super-user to your local account. It's best practice to perform administrative tasks as a normal user with sudo rather than as root.

  • Run the following command:
su username

4.3: System Update with Local User

  • Now that your user has sudo privileges, run a system update using sudo.
  • Run the following command (you will be prompted for your user's password):
sudo pacman -Syu

4.4: Install Additional Packages

  • Run the following commad:
sudo pacman -S kitty firefox kate curl wget git

4.5: Configure the DNS Server (Optional)

Perform this step only if you encounter network issues while downloading or installing packages (e.g., package downloads aborting).

  • In the terminal, run the following command:
sudo nano /etc/resolv.conf
  • It will open /etc/resolv.conf file in nano:
  • In the /etc/resolv.conf file, add the following line:
nameserver 8.8.8.8
nameserver 1.1.1.1
nameserver-added
  • Next, press Ctrl + O to save chagnes then press Enter to apply the saves and then press Ctrl + X to exit the file.



Afterwards

Now that fully Configured Arch Linux installed, you're ready to go. You can take your Arch Linux system to next level by further tweaking and customizing. Just don't forget to run the sudo pacman -Syu from time to time.




🎉 Congratulations! your Arch Linux system with archinstall script is now up and running!

If you hit any snags, drop a comment below, I'm here to help.
If this guide helped you, subscribe to our newsletter for more step-by-step tutorials.
1O1 out, I'll see you in the next one!




Load comments