Installing Arch Linux (2019)

Homepage.

Technical Notes Page.

As long as the prompt says "root@archiso#", you are in the "live system". "Live system" refers to the system that starts up when you boot from the iso.

Step -1 (Negative One)

Get the boot media.

https://www.archlinux.org/download/

Go to that website, the one in the line immediately above this line. Find a country that is near you in the "HTTP Direct Downloads" section of the website.

Click on one of the links.

You'll see a list of files. Some of them will end in ".iso".

You're looking for a filename that looks like this:

[ ] archlinux-2018.05.01-x86_64.iso 01-May-2018 05:08 560M

Click that link. You'll start downloading the file. It's 560 Megabytes, so it'll take some time to download.

When you're finished downloading the file, you can either copy it to a USB drive to create a Live USB, or you can run the installation in a virtual machine. I ran the installation on 14 May 2018 in a virtual machine that was running in VirtualBox. If you don't know how to run a virtual machine in VirtualBox, I'll write a tutorial explaining how to set up a virtual machine in VirtualBox.

When you boot either a real machine from the Live USB or a virtual machine with the arch .iso connected to it, you are ready to begin with step zero below.

Step 0

Choose "Boot Arch Linux" from the menu that appears when you boot the system.

Step 0.5 Wireless Network Setup

# wifi-menu

note: Install the "dialog" package to use "wifi-menu".

1 - Set up time synchronization

root@archiso# timedatectl set-ntp true

or

root@archiso@ timedatectl set-timezone "Australia/Brisbane"

2 - List the storage device

List the /dev/sda device, to make sure that it's there.

root@archiso# lsblk /dev/sda

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT

sda 8:0 0 50G 0 disk

NOTE (04 Jun 2019)

On a virtual machine, the command is

root@archiso#lsblk /dev/vda

"vda" is the virtual disk a

3 Create partitions

This step can be done different ways. It can be done with "fdisk" and with "parted". In this example, I explain painstakingly, step-by-step, how to do it with fdisk.

root@archiso# fdisk -l

[The contents of the disk are listed. "/dev/sda" will probably be the name of the disk you will alter.]

root@archiso# fdisk /dev/sda

Welcome to fdisk (util-linux 2.32)

Changes will remain in memory only, until you decide to write them.

Be careful before using the write command.

Device does not contain a recognized partition table.

Created a new DOS disklabel with disk identifier 0xe726af76.

Command (m for help): p

Disk /dev/sda: 50GiB, 53687091200 bytes, 104857600 sectors

Units: sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disklabel type: dos

Disk identifier: 0xe726af76

Command (m for help): n

Partition type

p primary (0 primary, 0 extended, 4 free)

e extended (container for logical partitions)

Select (default p): p

Partition number (1-4, default 1): 1

First sector (2048-104857599, default 2048): 2048

Last sector, +sectors or +size{K,M,G,T,P} (2048-104857599, default 104857599): +1G

Created a new partition 1 of type 'Linux' and of size 1GiB.

Command (m for help): n

Partition type

p primary (1 primary, 0 extended, 3 free)

e extended (container for logical partitions)

Select (default p): p

Partition number (2-4, default 2): 2

P

arFirst sector (2099200-104857599, default 2099200): 2099200

Last sector, +sectors or +size{K,M,G,T,P} (2099200-104857599, default 104857599): +10G

Created a new partition 2 of type 'Linux' and of size 10GiB.

Command (m for help): n

Partition type

p primary (2 primary, 0 extended, 2 free)

e extended (container for logical partitions)

Select (default p): p

Partition number (2-4, default 3): 3

First sector (23070720-104857599, default 23070720): 23070720

Last sector, +sectors or +size{K,M,G,T,P} (23070720-104857599, default 104857599): +8G

Created a new partition 3 of type 'Linux' and of size 8GiB.

Command (m for help): n

Partition type

p primary (3 primary, 0 extended, 1 free)

e extended (container for logical partitions)

Select (default e): p

Selected partition 4

First sector (39847936-104857599, default 39847936): 39847936

Last sector, +sectors or +size{K,M,G,T,P} (39847936-104857599, default 104857599): 104857599

Created a new partition 4 of type 'Linux' and of size 31 GiB.

Command (m for help): t

Partition number (1-4, default 4): 3

