Part 3: Arch Linux Installation Guide
Tags: linux, archlinux, tutorial
Published: 2021-08-12 15:10:50

*Originally published on [xhalford.com](https://www.xhalford.com/part-3-arch-linux-installation-guide/)*


---

In part 3 of this **series**, we will be partitioning, formatting and mounting a drive to install Arch on. This follows on from the live environment setup completed in the [previous part](https://www.xhalford.com/part-2-arch-linux-installation-guide/) of this guide series.

> _**Notes:** There are a few presumptions being made for this guide. Regarding yourself and your current setup._
> 
> - *You will be moving from another \*nix system.*
>     - *This will help with the initial steps, with the programs being used to download the image and write it to a USB drive.*
>     - *If you are coming from Windows, I will try to link to articles explaining this fairly trivial difference.*
> - *Have access to this guide on another device.*
>     - *As once we get to installing Arch Linux, we'll be stuck in a terminal for some major steps.*
> 
> - *Can handle looking deep into the empty void of the tty.*
> - *Make sure not to make any typos - as I try to do the same throughout these guides.*


---

## What you'll need:

- The patience to re-read every command you type, and output given.
- It's not the end of the world if you "mess up" at any stage here. You'll just save yourself the time of redoing anything, if you do.


---

# Partitioning

First, we need to partition our hard drive. Creating a space for the boot, file system and swap partitions. For this, we'll use **fdisk**, a common Linux utility.

To get started, use the below command to list view the hard drive and it's current partitions.

```sh
$ fdisk -l
```

This should give you a similar view as the **lsblk** command. Used when [preparing the USB drive in part 1](https://www.xhalford.com/part-1-arch-linux-installation-guide/#preparing-the-usb-drive-for-installation).

Now you should be able to identify which drive you have to partition. Next, you will input this drive path as an argument to the fdisk command.

```sh
$ fdisk /dev/nvme0n1
```

> Remembering to replace the path given above, with one that corresponds with your system (e.g. _fdisk /dev/sda_ or _fdisk /dev/nvme0n1_).

This will then prompt you with a series of commands to enter. To save some time I have provided you with some pretty standard options. You can tailor these to what you require - if you know what you're doing.

```sh
$ fdisk /dev/nvme0n1
$ m
$ g
$ n
$ 1
$ return
$ +550M
```

  - m = shows the help message
  - g = creates a gpt partition table
  - n = creates a new partition
  - 1 = partition number using the default
  - return = first sector starts at 2048 as default
  - +550M = gives the partition a size of 550M

This should now have created the first partition, that will be used for the EFI system.

You can list this new partition by entering _p_. This will show device start and end sectors (in mebibits, Mi) and type as "Linux filesystem".

At this point you haven't actually committed any changes yet to your drive. So don't worry if you think you've messed up. As you can _fdisk /dev/nvme0n1_ and select _d_ to delete a partition, or _q_ to quit without saving all changes.

---

## Swap Partition

To some, the creation of a swap partition is an optional step. But, given how affordable storage space is, the impact of having one is almost negligible. Especially when compared to losing all unsaved work, when your RAM fills up. And your computer needs to be restarted. Also, if you're still one to use hibernation, you will need at least the same amount of swap space as you do RAM, to store your system's state.

So creating this partition is much like the previous step. Hit _n_, and we'll create the swap partition. Enter _2_ for the partition number. Go with the default start position. And finally select how much swap space you want to assign.

```sh
$ n
$ 2
$ return
$ +4G
```

I'm choosing a swap space partition size of 4GB as I have 16GB of RAM. Some might see this as too much and some as too little. Here's an [easy to use table](https://help.ubuntu.com/community/SwapFaq#How_much_swap_do_I_need.3F) by people who know more about this than I do.

![Ubuntu's table showing how much swap space you might need](https://i.imgur.com/sF6DC1E.png)

---

## File System Partition

Now to create the partition for the system file system. Where your root directory will be created. Again this means following similar steps as before.

```sh
$ n
$ 3
$ return
$ return
```

Selecting the default partition size, by entering _return_ for the deault value. You will be assigning all remaining drive space for the Linux file system.

---

## Assigning Partition Types

Before assigning a type to each partition. We will view what we have done so far, by entering _p_, to show the current partition table.

```sh
Device          Start   End       Sectors   Size    Type
/dev/nvme0n1p1  2048    1128447   1126400   550M    Linux filesystem
/dev/nvme0n1p2  1128448 9517055   8388608   4G      Linux filesystem
/dev/nvme0n1p3  9517056 488397134 478880079 228.3G  Linux filesystem
```
> This is what my table looks like with a 256GB drive.

So far, all partitions are of the type "Linux filesystem". But we need to change the first two, to create both the EFI System and Linux swap partitions.

First up will be the 550M partition (1). Entering the below key presses to;
  1. change partition type, _t_
  2. select the correct partition, _1_
  3. list available partition types, _L_
  4. choose the EFI System partition type, _1_

```sh
$ t
$ 1
$ L
$ 1
```

Then we will do the same to the sencodn partition, creating the swap partition.

```sh
$ t
$ 2
$ L
$ 19
```

As the third partition is already of the right type to hold the root directory we can leave it as is. We can then view the partition table, _p_. 

```sh
Device          Start   End       Sectors   Size    Type
/dev/nvme0n1p1  2048    1128447   1126400   550M    EFI System
/dev/nvme0n1p2  1128448 9517055   8388608   4G      Linux swap
/dev/nvme0n1p3  9517056 488397134 478880079 228.3G  Linux filesystem
```

If you're happy with how everything looks. Hit _w_, and this new table will be saved.

---

# Formatting Partitions

Now the drive partitions have been created and assigned a type. They will now need to be formatted.

---

## EFI System Partition

As the EFI system partition is independent of the operating system being run. This means you can add a Windows operating system to your computer. Either as a separate drive or another set of future partitions.

With the EFI system partition, we will choose to go with a FAT32 file system. Instead of the standard Linux format, ext4. The [Arch Wiki](https://wiki.archlinux.org/index.php/EFI_system_partition) has a handy page all about the EFI system partition, if you have any further questions.

To format the partition, enter the following.

```sh
$ mkfs.fat -F32 /dev/nvme0n1p1
```
> Notice the additional partition number, _p1_, added to the end of the drive path.

---

## Linux Swap Partition

Then we will initialise the swap partition, _p2_.

```sh
$ mkswap /dev/nvme0n1p2
```

---

## Linux File System Partition

Finally before mounting, we will format the Linux filesystem as ext4.

```sh
$ mkfs.ext4 /dev/nvme0n1p3 
```
> When it starts to create the journal it may take a few seconds.

---

# Mounting the Formatted Partitions

Now we can mount the formatted partitions and enable the swap space.

```sh
$ swapon /dev/nvme0n1p2
$ mount /dev/nvme0n1p3 /mnt
```

Done. 🎉

We're almost there!

---

Follow me on [Twitter!](https://twitter.com/intent/user?screen_name=richardhalford_)