DEV Community

Richard Halford
Richard Halford

Posted on • Originally published at xhalford.com on

Part 3: Arch Linux Installation Guide

Originally published on xhalford.com


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 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.

$ fdisk -l
Enter fullscreen mode Exit fullscreen mode

This should give you a similar view as the lsblk command. Used when preparing the USB drive in part 1.

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.

$ fdisk /dev/nvme0n1
Enter fullscreen mode Exit fullscreen mode

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.

$ fdisk /dev/nvme0n1
$ m
$ g
$ n
$ 1
$ return
$ +550M
Enter fullscreen mode Exit fullscreen mode
  • 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.

$ n
$ 2
$ return
$ +4G
Enter fullscreen mode Exit fullscreen mode

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 by people who know more about this than I do.

Ubuntu's table showing how much swap space you might need


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.

$ n
$ 3
$ return
$ return
Enter fullscreen mode Exit fullscreen mode

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.

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
Enter fullscreen mode Exit fullscreen mode

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
$ t
$ 1
$ L
$ 1
Enter fullscreen mode Exit fullscreen mode

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

$ t
$ 2
$ L
$ 19
Enter fullscreen mode Exit fullscreen mode

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.

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
Enter fullscreen mode Exit fullscreen mode

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 has a handy page all about the EFI system partition, if you have any further questions.

To format the partition, enter the following.

$ mkfs.fat -F32 /dev/nvme0n1p1
Enter fullscreen mode Exit fullscreen mode

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.

$ mkswap /dev/nvme0n1p2
Enter fullscreen mode Exit fullscreen mode

Linux File System Partition

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

$ mkfs.ext4 /dev/nvme0n1p3 
Enter fullscreen mode Exit fullscreen mode

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.

$ swapon /dev/nvme0n1p2
$ mount /dev/nvme0n1p3 /mnt
Enter fullscreen mode Exit fullscreen mode

Done. ๐ŸŽ‰

We're almost there!


Follow me on Twitter!

Top comments (0)