Hex code (type L to list all codes): 82

Changed type of partition 'Linux' to 'Linux swap / Solaris'.

Command (m for help): a

Partition number (1-4, default 4): 1

The bootable flag on partition 1 is enabled now.

Command (m for help): w

The partition table has been altered.

Calling ioctl() to re-read partition table.

Syncing disks.

4 - Create filesystems.

root@archiso# mkfs.ext4 /dev/sda1 root@archiso# mkfs.ext4 /dev/sda2 root@archiso# mkfs.ext4 /dev/sda4

5 Mount the filesystems

root@archiso# mount /dev/sda2 /mnt root@archiso# mkdir -p /mnt/boot root@archiso# mount /dev/sda1 /mnt/boot root@archiso# mkdir -p /mnt/home root@archiso# mount /dev/sda4 /mnt/home

6 Set up and activate swap.

root@archiso# mkswap /dev/sda3 Setting up swapspace version 1, size = 8 GiB (8589930496 bytes) no label, UUID=bc4f947e-9957-4b11-9b52-0ebbc0639383 root@archiso# swapon /dev/sda3

7 Install Arch.

SIMPLE, BEGINNER WAY:

Run this command:

root@archiso# pacstrap /mnt base base-devel intel-ucode xfce4 gdm dialog wpa_supplicant

MORE ADVANCED WAY:

Overview: Edit the mirrorlist file to point to local mirrors. Run pacstrap. /etc/pacman.d/mirrorlist - This file contains all mirrors. You can edit it, moving geographically-closer mirrors to the top of the file to make the downloads faster. root@archiso# pacstrap /mnt base base-devel intel-ucode xfce4 gdm dialog wpa_supplicant This step takes a long time. I have run it many times, and it usually takes around thirty minutes when run over a wireless network. I began this step at 1458 aest 14 May 2018. Here is what I installed and how long it took: base base-devel intel-ucode gdm 14:27.29 total base base-devel intel-ucode xfce4 gdm This took 49 minutes on 15 May 2018. base base-devel intel-ucode xfce4 gdm This took 12 minutes of 15 May 2018, in the late afternoon. I was near the wireless access point. This took 2 minutes and 15 seconds of 09 Feb 2020, in the prenoon (finishing at 11:51). I was using Optus 4G. base base-devel intel-ucode xfce4 gdm 25:08.57 total I altered the method of installation (I used archlinux.org/mirrorlist), and I got this result: base base-devel intel-ucode xfce4 gdm 04:24.97 total This method involves using "elinks" to go to archlinux.org/mirrorlist, and using that page to generate a list of servers. When the list of servers is generated, press "ESC" to bring up the file menu, and save the page as a file called "abc". This will put the file "abc" in your liveiso home directory. Press "ESC" and then "x" to exit from "elinks". Then overwrite the /etc/pacman.d/mirrorlist file by running the command "# cp abc /etc/pacman.d/mirrorlist". Then run the command "sed -i "s/#S/S/g" /etc/pacman.d/mirrorlist" to uncomment the servers listed in the /etc/pacman.d/mirrorlist file.

8

Generate the file system table. root@archiso# genfstab -U /mnt >> /mnt/etc/fstab

9

Change the root directory. root@archiso# arch-chroot /mnt /bin/bash

10

Uncomment "en_US.UTF-8 UTF-8" in "/etc/locale.gen".

11

Run locale-gen [root@archiso /]# locale-gen Generating locales... en_US.UTF-8... done Generation complete.

12

Select the timezone. [root@archiso /]# tzselect You can make this change permanent for yourself by appending the line TZ='Australia/Brisbane'; export TZ to the file '.profile' in your home directory; then log out and log in again.

13

Set the timezone and the hardware clock. [root@archiso/]# ln -sf /usr/share/zoneinfo/Region/City /etc/localtime [root@archiso /]# hwclock --systohc --utc (e.g., in my case, the first of these two commands is "ln -sf /usr/share/zoneinfo/Australia/Brisbane /etc/localtime". This sets the system's clock to display Brisbane time.)

14

Generate initramfs [root@archiso /]# mkinitcpio -p linux This takes about a minute. As of 09 Feb 2020, this might not be necessary. "mkinitcpio" creates an initial ramdisk environment.

15

