---
title: "How to Install ArchLinux on a Virtual Machine"
description: "ArchLinux is a popular Linux distribution, but its installation process can be challenging for beginners. This tutorial provides a step-by-step guide to installing ArchLinux on a virtual machine, covering pre-installation, installation, and post-installation steps."
pubDate: "2018-06-20"
categories: ["Linux", "Tutorial", "Arch Linux"]
---

## Preface

Many people mention that their first reaction to ArchLinux is the difficulty of installation. There are several reasons for this difficulty, which we will address next.

- No graphic user interface: `ArchLinux` only provides a minimal environment. All of the install operations should be completed in the command line. This is the most difficult to overcome for many people who do not have experience in command line operations. Many Linux distributions can be popular because they provide user-friendly and streamlined installation processes. This has helped many people solve the first step in learning `Linux`: Installing a `Linux`.
- Insufficient prior knowledge and lack the ability to find and solve problems: No exposure to knowledge that is important to installing operating systems, such as system booting, configuration file editing, and command-line operations. Once the results of their operation do not match the tutorial, they do not know how to solve the problem.
- Lack of proper tutorials: The best and most complete tutorial for installing `ArchLinux` is the official [Installation guide](https://wiki.archlinux.org/title/Installation_guide) and [Wiki](https://wiki.archlinux.org/). Since the official Wiki is written in a way similar to the documentation, there is no chronological step-by-step installation process that we are used to, causing difficulties for people who are unfamiliar with this type of writing in reading and using. Other tutorials are often outdated or do not take into account the reader’s understanding of `Linux`, ignoring some of the newcomers who are prone to making mistakes.

**This tutorial is designed to be consistent with the existing official [Wiki](https://wiki.archlinux.org/) and includes links that are suitable for beginners to learn. I hope that anyone who has read this tutorial will be able to improve their ability to learn existing and future new official Wiki content.**

The advantages of `ArchLinux` or `Linux` are not mentioned here. I betlieve that people who will review this tutorial must have already understood it. And you can get a lot from this process.

### Precautions

Be sure to read each instruction in the tutorial carefully. Most of the installation failures were caused by not reading the tutorial carefully, missing or misdirecting instructions. Be sure to understand the contents of the tutorial, not just enter the command without understanding the description.

## Installation Tutorial

### Pre-installation

The installation media and their GnuPG signatures can be acquired from the [Download](https://archlinux.org/download/) page.

Choose a mirror site locates in your region, then download the `iso` image file looks like `archlinux-**-x86_64.iso`.

#### Verify Signature

It is recommended to verify the image signature before use, especially when downloading from an _HTTP mirror_, where downloads are generally prone to be intercepted to serve malicious images.

If you are using a `windows` operating system with `7-zip` installed, right-click on the downloaded `iso` image file. Choose `CRC SHA`>`SHA1`, then you can see the signature of the image. If the signature does not match what is displayed on the [Download](https://archlinux.org/download/) page, please re-download the image file from the correct URL.

#### Create a Virtual Machine

Before creating the virtual machine, enter the `BIOS`. If the CPU of your physical machine is a Intel CPU, enable `Intel VT`. Or the CPU is an AMD CPU, enable `AMD-V`.

Reboot the system and open VMware Workstation. Click on `Create a New Virtual Machine`.

- Select `I will install the operating system later.`
- In the `Guest operating system` option, choose `Linux`. Select the version `Other Linux 5.x or later kernel 64-bit`
- Resize the `Maximum disk size` and choose `Store virtual disk as a single file`.
- Click on `Customize Hardware...`. Enter the appropriate value of memory and processors for this virtual machine.
- Change the `New CD/DVD (IDE)` connection. Choose `Use ISO image file:`. Click on `Browse...` to open the path of the image file and select it.
- In `Virtualization engine`, check the three boxes `Virtualize Intel VT-x/EPT or AMD-V/RVI`, `Virtualize CPU performance counters` and `Virtualize IOMMU (IO memory management unit)`.
- If you want to install a user graphic interface after installing `ArchLinux`, it is recommended to check the box `Accelerate 3D graphics` in `Display`-`3D graphics`.

#### Boot the Live Environment

1. Click on `Power on this virtual machine`. After startup, you will see the following interface.

   ![ArchLinux boot interface](https://img.eigenigma.io/how-to-install-archlinux-on-a-virtual-machine/boot-interface.png)

   If you do not see this interface, please check the integrity of the `iso` image file.

   Select the first option `Boot Arch Linux (x86_64)` and press `Enter` to enter the installation environment.

2. At this point, ArchLinux starts loading and you will see the screen showing the following.

![ArchLinux boot loading screen](https://img.eigenigma.io/how-to-install-archlinux-on-a-virtual-machine/boot-loading.png)

After the loading is complete, you will enter an interface with a command line.

![ArchLinux command line interface after boot](https://img.eigenigma.io/how-to-install-archlinux-on-a-virtual-machine/command-line-interface.png)

If `FAIL` or other error message appears and it cannot be started, please search for the error message to get the solution.

If you are unfamiliar with the common operations of the `Linux` command line, please learn some of the common shortcuts or commands below.

> `Tab`: Command-line auto-completion. Type the first few characters of the command or file name and press `Tab`, it will automatically complete the command or display all commands that match the characters you type.
> `↑` or `Ctrl`+`p`: Display the previous command.
> `↓` or `Ctrl`+`n`: Display the next command.
> `Ctrl`+`c`: Terminate the currently executing command.

For other commonly used shortcuts, you can view [10 Linux Shortcuts You Can’t Live Without](https://www.marksanborn.net/linux/10-linux-shortcuts-you-cant-live-without/).

#### Set the Keyboard Layout (Optional)

**If your current keyboard layout is US, you can skip this step.**

The default console keymap of `ArchLinux` is US. Available layouts can be listed with:

```bash
ls /usr/share/kbd/keymaps/**/*.map.gz
```

To modify the layout, append a corresponding file name to [loadkeys](https://man.archlinux.org/man/loadkeys.1), omitting path and file extension. For example, to set a German keyboard layout:

```bash
loadkeys de-latin1
```

Console fonts are located in `/usr/share/kbd/consolefonts/` and can likewise be set with [setfont](https://man.archlinux.org/man/setfont.8).

#### Verify the Boot Mode

In fact, the default boot mode provided by VMware Workstation is `BIOS`+`MBR`.

Enter the following command, you can see that there is no partition whose `Type` is `EFI System`.

```bash
fdisk -l
```

![fdisk -l output showing disk partitions](https://img.eigenigma.io/how-to-install-archlinux-on-a-virtual-machine/fdisk-list.png)

#### Connect to the Internet

`Archlinux` cannot be installed offline. We need to download the required components online. Therefore, next we have to connect to the Internet.

Make sure your physical machine is connected to the Internet.

Enter and execute the following command to obtain the IP address.

```bash
dhcpcd
```

Then enter and execute the following command to determine if the network connection is working.

```bash
ping www.google.com
```

If you can see something like the following, it means that `ArchLinux` is connected to the Internet.

![Successful ping test confirming network connectivity](https://img.eigenigma.io/how-to-install-archlinux-on-a-virtual-machine/ping-test.png)

> Tip: Use the shortcut `Ctrl`+`c` to terminate the currently executing command.

#### Update the System Clock

Use `timedatectl` to ensure the system clock is accurate:

```bash
timedatectl set-ntp true
```

> Under normal circumstances, this command does not output anything.

#### Part the Disks

When recognized by the live system, the virtual disk is assigned to a block device `/dev/sda`. Enter and execute the following command to view current partition status.

```bash
fdisk -l
```

The partition status has been shown previously.

Enter and execute the following command to create a **root partition**.

```bash
fdisk /dev/sda
```

1. Enter `o` to create a new `MBR` partition table.
2. Enter `n` to create a new partition.
   - First select the partition type, press `Enter` to select the default option `primary`.
   - Then you need to assign a partition number to the new partition. Press `Enter` to use the default partition number `1`.
   - Select the first sector. Under normal circumstances, you can press `Enter` directly to use the default value.
   - Select the last sector. Enter the value of the last sector and press `Enter`. If you want to make the newly created partition completely occupy the free disk space, you can directly press `Enter` to use the default value of the last sector.
3. Enter `p` to view the newly created partition. You can see something like the following.

   ![fdisk showing newly created partition](https://img.eigenigma.io/how-to-install-archlinux-on-a-virtual-machine/fdisk-new-partition.png)

4. Enter `w` to write all previous operations to the disk.

   ![fdisk writing partition table to disk](https://img.eigenigma.io/how-to-install-archlinux-on-a-virtual-machine/fdisk-write.png)

5. Once the partitions have been created, each must be formatted with an appropriate file system. Enter and execute the following command to format the root partition you just created.

```bash
mkfs.ext4 /dev/sda1
```

![Formatting partition with mkfs.ext4](https://img.eigenigma.io/how-to-install-archlinux-on-a-virtual-machine/mkfs-ext4.png)

#### Mount the File Systems

Enter and execute the following command to mount the file system on the root partition to `/mnt`.

```bash
mount /dev/sda1 /mnt
```

### Installation

From this step, we need to do some file editing operations. So you need to master the basic operations of a well-known command-line editor `Vim`. It is recommended to learn from [Interactive Vim Tutorial](https://www.openvim.com/). You just need to know how to edit, copy, paste and save a file with `Vim`.

#### Select the Mirrors

The _mirrors_ are the sources of the package we downloaded. We need to select different mirrors according to our region to speed up the download.

Enter and execute the following command to use `vim` to edit the file `/etc/pacman.d/mirrorlist`.

```bash
vim /etc/pacman.d/mirrorlist
```

> Tip: When entering the path, you can use `Tab` to auto-complete it.

The higher a mirror is placed in the list, the more priority it is given when downloading a package. You need to move the geographically closest mirrors to the top of the list.

For example, use `:/China` to find the mirrors under the string `China`. Press `dd` in `NORMAL` mode to cut the line under the cursor. Press `gg` to return to the beginning of the file. Press `P` (uppercase) to paste the line to the front of the file.

Manually input Zhengjiang University Mirror after Tsinghua University Mirror pasted before.

```bash
## China
Server = http://mirrors.tuna.tsinghua.edu.cn/archlinux/$repo/os/$arch
Server = http://mirrors.zju.edu.cn/archlinux/$repo/os/$arch
```

Input `:wq` to save and quit the file.

#### Install Essential Packages

The next step is to install the base `ArchLinux` package to the disk. This is an online download and installation process. Use the `pacstrap` script to install the base package, `Linux` kernel and firmware for common hardware.

```bash
pacstrap /mnt base base-devel linux dhcpcd
```

Depending on the download speed, you need to wait for a while here. When the command prompt reappears, you can proceed to the next step.

#### Configure the System

After installing the base package of `ArchLinux`, we need to configure the system.

##### Fstab

Enter and execute the following command to generate an fstab file which is used to mount partitions automatically.

```bash
genfstab -L /mnt >> /mnt/etc/fstab
```

Since this step is important, we need to output the generated file to check if it is correct. Enter and execute the following command.

```bash
cat /mnt/etc/fstab
```

We can see that `/dev/sda1` is mounted to the root partition.

![Generated fstab showing sda1 mounted to root](https://img.eigenigma.io/how-to-install-archlinux-on-a-virtual-machine/fstab-output.png)

##### Chroot

Change root into the new system. `chroot` means change root, which is equivalent to handing over the control to the newly installed `ArchLinux` system. **After performing this step, our operations are performed on the newly installed system on the disk.**

Enter and execute the following command.

```bash
arch-chroot /mnt
```

##### Time Zone

Enter and execute the following command to set the time zone to your region.

```bash
ln -sf /usr/share/zoneinfo/Region/City /etc/localtime
```

For example, we can set the time zone to `Shanghai`.

```bash
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
```

Run `hwclock` to generate `/etc/adjtime`:

```bash
hwclock --systohc
```

##### Install Required Package

Because we have `chroot` to the new system, there are only some of the most basic packages. At this time, we need to install some required packages ourselves. Then this tutorial will introduce `ArchLinux`’s package management tool `pacman`. In most cases, a single line of commands can solve the problem of packages and their dependencies.

The command format of installing new packages is `pacman -S packagename`. `Pacman` will automatically check the other packages (dependencies) needed for this package and install them together. Below we will install some packages through `pacman`. These packages will be used later.

Enter and execute the following command.

```bash
pacman -S vim dialog wpa_supplicant networkmanager
```

##### Localization

Set the languages we use. Use `Vim` to edit `/etc/locale.gen`.

```bash
vim /etc/locale.gen
```

Uncomment `en_US.UTF-8 UTF-8` and other needed locales in /etc/locale.gen, and generate them with:

```bash
locale-gen
```

For example, we can use `:/` to find `zh_CN.UTF-8 UTF-8`, `zh_HK.UTF-8 UTF-8`, `zh_TW.UTF-8 UTF-8` and `en_US.UTF-8 UTF-8` then delete the `#` before them.

Create (when the file does not exist, `Vim` will create a file with the same name) the `locale.conf` file.

```bash
vim /etc/locale.conf
```

Add the following to the first line of the file.

```bash
LANG=en_US.UTF-8
```

Input `:wq` to save and quit the file.

##### Network Configuration

Create the `hostname` file.

```bash
vim /etc/hostname
```

Enter your own _myhostname_ in the first line of the file.

Input `:wq` to save and quit the file.

Edit the `/etc/hosts` file.

```bash
vim /etc/hosts
```

Add the following at the end of the file (replace _myhostname_ with your own _hostname_).

> 127.0.0.1 localhost
> ::1 localhost
> 127.0.1.1 _myhostname_.localdomain _myhostname_

Input `:wq` to save and quit the file.

##### Root Password

Set the root password.

```bash
passwd
```

Type and retype your root password.

##### BootLoader

Choose and install a `Linux`-capable boot loader. Here we install the most popular boot loader `Grub2`.

- First install `os-prober` and `ntfs-3g`, which can be used with `Grub` to detect existing systems and automatically set startup options.

  ```bash
  pacman -S os-prober ntfs-3g
  ```

- Install `grub`.

  ```bash
  pacman -S grub
  ```

- Deploy `grub`.

  ```bash
  grub-install --target=i386-pc /dev/sda
  ```

- Generate the configuration file.

  ```bash
  grub-mkconfig -o /boot/grub/grub.cfg
  ```

![GRUB installation and config generation output](https://img.eigenigma.io/how-to-install-archlinux-on-a-virtual-machine/grub-install.png)

**If you do not see the message as shown, please double-check that the above process is completed correctly.**

##### BootLoader Check

Use the following command to check whether the entry of the system is successfully generated. If it is not generated normally, there will be no system entry when booting.

```bash
vim /boot/grub/grub.cfg
```

Check if there is an `ArchLinux` entry near the end of the menuentry section. The following figure shows the detected `ArchLinux` entry.

![GRUB config showing ArchLinux menuentry](https://img.eigenigma.io/how-to-install-archlinux-on-a-virtual-machine/grub-menuentry.png)

**If you do not see `ArchLinux` entry or the file `grub.cfg` does not exist, please check the directory `/boot` first.**

See if there are files `initramfs-linux-fallback.img` `initramfs-linux.img` `intel-ucode.img` and `vmlinuz-linux`. If not, the `Linux` kernel is not deployed properly. This is most likely caused by the `/boot` directory not being properly mounted. After confirming that the `/boot` directory is correct, you can redeploy the `Linux` kernel.

```bash
Pacman -S linux
```

Then regenerate the configuration file `grub.cfg` and try to find the system entry.

#### Reboot

Exit the `chroot` environment by typing `exit` or pressing `Ctrl`+`d`.

Finally, restart the machine by typing `reboot`.

Click on `Edit virtual machine settings`. Change the `CD/DVD (IDE)` connection. Choose `Use physical drive: Auto detect`. Now you have removed the installation media and then you can login into the new system with the root account.

### Post-installation

See [General recommendations](https://wiki.archlinux.org/title/General_recommendations) for system management directions and post-installation tutorials (like setting up a graphical user interface, sound or a touchpad).

For a list of applications that may be of interest, see [List of applications](https://wiki.archlinux.org/title/List_of_applications).
