Categories
Uncategorized

Installing Arch Linux

A colleague told me about Arch Linux. Since I am really a DIY kind of guy, I decided to give it a try.  It is different from something like Ubuntu. It’s small and comes without a pre-installed desktop. It has no version since it is a rolling-release. Installing is a bit more more complicated than something like Ubuntu or CentOS but not that complicated. I will be assuming a UEFI installation.

Prerequisites

  • Computer, x86_64 with a minimum of 512mb RAM.
  • 2gb usb drive
  • Working internet connection.

Tools needed

Prepare the USB drive

Install Etcher on any computer . Start Etcher.

Flashing the usb drive is a simple three-step process. Select the Arch Linux iso image you downloaded. Select the USB drive. Flash!. After few minutes your drive will be ready. Of course, if you prefer another flash program, use that.

Prepare target!

The target machine is a Gigabyte BRIX computer. 8Gb, 120GB SSD, i5. No wifi, so plug in the LAN cable and of course the USB drive. While starting this computer you’ll need to hit F12 to enter boot mode. Select the UEFI usb drive.

The USB loads the following menu. Select “Arch Linux archiso x86_64 UEFI USB”.

The live-cd (usb) session will load.

 

Note: You can also do this using a VM using VirtualBox and the downloaded ISO instead of a physical computer with USB drive. You need to change a settings after creating the virtual machine. Go to Machine -> Settings. Tab System. Check ‘Enable EFI’. Choose the ISO image under Devices -> Optical drives. Right after ‘Arch Linux archiso x86_64 UEFI USB’ menu selection a black screen is shown. Be patient, it will take a while before the iso will start to load.

A prompt. Now what?

When loading is done a root session wil be started:

At this point Arch Linux is not yet installed but you can actually control Arch Linux with preselected packages. However, you are limited to use what’s on the live cd/usb. Most changes you make will be lost as soon as you restart. Fortunately it contains all the tools you need to build a real Arch Linux system.

Storage preparation

The storage preparation is an important step. Some of the steps are mandatory,  but you can extend the scheme based on your specific needs and preferences. Before we start creating the scheme, we need to make sure the disk is empty. Your storage disk might already contain data of a previous installation. We need to wipe that out together with the partitions. Next we’ll create a new partitioning scheme.

Many schemes are possible, but we’ll try to keep it simple. Let’s create a boot, swap and root partition.

A brief overview:

boot

Partition /dev/sda1 will be the boot partition. It will be mounted to /boot. This partition will hold a piece of software responsible for booting your OS or even multiple OSes. The partition type is ‘EFI System partition’. It can be relatively small, 260-512Mb is suggested.

swap

/dev/sda2 will become the swap partition [SWAP]. This is used for virtual Ram. The recommended swap space used to be twice your RAM size but if you have more than 1024Mb RAM you can have a smaller swap partition. In my case I’ll stick to 8GB so swap is equal to RAM. The partition type is ‘Linux swap’.

system root

We will create a system root partition on /dev/sda3 and will be mounted to ‘/’. It holds the linux system folder and in our case everything else. The partition type is ‘Linux’.

Locate your disk

Run lsblk to list your attached devices. This will output something like:

We need the ‘/dev/sda’  device since that’s the actual harddrive. It only has one partition sda1 in my case.

Destroy

First we will destroy our disk. This means whiping out all data and remove the partition tables.

Now I recommend to actually press ? + <Enter> for help. It will list all options (not that many). There is no option for destroying that disk. You’ll see options to create new partitions, but the tool cgdisk is a better choice for that task. However, there is an option x: for Experts. Let’s try hitting “x + <Enter>” and press “? + <Enter>” for help again. There we go: z will zap and Destroy. That sounds like fun. Press “z + <Enter>” . Confirm twice.

Partitioning

So now we have a disk with no partitions and no therefore no partition table. For partitioning we will use cgdisk.

There will be a scary GPT warning. In our case it’s just because we removed the partitioning table during the previous step. Just hit enter.

Now we get an overview showing the free space. No partitions yet since we destroyed it. Below the screen there will be a menu. Lets create boot, swap and root. Hit N or choose New.

First sector -> accept default
Size -> 512M
Hex code or GUID -> ef00 for EFI System (or lookup using L first)
Name -> boot

Important: Back in the menu select the biggest free space option before you hit N or choose New.

First sector -> accept default
Size -> 8G
Hex code or GUID -> 8200 for Linux swap (or lookup using L first)
Name -> swap

Again, select the biggest free space option before you hit N or choose New.

First sector -> accept default
Size -> accept default for remaining space
Hex code or GUID -> accept default (8300 for Linux filesystem)
Name -> root.

At this point nothing is saved. You can even change stuff if you made a mistake. Choose Write to create your scheme and yes to confirm.

Verify:

Create filesystem

The partitions can’t be used just yet. They need to be formatted for a specific filesystem. We will also mount these filesystems. This is just one-time mounting in order to download and install the software.

Create mount dirs

Boot FAT32 and mount

Swap (needs no mount)

Root ext4 and mount

Internet

To install, we need a working internet connection. In my setup I used a Ethernet cable.

Test if your internet connection is working by pinging a website. Press ctrl-c to quit.

If that’s not working we’ll need to figure out our interface before we can start it. Below a working example.

enp2s0 is the interface we need to start. Start the dhcpd service for this interface:

Download ArchLinux

So now we can start to download Arch into our /arch directory. If you remember: we created this directory ourselves and mounted it to /dev/sda3. So everything we download to /arch will be persisted even if we restart the CD image  (although we would need to mount this again).

We will use the tool pacstrap to download and install the Arch package base directly into our /arch directory.

This will take a while but after this is done the base system is ready.

Finalizing installation

Next step will be to create a fstab file. This is a file that tells linux how the partitions should be mounted at startup (the final mounting, not the mounting we just did for installation). We use the the genfstab tool that examines partitions and creates the file for the new system.

You can view the file but it is not that exiting. For example, you’ll see that /dev/sda3 will be mounted to ‘/’, this is our new root when the system is rebooted.

Now we will actually switch from our live-cd session to the newly installed Archlinux. To switch we need to use the arch version of the chroot command. Chroot is a very powerful command, not only in this context.

So now we are finally in the new installation.

Leave a Reply

Your email address will not be published. Required fields are marked *