Install the grub package and the os-prober package. [root@archiso /]# pacman -S grub os-prober resolving dependencies... looking for conflicting packages... Packages (2) grub-2:2.02-5 os-prober-1.76-1 Total Download Size: 6.05 MiB Total Installed Size: 30.07 MiB :: Proceed with installation [Y/n] Y

16

Install GRUB on the /dev/sda filesystem. [root@archiso /]# grub-install --target=i386-pc /dev/sda Installing for i386-pc platform. Installation finished. No error reported.

17

Create the grub.cfg file. [root@archiso /]# grub-mkconfig -o /boot/grub/grub.cfg Generating grub configuration file ... Found linux image: /boot/vm-linuz-linux Found initrd image: /boot/intel-ucode.img /boot/initramfs-linux.img Found fallback initrd image(s) in /boot: initramfs-linux-fallback.img WARNING: Failed to connect to lvmetad. Falling back to device scanning. done

18

Set the hostname. # vi /etc/hostname or # echo "arch" > /etc/hostname (Add the line "arch" to this file to set the system's hostname to "arch".)

19

Discover the name of the wired network device. [root@archiso /]# ip addr 1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forver 2: enp0s3: mtu 1500 qdisc fq_code1 state UP group defualt qlen 1000 link/ether 08:00:27:58:0a:6c brd ff:ff:ff:ff:ff:ff inet 10.0.2.15/24 brd 10.0.2.255 scope global noprefixroute enp0s3 valid_lft forever preferred_lft forever inet6 fe80::363c:1cb3:7251:2ac8/64 scope link valid_lft forever preferred_lft forever In this example, the name of the wired network device is "enp0s3". The section after "1:" refers to the loopback device, which is another way of saying "This system." The section after "2:" refers to the wired network device, and is the device that we're looking for in this installation procedure.

20

Enable the network connection - DO NOT DO THIS IF YOU ARE USING WIFI -- set up wifi after the reboot WIRED METHOD [root@archiso /]# systemctl enable dhcpcd@enp0s3.service Created symlink /etc/systemd/system/multi-user.target.wants/dhcpcd@enp0s3.service -> /usr/lib/systemd/system/dhcpcd@.service. In the above example, "enp0s3", which you discovered in Step 19, is the key part of this command. It might be the case that your wired device isn't called "enp0s3". If it is the case that it's not called "enp0s3", then you should replace "enp0s3" with whatever the wired device is called. NOTE: if you enable dhcpcd, you won't be able to use netctl to set up a wireless network connection. In order to use wifi-menu (which is a frontend for netctl), you have to turn off the wlp3s0 connection. wifi-menu won't work otherwise. In order to turn off the wlp3s0 connection, run the following command: # ip link set wlp3s0 down When this is done, you can run this command: # wifi-menu

21

Set the root password. [root@archiso /]# passwd New password: Retype new password: passwd: password updated successfully

22

Exit the chroot environment. [root@archiso /]# exit arch-chroot /mnt /bin/bash 18.70s user 6.15s system 3% cpu 12:01.21 total

23

Unmount the partitions. root@archiso ~ # umount -R /mnt

24

Reboot. root@archiso ~ # reboot [Take the .iso out of the disk drive. This might mean that you have to shut the computer down. If so, do it. Alternatively, you can choose "Boot from existing OS" in the Arch boot menu that appears when you boot from the .iso.]

25

Log in to the system. Arch Linux 4.16.8-1-ARCH (tty1) arch login: root Password: [root@arch ~]#

26

Create a non-root account and give it sudo privileges. [root@arch]# useradd -m -G wheel -s /bin/bash username [root@arch]# passwd username [root@arch]# visudo Find this line: root ALL=(ALL) ALL Add this line immediately below it: username ALL=(ALL) ALL Uncomment the line that reads # %wheel ALL=(ALL) ALL That means that you should change the line so that it looks like this: %wheel ALL=(ALL) ALL The "-m" flag in the "useradd" command" creates a home directory for the user that the useradd command specifies. If you don't use this flag, you have to create a home directory and chown it, setting ownership to the user's identity. If this paragraph is just a bunch of jargon to you, ignore it and trust that it will make sense when you know more about user creation and system administration.

26.5

