DEV Community

Cover image for Minimal Arch Linux Installation Guide: Get Ready In Half An Hour
Simon Weis
Simon Weis

Posted on • Updated on

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

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

Then load your prefered layout:

loadkeys <lang-code>
Enter fullscreen mode Exit fullscreen mode

For example:

loadkeys de-latin1
Enter fullscreen mode Exit fullscreen mode

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

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

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

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

dhcpd <INTERFACE>
Enter fullscreen mode Exit fullscreen mode

For example:

dhcpd enp0s25
Enter fullscreen mode Exit fullscreen mode

Or use your WLAN interface to connect to the Internet:

wifi-menu
Enter fullscreen mode Exit fullscreen mode

Update the package repository:

  • -Syy: Synchronizing package databases without upgrading them
pacman -Syy
Enter fullscreen mode Exit fullscreen mode

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

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

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

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

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

mount /dev/sdXY /mnt
Enter fullscreen mode Exit fullscreen mode

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

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

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

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

Now chroot into your currently installed system with bash:

arch-chroot /mnt /bin/bash
Enter fullscreen mode Exit fullscreen mode

Install nano:

pacman -S nano
Enter fullscreen mode Exit fullscreen mode

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

nano /etc/locale.gen
Enter fullscreen mode Exit fullscreen mode

For example:

de_DE.UTF-8 UTF-8 
en_US.UTF-8 UTF-8
Enter fullscreen mode Exit fullscreen mode

And now, create your locale file(s):

locale-gen
Enter fullscreen mode Exit fullscreen mode

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

For example:

ln -sf /usr/share/zoneinfo/Europe/Berlin /etc/localtime
Enter fullscreen mode Exit fullscreen mode

Update your hardware clock:

  • --systohc: System 2 hardware clock
  • --utc: UTC time
hwclock --systohc --utc
Enter fullscreen mode Exit fullscreen mode

Give your computer a name (hostname):

echo <HOSTNAME> > /etc/hostname
Enter fullscreen mode Exit fullscreen mode

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

nano /etc/hosts
Enter fullscreen mode Exit fullscreen mode
127.0.0.1   localhost.localdomain   localhost                    
::1              localhost.localdomain   localhost
127.0.1.1   localhost.localdomain   <HOSTNAME>
Enter fullscreen mode Exit fullscreen mode

Change the root password:

passwd
Enter fullscreen mode Exit fullscreen mode

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

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

Create the grub configuration file:

  • -o: Out. Specify the output file
grub-mkconfig -o /boot/grub/grub.cfg
Enter fullscreen mode Exit fullscreen mode

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

Exit the chroot environment:

exit
Enter fullscreen mode Exit fullscreen mode

Unmount the arch partition:

  • -R: Recursively
umount -R /mnt
Enter fullscreen mode Exit fullscreen mode

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

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

Change the password for your new user:

passwd <USERNAME>
Enter fullscreen mode Exit fullscreen mode

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

nano /etc/sudoers
Enter fullscreen mode Exit fullscreen mode
%wheel     ALL=(ALL) ALL
Enter fullscreen mode Exit fullscreen mode

Exit the root environment:

exit
Enter fullscreen mode Exit fullscreen mode

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

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

$ echo "exec i3" > ~/.xinitrc
Enter fullscreen mode Exit fullscreen mode

Start X:

startx
Enter fullscreen mode Exit fullscreen mode

No sound?

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

alsactl init
Enter fullscreen mode Exit fullscreen mode

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

Top comments (15)

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

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

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

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

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

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