Computer >> Computer tutorials >  >> System >> Linux

How to Install Arch Linux

Arch Linux is a powerhouse Linux distribution that offers a rolling release, so all of your software is always up to date. But with that power comes a bit of operating system installation complexity. In other words, installing Arch Linux isn’t easy … but not impossible. Here you will learn how to install Arch Linux as a virtual machine (using VirtualBox). The process is the same if you’re installing on bare metal (the only difference being the need to create a bootable media, such as a USB drive or CD/DVD for the bare metal installation). Taking your first steps using a virtual machine makes the process of learning a bit easier.

This tutorial will not detail the steps for creating the VirtualBox virtual machine. To learn how that process is completed, read Run Ubuntu Within Windows Using VirtualBox. The steps for creating a virtual machine in VirtualBox are similar, regardless of hosting platform.

Download the ISO

The first thing you must do is download the latest Arch Linux ISO file. Point your browser to the Arch Linux Download page and download the latest image to your hard drive. With that ISO image, you’ll create your virtual machine in the standard fashion. Once you’ve created the virtual machine, boot Arch Linux. You will eventually find yourself faced with a bash prompt (where you can begin running the necessary commands).

Partition the Hard Drive

How to Install Arch Linux
  1. The first thing to be done from the command prompt is partitioning the drive. Issue the command:

    fdisk /dev/sda
  2. Next, type n, and hit Enter.

  3. Now type p, and hit Enter.

  4. You will then want to keep the default partition number (1) by hitting Enter.

  5. Do the same when prompted to select the First sector and for the Last sector (just hit Enter).

  6. Finally, type w to write the changes to the disk.

Formatting the Partition

  1. Now we have to format the newly created partition. To do this, issue the command:

    mkfs.ext4 /dev/sda1
  2. Mount that newly formatted partition with the command:

    mount /dev/sda1 /mnt

Installation

How to Install Arch Linux

And now we install base Arch Linux package. This will install the bare minimum needed to run the system (such as GNU BASH shell, data compression tool, file system utilities, C library, compression tools, Linux kernels and modules, library packages, system utilities, USB devices utilities, vi text editor, and more) and is accomplished with the command:

pacstrap /mnt base base-devel

Configuring the System

Next, we need to configure the system.

  1. The first step in this process is to generate an /etc/fstab file, which defines how block device and remote file systems are mounted. Do this with the command:

    genfstab -U /mnt >> /mnt/etc/fstab
  2. Now we need to change the root directory for the currently running process with the command:

    arch-chroot /mnt

Setting Time Zone, Hardware Clock, and Locale

How to Install Arch Linux
  1. We need to set both the timezone and the locale for the installation. This is done with the following commands:

    ln -sf /usr/share/// /etc/localtime
  2. Where ZONEINFO is the Country, REGION is the State, and CITY is the city. For example, if you are in Louisville, Kentucky, your command would be:

    ln -sf /usr/share/America/Kentucky/Louisville /etc/localtime
  3. Set the hardware clock with the command:

    hwclock --systohc --utc
  4. And now we set the locale, which defines the language and local settings. To do this, issue the command:

    vi /etc/locale.gen
  5. At this point, you are using the vi text editor, which is far from user-friendly. What you need to do is first hit the i key to enter insert mode. Next, scroll through and uncomment (remove the “#” symbol from the beginning of a line) the locale that suits your location/need.

    By default United States English is uncommented. If you are not located in America, you’ll want to comment that out and uncomment the best location.

  6. Once you’ve taken care of this change, hit the Escape key, followed by wq and Enter. This will save and close the file. Generate the necessary locale file with the commands:

    locale-gen
    echo LANG=en_US.UTF-8 > /etc/locale.conf
    export LANG=en_US.UTF-8

    Substitute your locale for en_US (if necessary).

Set the Hostname and Install the Bootloader

How to Install Arch Linux
  1. In order for your Arch Linux distribution to boot, you must install a bootloader. Before we do that, let’s set the hostname for the system (choose the hostname that suits your needs). The command for this is:

    echo HOSTNAME > /etc/hostname

    Where HOSTNAME is the name you’ve chosen.

  2. Install the bootloader with the following commands:

    pacman -Sy grub
    grub-install /dev/sda
    grub-mkconfig -o /boot/grub/grub.cfg
  3. Finally, set a root password with the command:

    passwd

    At this point, you have a base installation of Arch Linux. If you reboot the system, you’ll find yourself at a command prompt, where you can log in as the root user.

Configure Networking

How to Install Arch Linux

  1. Before continuing on, you’ll need to configure networking. If you attempt to ping something from the command line, it becomes all too clear that networking isn’t functioning yet. The first thing to be done is to find out the name of our networking device. That can be found with the command:

    ip link
  2. You’ll see a listing for lo (loopback) and one for a standard network interface. To configure the network interface, issue the command:

    vi /etc/systemd/network/DEVICE_NAME.network

    Where DEVICE_NAME is the name of your networking device.

  3. In this empty file, paste the following:

    [Match]
    name=en*
    [Network]
    DHCP=yes

    Save and close that file.

  4. Start and enable networking with the commands:

    systemctl restart systemd-networkd
    systemctl enable systemd-networkd
  5. Next, create the necessary DNS entries with the command:

    vi /etc/resolv.conf
  6. In that file, add the following:

    nameserver 8.8.8.8
    nameserver 8.8.4.4
  7. Save and close that file.

    Networking should now be functioning.

Install a Desktop Environment

  1. Let’s install the GNOME desktop environment. To do this, issue the commands:

    pacman -S xorg xorg-server
    pacman -S gnome gnome-extra

    During the above commands, hit Enter to select the defaults for all options.

  2. Finally, start and enable the display manager with the commands:

    systemctl enable gdm.service
    systemctl start gdm.service
  3. You should now be able to log into GNOME and enjoy your Arch Linux installation.