Connect the wireless network to the operating system WIRELESS METHOD [root@archiso/]# wifi-menu -o This command generates a file whose name is made up of the network interface name (for instance "wlp3s0") and the network name (for instance "TP-Link_5G"). The file appears in the "/etc/netctl" directory. The absolute location of the file is "/etc/netctl/wlp3s0_TP-Link_5G".sydo Move to the "/etc/netctl" directory where the network configuration profile was outputted to: [root@archiso/]# cd /etc/netctl Use "netctl" to turn on the network: [root@archiso/etc/netctl]# netctl start wlp3s0_TP-Link_5G Use "netctl" to make the network connection persist between reboots: [root@archiso/etc/netctl]# netctl enable wlp3s0_TP-Link_5G

27

Install gdm $ sudo pacman -S gdm $ sudo systemctl enable gdm $ sudo systemctl start gdm

28

Install and enable ssh $ sudo pacman -S openssh $ sudo systemctl enable sshd

29

Other software $ sudo pacman -S net-tools xterm vim firefox opera

Troubleshooting

Q: I can't run "gnome-terminal" after I install the "gnome" group. A: On 14 May 2018, I had this problem, and I did the following: # locale-gen # localectl set-locale LANG="en_US.UTF-8" # reboot After that, "gnome-terminal" could be launched from the ALT+F2 launcher. How To Install Software $ sudo pacman -S vim How To Uninstall Software $ sudo pacman -R vim How To Install VirtualBox $ sudo pacman -S virtualbox linux-headers virtualbox-host-modules-arch When that's done, run $ sudo modprobe vboxdrv This command loads the kernel module "vboxdrv". Inside a VirtualBox instance that is running Arch Linux, it seems that you can't install Arch from an x86_64 (64-bit) iso. Instead, you need a 32-bit iso. The 32-bit iso can be obtained at "https://archlinux32.org/download/". How to Install elinks $ sudo pacman -S elinks during pacstrap: # pacstrap elinks How to generate a superior mirrorlist for installation: [root@archiso /]# elinks Go to archlinux.org/mirrorlist. Generate a mirrorlist for your country. Save it to the local filesystem. (use the "File" menu to save the file to your filesystem). How to Install Kodi # pacman -S kodi # pacman -S libnfs # pacman -S alsa-utils "libnfs" is necessary so that Kodi can attach to NFS shares. "alsa-utils" provides "alsamixer", which allows you to un-mute the system (Arch is muted every time I've done an installation of it, and I have to run "alsamixer" and press "m" to unmute the system.) How to Install an X Server and a Window Manager (not a Desktop Environment) # pacman -S xorg-server xorg-apps xorg xorg-xinit xterm fluxbox # xinit This works only when signed in as root. When you sign in as a user, you must run # startx or you will get a message that reads "init: unable to connect to X server: connection refused". "xorg-xinit" is the package that provides the "xinit" command. This was unknown to me until 30 May 2018. Discovering this made it possible for me to launch an Xorg session, and thereby to launch fluxbox. Previously, I was wandering in the night in which all cows are black. How to set Fluxbox to launch when you run "startx" $ cp /etc/X11/xinit/xinitrc ~/.xinitrc Add the following to any white space in .xinitrc: exec fluxbox Then run this command again: $ startx How to Get Audio Working (Probably) By default, alsamixer has muted the audio channels. Install "alsa-utils" and use "alsamixer" to fix this. # pacman -S alsa-utils $ alsamixer Then select the audio channels (use the left and right arrows) and press "m" to unmute them. After they're unumted, use the up and down arrows to set the volume however loud you want it. How to Install a Screen-Locker # pacman -S xtrlock "xtrlock" is invoked through the command line or the application launcher. It freezes the screen in the state the screen is in when the command is invoked. To unlock the screen, type your user password and press ENTER. How to Install and Set Up an Apache Web Server # pacman -S apache # systemctl start httpd # systemctl enable httpd # touch testfile # cp testfile /srv/http/ Now go to the port-forwarded ip address of the machine on which the Apache Web Server is running. Stack Tracing # pacman -S gdb Without this package, you cannot perform stack tracing. When Kodi crashes, you will not have a stack trace in the log unless this package has been installed. Managing Access Through SSH (blocking malicious actors) On 03 Jun 2018 I noticed that actors from China and Croatia were trying to get access to my Arch machine. I used the program "ipset" to block the Chinese IP: https://wiki.archlinux.org/index.php/Ipset How to Install "packer" 1. Install dependencies $ sudo pacman -S wget git expac jshon 2. Create a temporary directory for the installation: $ mkdir packer $ cd packer 3. Download the package build script from AUR: $ sudo wget https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=packer 4. Download the package build script from AUR: $ mv PKGBUILD?h=packer PKGBUILD 5. Compile the package using PKGBUILD: $ makepkg 6. Install the package: $ sudo pacman -U packer-20150808-1-any.pkg.tar.gz 7. Remove the temporary installation directory: $ cd; sudo -rm dR packer Test by installing "chromium": $ sudo packer -S chromium If you get Error 404 when trying to Install a Package In this case, synchronize your repository information and update your system. # pacman -Syu How to get the "ifconfig" command working You have to install the "net-tools" package. # pacman -S net-tools How to use AUR Go to aur.archlinux.org and acquire buildfiles. Verify that the PKGBUILD and the accompanying files are not malicious or untrustworthy. Run "makepkg -si" in the directory where the files are saved. This performs the whole installation procedure. An Arch Linux installation Guide, found here: https://drive.google.com/file/d/1GKt-XcaR60z7ZdShhj6JZ4bvy5vTdxZm/view ## Arch Linux installation ### Verify the boot mode * `ls /sys/firmware/efi/efivars` >> In EFI mode if result is not empty ### Connect to the internet * `lspci -k` >> show drivers * `ip link` >> show interfaces * `ip link set up` >> bring up wireless interface * `iw dev scan | less ` >> scan wireless network * `wpa_passphrase "My SSID" "My Password" > pass` >> generate WPA password * `wpa_supplicant -B -i -c /path/to/pass` >> connect to network * `dhcpd > get assigned IP address ### Partition disks * `parted` >> enter interactive mode (using **parted** which is a terminal partitioning tool * `mkpart primary ebs 1Mib 513MiB` >> create EFI file system * `mkpart primary linux-swap 513MiB 3000MiB` >> create swap (*change size accordingly*) * `mkpart primary ext4 3000 50%` >> create ext4 for installation * `print` >> to show partition tables ### Format the partitions * `mkfs.ext4 /dev/sdax` >> format **sdax** to be ext4 (**x** is a number, e.g: **sda1**) * `mkswap /dev/sdax` >> format swap partition ### Mount the file systems * `mount /dev/sda3 /mnt` >> assuming installation is in sda3 * `mkdir /mnt/boot/efi` >> create EFI for grub install * `mount /dev/sda1 > /mnt/boot/efi` >> mount EFI to this dir * `mkdir /mnt/boot` ### Installation * ##### Select mirrors: * Move the geographically closest mirrors to the top of the list, which is located in `/etc/pacman.d/mirrorlist` * ##### Install the base packages * `pacstrap /mnt base` * ##### Config the system * Fstab: `genfstab -U /mnt >> /mnt/etc/fstab` * Chroot: `arch-chrrot /mnt` * Set timezone: `/usr/share/zoneinfo/Region/City /etc/localtime` * Locale: `locale-gen` * Hostname: `echo yourhostname > /etc/hostname` * Initramfs: `mkinitcpio -p linux` * Set root password: `passwd` * Install network manager: `pacman -S networkmanager` * ##### Boot loader * Install GRUB: `pacman -S grub` and then `grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=arch_grub /dev/sda` * Finally: `grub-mkconfig -o /boot/grub/grub.cfg` ## Post installation #### Create user * `useradd -m -g users -G wheel -s /bin/bash sondv` >> create a user with name **sondv** belong to **wheel** group * `pacman -S sudo` and then `visudo` >> comment **wheel** and **sudo** group * `pacman -S pulseaudio pulseaudio-alsa xorg xorg-xinit` * `echo "exec startkde" > ~/.xinitrc"` * `pacman -S plasma-desktop dolphin firefox kate terminator plasma-nm sddm` * `startx` to start graphical interface * `pacman -Syyu` >> synchronize packages * `systemctl enable sddm.service` >> enable graphical interface * `pacman -S ttf-freefront breeze-gtk breeze-kde4 kde-gtk-config powerdevil plasma-pa redshift` *

To learn more HTML/CSS, check out these tutorials!