Traveling through the Arch — Vol. 3
Tags: experience, archlinux, linux
Published: 2018-06-23 08:19:09

---
title: Traveling through the Arch — Vol. 3
published: true
tags: experience,arch-linux,linux
canonical_url: 
---

![](https://cdn-images-1.medium.com/max/637/1*8xkCMdxI6Dy2EL1UzBH18A.png)

Welcome back to the third issue of “Traveling though the Arch”. The [last post](https://dev.to/svettwer/traveling-through-the-arch--vol-2-3d43-temp-slug-3313923) was about a Anarchy Linux installation using the installer from [arch-anywhere.org](http://arch-anywhere.org). This time, we’ll install a basic Arch Linux™ by our own hands without any predefined installer.

### Requirements

To follow this guide, I would like to recommend the following setup:

- Virtual machine (VirtualBox, KVM, etc.)
- A downloaded [Arch Linux™ iso image](https://www.archlinux.org/download/) to install the OS from.
- A web browser to read the instructions. I guess you‘ll have one when you’re reading this article ;-)
- 10–60 minutes of time depending on the level of detail you’re looking for

### Introduction

At first, let me point out, that I’ll not cover every step of the installation in this article but only some of the more interesting parts. You can find the whole installation process in my [Arch-Installation GitHub repository](https://github.com/FMAOuroboros/Arch-Installation), where every command is commented. I separated the installation into three major steps just as the official installation guide does.

- Creating a bootable USB Stick  
_Just in case you want to install it on a real machine_
- Installing a very basic Arch Linux™
- Installing everything else on top  
_Will be covered in the next episode_

This structure will be represented in the GitHub repository as well.

### Creating a bootable USB Stick

Under Linux, there is nothing easier than that!  
_Disclaimer!  
If you use dd, please be careful! You can easily erase your disks, if you set_ **_of_** _to the wrong device._

```
dd bs=4M if=/path/to/archlinux.iso of=/dev/sdX status=progress && sync
```

- dd  
A tool to copy files byte by byte.
- bs=4M  
Telling dd to read/write 4M byte at a time.
- if  
Stands for **i** nput  **f** ile.
- of  
Stands for **o** utput  **f** ile.
- status=progress  
Limits the output of the output to transfer statistics.
- &&  
An logical _and_ operator. Within the context of this command: If _dd_ was successful, please also execute _sync._
- sync  
Tells the system to write cached data to persistent storage.

If you’re not familiar with dd or the way that Linux handles devices, please use a tool like the _Startup Disk Creator_ or one of the other numerous programs to create bootable USB Sticks.

If you’re starting from Windows, I’d recommend the [LinuxLive USB Creator](https://www.linuxliveusb.com/).

### Installing a very basic Arch Linux™

![](https://cdn-images-1.medium.com/max/637/1*xENQrzTQl0cwXixOSck7WQ.png)<figcaption>Arch Linux™ — Boot screen</figcaption>

After booting your system from the medium of your choice, the boot screen will show up as in any other distribution. But After deciding to _Boot Arch Linux (x86\_64)_ you’ll be dropped into a the live system with nothing more than a command prompt.

![](https://cdn-images-1.medium.com/max/804/1*WfX7hvVP-_F9uG1DJ4L76A.png)<figcaption>Arch Linux live shell</figcaption>

#### Partitioning and encryption

After performing some basic configuration, I prepared my partitions. I used the tool [_cfdisk_](https://linux.die.net/man/8/cfdisk) (just because I know how it works) and created two partitions. One partition for _/boot_, with round about 200MB of space and the rest of the disk for everything else.

If you’re curious what _/boot_ is:  
Referring to the [Filesystem Hirarchy Standards (FHS)](http://refspecs.linuxfoundation.org/FHS_3.0/fhs/index.html), the [/boot](http://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch03s05.html) folder holds the static files of the boot loader. It is allowed to store the kernel there as well.

The only reason, why I setup a different partition for my boot loader and kernel is, that my main partition will be encrypted and therefore a decryption by the kernel is required before user-mode programs can be loaded.

So now that I’ve setup my partitions, it’s time to encrypt the device!  
Therefore I used the tool cryptsetup, which is a tool that is able to perform a plain [dm-crypt](https://en.wikipedia.org/wiki/Dm-crypt) or a LUKS encryption. dm-crypt is the cryptographic device mapper module where LUKS stands for _Linux Unified key Setup_, which extends the plain encryption of dm-crypt by an additional meta information header easing the identification of the encryption algorithm, finding user data within the encrypted data blob and makes some additional cryptographic features possible.

```
cryptsetup -y -v luksFormat /dev/sdaX
```

- cryptsetup  
Tool to encrypt devices
- -y  
Asks for passphrase verification
- -v  
Verbose
- luksFormat  
Encrypt with LUKS header
- /dev/sdaX  
The device to be encrypted

Encryption is done!

#### Setting up the File system

After opening the encrypted device, we’re now able to write our file system.

```
mkfs.btrfs /dev/mapper/cryptroot
```

- mkfs  
A tool to create Linux file systems
- mkfs.btrfs  
Creates a btrfs file system
- /dev/mapper/cryptroot  
The opened/mapped device

```
mkfs.ext2 /dev/sda1
```

- mkfs.ext2  
Creates a ext2 file system
- /dev/sda1  
The device to create the file system on.  
_In this case, this is my /boot partition_

Setting up a file system is not that hard. Choosing your file system however is very hard. There are multiple file systems out there with many different features. Because I don’t want to start comparing all the pros and cons of the different systems, let me just point out why I’ve chosen _ext2_ for my boot partition and _btrfs_ for everything else. At first: It was a recommendation. But that’s not enough reason to do so. Therefore I did some research.

[_ext2_](https://en.wikipedia.org/wiki/Ext2) is what one would call a very basic file system nowadays. It was meant to solve various issues of ext. But due to its simplicity it’s ideal for boot partitions, USB-Sticks and basically every storage, where [journaling](https://en.wikipedia.org/wiki/Journaling_file_system) is not required.

[_btrfs_](https://en.wikipedia.org/wiki/Btrfs) on the other hand is a file system that hits its stable state initially in 2014. It’s a [copy-on-write](https://en.wikipedia.org/wiki/Copy-on-write#Copy-on-write_in_computer_storage) file system with a vast amount of features including self-healing mechanisms, file system snapshots, subvolumes and much much more. Especially because of it’s snapshot mechanism it’s very easy to create file system backups without copying tons of data to an external drive.

#### Setting up initramfs

This section clarifies what bugged me the most when installing Linux systems with encrypted devices… until now.

The keyboard layout while setting up the passphrase was German (due to my choices during the installation process) but while booting the system, the layout switches back to English!

This led me to so many moments full of frustration but now, they are gone!  
And unfortunately it could have been so easy avoiding the frustration at all.

There is a file on your Arch Linux™ machine called _/etc/mkinitcpio.conf._  
This is a configuration file for (who would have guessed) a program called _mkinitcpio_ which is able to create _initramfs_ archives. The most important part of this configuration file is the definition of the _HOOKS_ variable. _HOOKS_ specifies the composition and behavior of the initramfs. One of this glorious hooks is called _keymap_. And this is what _keymap_ does:

> Adds the specified keymap(s) from /etc/vconsole.conf to the initramfs.   
> Loads the specified keymap(s) from /etc/vconsole.conf during early userspace.  
> Source: [https://wiki.archlinux.org/index.php?title=Mkinitcpio&oldid=492088](https://wiki.archlinux.org/index.php?title=Mkinitcpio&oldid=492088)

```
mkinitcpio -p linux
```

Done!

This means, that the keyboard layout of my choice is loaded within the initramfs. This empowers me to use as many special characters in my passphrase as I want!

### Summary

One told me once: _Setting up an Arch Linux™is no witchcraft._  
Now that I did it, I can only agree. I took some hours to find out only some of the details I wanted to know. One could spend hundreds of hours more depending on the level of detail you’re looking for. So the learning curve is steep and one will have to do some parts of the installation twice but at the end, you’ve a system which is absolutely transparent to you. And if I forget what I did once while I performed the installation, I can just look it up in the repository. At my current point it feels like there is not a single situation where the system could receives critical damage to the software that I’m unable to repair.

This article is originally published at [medium.com/@SvenHettwer](https://medium.com/@SvenHettwer/traveling-through-the-arch-vol-3-9efc70bafc80)