3

How to Install Arch Linux

 2 years ago
source link: https://www.vultr.com/docs/how-to-install-arch-linux
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
<?xml encoding="utf-8" ??>

Introduction

This guide explains how to install Arch Linux on a Vultr cloud server instance.

Choose an Arch ISO

You can install Arch from the Vultr ISO library or upload a newer version manually.

Option 1: Vultr ISO Library

  1. Navigate to the Vultr customer portal and deploy a new instance.
  2. In the Server Type section, click the ISO Library tab.
  3. Select the most recent Arch version and deploy a server.

Option 2: Manually Upload ISO

  1. Locate the download URL of the most recent Arch ISO.
  2. Go to the Vultr Add ISO page.
  3. Paste the download URL, and click Upload. After a few minutes, your ISO will be available.
  4. Navigate to the Vultr customer portal and deploy a new instance.
  5. In the Server Type section, click the Upload ISO tab.
  6. Select the ISO and deploy a server.

Update the System Clock

Use timedatectl to ensure the system clock is accurate.

    # timedatectl set-ntp true

To check the service status, use timedatectl status.

Disk Partitioning

View the block devices available with the command lsblk.

    # lsblk

Once you identify the disk, use fdisk or parted to partition. This tutorial assumes you chose a standard Vultr server with a single hard drive. Your hard drive will have the name vda.

Create a partition table.

    # parted /dev/vda --mklabel msdos

Add a root partition.

    # parted /dev/vda --mkpart primary 1MiB -8GiB

Add a swap partition.

    # parted /dev/vda --mkpart primary linux-swap -8GiB 100%

Formatting

Create a new file system on the disk, and it’s recommended to add a label to each using -L.

    # mkfs.ext4 -L arch /dev/vda1


    # mkswap -L swap /dev/vda2

Mount your file system.

    # mount /dev/ disk/by-label/arch /mnt

Turn swap device on.

    # swapon /dev/vda2

Install

Use the following command to launch the package installation.

    # pacstrap /mnt base linux linux-firmware base-devel vi nano

You need to install a text editor (we install vi and nano here!) and other essential packages such as base-devel if you’re going to be compiling a lot of code, for instance.

This base install comes with systemd-networkd and that’s what we are going to use in this installation guide. However, you can install other network managers that are easier to use such as NetworkManager.

Before we change root into our newly installed system, generate an fstab file.

    # genfstab -U /mnt >> /mnt/etc/fstab

Now, switch over to the new system.

    # arch-chroot /mnt

System Configuration

Now you have chrooted into the system, set the timezone, and sync the clock.

    # ls /usr/share/zoneinfo/America/

Choose a city from the list, for example: New_York

    # ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime


    # hwclock –systohc

Set the system locale to UTF-8. Visit locale.gen and uncomment en_GB.UTF-8 UTF-8, then set the locale.

    # nano /etc/locale.gen


    # echo 'LANG=en_US.UTF-8' > /etc/locale.conf

Network Configuration

Find the currently active network adaptor.

    # ip addr

This is usually called enp1s0 or similar.

Write the configuration file:

    # nano /etc/systemd/network/enp1s0.network

The content should be as follows:

            [Match]
            Name=enp1s0

            [Network]
            DHCP=yes

This file is case-sensitive. Check Arch Linux Network Configuration for more details on network settings and configurations.

Enable DHCP and DNS resolution to run automatically run at boot.

    # systemctl enable systemd-networkd

    # systemctl enable systemd-resolved

Setup resolv.conf to forward requests to systemd-resolved.

    # ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf

Set the system hostname.

    # echo '<YOUR_HOSTNAME>' > /etc/hostname

Set up your hosts file by replacing your hostname and your static IP address in place of <YOUR_HOSTNAME> and <YOUR_STATIC_IP>.

    # cat <<EOF > /etc/hosts
    > <YOUR_STATIC_IP>   localhost
    > ::1                localhost
    > <YOUR_STATIC_IP>   <YOUR_HOSTNAME>.localdomain  <YOUR_HOSTNAME>
    > EOF

Run the command ip addr again to find your static IP.

Install the Bootloader

Install grub, and write a configuration file.

    # pacman -S grub
    # grub-install --target=i386-pc /dev/vda

Note that the argument is the disk itself and not the system partition.

    # grub-mkconfig -o /boot/grub/grub.cfg

Set a Root Password

Set the root password.

    # passwd

Reboot

Exit the chroot, and reboot the system.

    # exit

    # systemctl poweroff

Go to the Vultr customer portal, remove the ISO, and then restart the server.

Reconnect the VNC console.

Create User

Now the system has booted successfully. Login as root with the password you just set up:

Install sudo.

    # pacman -S sudo

Allow users that you add in group wheel to use sudo.

    # cp /etc/sudoers /etc/sudoers.new
    # sed 's/# %wheel ALL=(ALL) ALL/%wheel ALL=(ALL) ALL/' -i /etc/sudoers.new
    # visudo -c -f /etc/sudoers.new && mv /etc/sudoers.new /etc/sudoers

Create a user account.

    # useradd --create-home –-groups wheel <yourusername>

Set the user’s password.

    # passwd <yourusername>

Log out as root and log in with the newly created user.

    # exit

Configure Time Synchronization

Download the ntp package

    # pacman -S ntp

    # systemctl enable --now ntpd

Configure SSH

Install SSH.

    # pacman -Sy openssh

Edit the configuration file to enable a port. Usually, this is port 22.

    # sed 's/#Port 22/Port 22/' -i /etc/ssh/sshd_config

Enable SSH.

    # systemctl enable --now sshd

You should now be able to log in via SSH.

At this point, you can ssh to your newly installed server. However, by default, sshd does not allow you to log in as root.

Upgrading Arch Linux

Arch Linux is a rolling release distribution. That means you can update your system packages anytime. To upgrade all packages at once, use the following command:

    # pacman -Syu

After upgrading, you may be prompted with messages requesting further actions.

Conclusion

For more information, check the Arch Linux website

Want to contribute?

You could earn up to $600 by adding new articles


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK