DEV Community

loading...
Cover image for Minimal Arch Linux Installation Guide: Get Ready In Half An Hour

Minimal Arch Linux Installation Guide: Get Ready In Half An Hour

siatwe profile image Simon Weis Updated on ・6 min read
  • Edit 20191226: Manuall installation linux kernel, nano and dhcpcd
  • Edit 20190809: Installation of base-devel not required for minimal setup
  • Edit 20190318: Typo: sudoer => sudoers
  • Edit 20190208: Added: Solution if pacstrap -i does not run properly due to invalid packet data (invalid or corrupted package (PGP signature)
  • Edit 20190205: Added: loadkeys during installation ___

originally posted on my blog

Step by step guide to install a minimal Arch Linux OS with graphical user interface, a terminal emulator and a browser in just 20 - 30 minutes. But of course:

  • "Minimal" means one partition, no swap and no special driver requirements.

If you want to try it, I would recommend you to install it first on a virtual machine, so you can't break anything.


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

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

Then load your prefered layout:

loadkeys <lang-code>

For example:

loadkeys de-latin1

Are you connected to the Internet? You absolutely need Internet for the installation! If your computer is connected to a LAN cable, that shouldn't be a problem unless you're using completely exotic hardware.

  • -c: n tries
ping -c 3 google.com

If you are not connected to the Internet, check your available network interfaces...

  • link: Manage and display the state of all network interfaces
ip link

Output could something like this:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp0s25: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/ether xxxxxxxxxxxxxxxxx brd xxxxxxxxxxxxxxxxx
3: wlp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DORMANT group default qlen 1000
    link/ether xxxxxxxxxxxxxxxxx brd xxxxxxxxxxxxxxxxx

...and try to configure your favorite one with DHCP:

dhcpd <INTERFACE>

For example:

dhcpd enp0s25

Or use your WLAN interface to connect to the Internet:

wifi-menu

Update the package repository:

  • -Syy: Synchronizing package databases without upgrading them
pacman -Syy

Install the reflector package which generates an optimized mirror list based on the given country name. (In this case for Germany):

  • -S: Install (S)pecific or (S)ingle package(s)
pacman -S reflector
  • -c: Country in quotes
  • -f: The fastest n
  • -l: Limit the list to the n most recently synchronized servers
  • -n: Return at most n mirrors
  • --save: And save it to ...
reflector -c "Germany" -f 12 -l 10 -n 12 --save /etc/pacman.d/mirrorlist

Have a look at the available hard disks and their partitions. The partitions are not important now, but it can make it easier to identify your disks and reduce the risk of overwriting the wrong one:

  • -l: List the partition tables for the specified devices
fdisk -l

Run cfdisk on your selected hard drive and create a primary and bootable partition. It is important not to apply cfdisk to a partition, but to the disk itself. /dev/sda != /dev/sda1

  • X: Disk letter
cfdisk /dev/sdX

After you have created the partition, it have to be formatted. For example with ext4 or btrfs. Now it is important to select the partition:

  • XY: Disk letter + Y: Partition number
mkfs.ext4 /dev/sdXY

You now have to mount the partition created this way to /mnt:

mount /dev/sdXY /mnt

The following command installs the base system on the given partition:

  • -i: Prompt for package confirmation when needed (run interactively)
pacstrap -i /mnt base

If there are problems with incorrect packet data (invalid or corrupted package (PGP signature)), run the following commands and try again:

pacman-key --init
pacman-key --populate archlinux
pacman-key --refresh-keys

After the installation is finished you can create the fstab file with the following command:

  • -U: Use UUIDs (Universally Unique Identifiers) for source identifiers (shortcut for -t UUID)
  • -p: Avoid printing pseudofs mounts
genfstab -U -p /mnt >> /mnt/etc/fstab

Now chroot into your currently installed system with bash:

arch-chroot /mnt /bin/bash

Install nano:

pacman -S nano

Edit /etc/locale.gen and uncomment your preferred language(s) for utf-8 and en_US.UTF-8 UTF-8:

nano /etc/locale.gen

For example:

de_DE.UTF-8 UTF-8 
en_US.UTF-8 UTF-8

And now, create your locale file(s):

locale-gen

(The next two points can be skipped if you later want to synchronize the time settings over the Internet.)

Select your time zone. (With a few chars and the tab key you can auto complete possible continents and cities):

  • -sf: Make symbolic links instead of hard links and remove existing destination files
ln -sf /usr/share/zoneinfo/<CONTINENT>/<CITY> /etc/localtime

For example:

ln -sf /usr/share/zoneinfo/Europe/Berlin /etc/localtime

Update your hardware clock:

  • --systohc: System 2 hardware clock
  • --utc: UTC time
hwclock --systohc --utc

Give your computer a name (hostname):

echo <HOSTNAME> > /etc/hostname

Create/edit /etc/hosts and add your hostname and some needed informations:

nano /etc/hosts
127.0.0.1   localhost.localdomain   localhost                    
::1              localhost.localdomain   localhost
127.0.1.1   localhost.localdomain   <HOSTNAME>

Change the root password:

passwd

Install sudo, grub and the kernel. Optional: dialog, netctl, dhcpcd and wpa_supplicant if you have set up your Internet connection with wifi-menu, so you can use wifi-menu again after the next reboot:

pacman -S grub sudo dialog netctl wpa_supplicant dhcpcd linux linux-headers linux-firmware

Install Grub on your hard disk (not the partition). If you have other non Linux/Unix-like operating systems on your computer (e.g. Windows) and want to be able to boot them via Grub then install os-prober and mount it, Grub should recognize the operating system then:

grub-install /dev/sdX

Create the grub configuration file:

  • -o: Out. Specify the output file
grub-mkconfig -o /boot/grub/grub.cfg

At this point you should enable the dhcpcd daemon to your preferred network interface to avoid doing this at every new startup. (Not necessary if you used wifi-menu and want to stay with it):

  • enable: Enable this service/daemon...
  • --now: NOW! You don't really need this parameter here, but it's still good to know that it exists
systemctl enable dhcpcd@<INTERFACE> --now

Exit the chroot environment:

exit

Unmount the arch partition:

  • -R: Recursively
umount -R /mnt

Reboot your system (Important: Did you configure grub correctly and without error messages? If this is not the case, you can only boot into your newly installed system under certain circumstances {boot from live medium again, mount your existing /mnt partition, chroot into it and try to install grub again}. So you should be sure now):

reboot

Login as root and create a new user:

  • -m: Create the home dir
  • -g: The group name or ID for a new user's initial group, in this case: users
  • -G: A list of supplementary groups which the user is also a member of, in this case: wheel (Administration group, later needed for our sudo command)
  • -s: The path to the user's standard/login shell, here: /bin/bash
useradd -m -g users -G wheel -s /bin/bash <USERNAME>

Change the password for your new user:

passwd <USERNAME>

Edit the /etc/sudoers file and uncomment the following line:

nano /etc/sudoers
%wheel     ALL=(ALL) ALL

Exit the root environment:

exit

Login as new created user and install X, a window manager with a simple menu and status bar, audio, a terminal emulator and a web browser (In this example i3 with dmenu and i3status, the xfce4 terminal and chromium):

sudo pacman -S pulseaudio pulseaudio-alsa alsa-utils xorg xorg-xinit i3-wm dmenu i3status chromium xfce4-terminal

Put i3 in your ~/.xinitrc file, so startx knows what to do:

$ echo "exec i3" > ~/.xinitrc

Start X:

startx

No sound?

Type win + enter (to open the installed terminal) execute the following command and try again:

alsactl init

There you go. Now you have a minimal Arch Linux operating system on your computer. Without garbage and only with the software you wanted. With win + d a small menu opens at the top of the screen - from there you can start your programs.


TODO

  • UEFI Installation

Discussion (17)

pic
Editor guide
Collapse
webreflection profile image
Andrea Giammarchi

To have UEFI partition and optionally a swap too, boot via USB/CD and type:

bash <(curl -s archibold.io/based)

You can then optimize mirrors and local time , or other extras, once rebooted.

You can also bash <(curl -s archibold.io/install/gnome) once rebooted, and have full desktop experience (remember to enable dark theme via gnome-tweaks, too gorgeous to miss).

Other infos and source code in archibold.io/

Collapse
siatwe profile image
Simon Weis Author

Nice to know!

Collapse
johnyradio profile image
johnyradio

i'm getting:

sudo genfstab -U -p /mnt >> /mnt/etc/fstab
zsh: permission denied: /mnt/etc/fstab

Collapse
johnyradio profile image
johnyradio

solved with:
genfstab -U -p /mnt | sudo tee /mnt/etc/fstab

i noticed i need sudo for other commands in this tute. Was i supposed to su at some point?

running from an existing Arch.

thx!

Collapse
shindesharad71 profile image
SHARAD SHINDE

Can you use Arch at work? I mean its bleeding edge update screws up system.

Collapse
dmfay profile image
Dian Fay

I wouldn't run Arch on servers but as long as you exercise a little care with updates (like setting IgnorePkg directives for database packages in pacman.conf) it's fine for developer machines. My primary computer has been running Arch for a few years now and I've been quite happy with its stability. I've probably wasted more time clicking "remind me tomorrow" on OSX update nag screens and wrangling Homebrew than I have dealing with pacman fallout.

Collapse
siatwe profile image
Simon Weis Author

Of course not :-) @work we use Ubuntu.

Collapse
shindesharad71 profile image
SHARAD SHINDE

Same here!

Collapse
alighazi profile image
Ali • Edited

sudoers file is in /etc/sudoers not /etc/sudoer

Collapse
siatwe profile image
Simon Weis Author

Thanks for pointing that out. I fixed it.

Collapse
alighazi profile image
Ali • Edited

thanks for the great article btw, It was easy to follow and it works!
btw it would be great if you explain how can we install other window systems on it as well (the xorg one seems quite basic)

Thread Thread
siatwe profile image
Simon Weis Author

Thank you :) I'm glad it worked out. Which window manager did you have in mind?

Thread Thread
alighazi profile image
Ali

the most popular desktop environments for example Deepin, LXDE, etc..

Collapse
johnyradio profile image
johnyradio

Why is base-devel needed? For compiling packages later?

Collapse
siatwe profile image
Simon Weis Author • Edited

The ''base-devel'' package group should also be installed if you plan on compiling software from the AUR or using ABS. So the package is not necessary at first, but quite probably later. But true, with an absolutely minimal installation it doesn't have to be there now...
Thanks for the tip, I adapted the article.