Arch Linux Setup: Post Installation - dmitana/dotfiles GitHub Wiki

Post-Installation

System administration

User and groups

Add new unprivileged user and set his password.

$ useradd -m -G wheel -s /bin/bash <USERNAME>
$ passwd <MYUSERNAME>

Privilege elevation

Add the new user to sudoers.

$ EDITOR=vim visudo

Uncomment the line.

# %wheel      ALL=(ALL) ALL

Now you can logout and login as a newly created user.

Connect to the internet

Use the previously installed NetworkManager to connect to the internet. You should start and enable NetworkManager.service.

$ sudo systemctl enable --now NetworkManager

Note: You must ensure that no other service that wants to configure the network is running; in fact, multiple networking services will conflict. You can find a list of the currently running services with systemctl --type=service and then stop them.

After that, list nearby wifi networks and connect to a wifi network.

$ nmcli device wifi list
$ nmcli device wifi connect <SSID> --ask

Logs management

Clean systemd logs in /var/log/journal manually.

$ sudo journalctl --vacuum-size=50M

Set such limit permanenntly in /etc/systemd/journald.conf.

/etc/systemd/journald.conf

SystemMaxUse=50M

Package management

Install an AUR helper

I am using yay as an AUR helper.

First install its dependencies (some are already installed).

$ sudo pacman -S go

Then install yay.

$ git clone https://aur.archlinux.org/yay.git
$ cd yay
$ makepkg -sri

Cleaning the package cache

Install pacman-contrib for the paccache script.

$ yay -S pacman-contrib

The paccache script deletes all cached versions of installed and uninstalled packages, except for the most recent 3, by default.

$ paccache -r

# To retain only one past version
$ paccache -rk1

Enable and start paccache.timer to discard unused packages weekly.

$ sudo systemctl enable --now paccache.timer

Add the -u/--uninstalled switch to limit the action of paccache to uninstalled packages. For example to remove all cached versions of uninstalled packages, use the following:

$ paccache -ruk0

To remove also AUR cache use:

$ yay -Sc

Tip: To remove unused packages use yay -S --clean or sudo pacman -Rns $(pacman -Qtdq).

Install preferred packages

Terminal

yay -S kitty

Python

Python itself should be installed in previous steps, but pip is missing, so install it.

$ curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
$ python get-pip.py
$ rm pip.py

Docker

$ yay -S docker docker-compose
$ sudo systemctl enable --now docker

Optionally add yourself to docker group to use docker as a non-root user. Logout and login to take effect.

$ sudo usermod -aG docker $USER

Optionally move docker's files to /home (or somewhere else), because docker images can grow in a size very quickly.

$ sudo systemctl stop docker
$ sudo mv /var/lib/docker ~/var-lib-docker
$ sudo ln -s ~/var-lib-docker /var/lib/docker
$ sudo systemctl start docker

Verify that Docker Engine is installed correctly by running the hello-world image. After that remove that worthless container and image.

$ docker run hello-world
$ docker rm ...
$ docker rmi hello-world:latest

Audio drivers

$ yay -S alsa-utils pulseaudio-alsa pulseaudio-bluetooth pulseaudio pavucontrol

Keyring

Use gnome-keyring as a wrapper around ssh-agent.

$ yay -S gnome-keyring gcr-4
$ systemctl --user enable --now gcr-ssh-agent.socket  # Don't use sude with --user flag

After installation and systemd unit enabling and starting log out and log in (or reboot) and SSH_AUTH_SOCK should be set to $XDG_RUNTIME_DIR/gcr/ssh via .zshenv.

Browser

$ yay -S google-chrome ttf-liberation firefox

Graphical user interface

Display server

Install X display server.

$ yay -S xorg-server xorg-xinit xorg-xrandr xorg-xprop xorg-xbacklight

Display drivers

Intel drivers

  1. Install intel drivers.
$ yay -S xf86-video-intel vulkan-intel vulkan-icd-loader mesa
  1. Add intel kernel graphics driver i915 to initramfs.
$ sudoedit /etc/mkinitcpio.conf

MODULES=(i915 ...)
  1. Regenerate the initramfs for the change to take effect.
$ sudo mkinitcpio -P

NVIDIA drivers

Install NVIDIA drivers.

$ yay -S nvidia 

Window manager

Install AwesomeWM/

$ yay -S awesome-git --removemake

Install my AwesomeWM's dependencies and other utilities.

$ yay -S picom-git udiskie network-manager-applet xfce4-clipman-plugin autorandr arc-icon-theme acpi xterm

Splash screen and silent boot

  1. Install plymouth a flicker-free graphical boot process. It relies on kernel mode setting (KMS) to set the native resolution of the display as early as possible, then provides an eye-candy splash screen leading all the way up to the login manager.
$ yay -S plymouth-git
  1. Add plymouth to the HOOKS array in mkinitcpio.conf. It must be added after base and udev for it to work:
$ sudoedit /etc/mkinitcpio.conf

HOOKS=(base systemd plymouth ...)
  1. Regenerate the initramfs for the change to take effect.
$ sudo mkinitcpio -P
  1. Set theme, I use Arch Linux Glow.
# Install theme
$ yay -S plymouth-theme-arch-glow

# List all installed plymouth themes
$ sudo plymouth-set-default-theme -l

# Select a theme and rebuild the initrd
$ sudo plymouth-set-default-theme -R arch-glow
  1. splash has to be appended in the kernel parameters to make plymouth works. Other parameters are for silent boot.
$ sudoedit /etc/default/grub

GRUB_CMDLINE_LINUX_DEFAULT="... quiet splash loglevel=3 rd.udev.log_priority=3 vt.global_cursor_default=0"
  1. Recreate grub config.
$ sudo grub-mkconfig -o /boot/grub/grub.cfg

Display manager

A display manager, or login manager, is typically a graphical user interface that is displayed at the end of the boot process in place of the default shell.

Install sddm DM and enable it.

$ yay -S sddm
$ sudo systemctl enable sddm.service

Install a theme.

$ yay -S sddm-theme-sugar-candy-git

Note: Sddm configuration is set up in the Dotfiles Optional section.

User directories

Well-known user directories like Downloads or Music are created by the xdg-user-dirs-update.service user service, that is provided by xdg-user-dirs and enabled by default upon install.

$ yay -S xdg-user-dirs
$ xdg-user-dirs-update

Fonts

Install used fonts and some nerd fonts.

$ yay -S ttf-dejavu ttf-liberation ttf-droid noto-fonts noto-fonts-emoji ttf-mononoki nerd-fonts-mononoki ttf-meslo ttf-meslo-nerd ttf-fira-mono ttf-fira-sans ttf-inconsolata ttf-opensans ttf-roboto ttf-ubuntu-font-family

Enable font presets by creating symbolic links.

$ sudo ln -s /etc/fonts/conf.avail/70-no-bitmaps.conf /etc/fonts/conf.d
$ sudo ln -s /etc/fonts/conf.avail/10-sub-pixel-rgb.conf /etc/fonts/conf.d
$ sudo ln -s /etc/fonts/conf.avail/11-lcdfilter-default.conf /etc/fonts/conf.d

The above will disable embedded bitmap for all fonts, enable sub-pixel RGB rendering, and enable the LCD filter which is designed to reduce colour fringing when subpixel rendering is used.

For font consistency, all applications should be set to use the serif, sans-serif, and monospace aliases, which are mapped to particular fonts by fontconfig.

Create /etc/fonts/local.conf. You can get the actual names of fonts by fc-list.

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
    <match>
        <edit mode="prepend" name="family">
            <string>MesloLGS</string>
        </edit>
    </match>
    <match target="pattern">
        <test qual="any" name="family">
                <string>serif</string>
        </test>
        <edit name="family" mode="assign" binding="same">
                <string>Noto Serif</string>
        </edit>
    </match>
    <match target="pattern">
        <test qual="any" name="family">
            <string>sans-serif</string></test>
        <edit name="family" mode="assign" binding="same">
                <string>Noto Sans</string>
        </edit>
    </match>
    <match target="pattern">
        <test qual="any" name="family">
            <string>monospace</string>
        </test>
        <edit name="family" mode="assign" binding="same">
                <string>Noto Mono</string>
        </edit>
    </match>
</fontconfig>

Keyboard layout

Create a new keyboard layout configuration using localectl. It will save the configuration in /etc/X11/xorg.conf.d/00-keyboard.conf, this file should not be manually edited, because localectl will overwrite the changes on next start.

$ localectl --no-convert set-x11-keymap us,sk pc104 ,qwerty grp:alt_shift_toggle

After reboot a new keyboard layout will work.

GTK3 Theme

  1. Install app for chaging system fonts, icons, themes and cursor themes.
$ yay -S lxappearance-gtk3
  1. Instal GTK3 theme, currently my favourite is Materia Dark Compact.
$ yay -S materia-gtk-theme
  1. Install icon theme, currently my favourite is Papirus.
$ yay -S papirus-icon-theme
  1. Install cursor theme, currently my favourite is Vimix.
$ yay -S vimix-cursors
  1. GTK3 theme, icon theme, fonts and cursor themes can be set in lxappearance. If you already have cloned dotfiles, then everything should be set (maybe a reboot is needed).

Dotfiles

Now, install Dotfiles. After that, come back and finish this setup.

Note: if there is some problem with AwesomeWM widgets, check theirs READMES.

Power management

  1. Install TLP with tlp-rdw and optional dependencies.
$ yay -S tlp tlp-rdw ethtool smartmontools
  1. Enable TLP and NetworkManager-dispatcher (for tlp-rwd) services.
$ sudo systemctl enable --now tlp.service
$ sudo systemctl enable --now NetworkManager-dispatcher.service
  1. Mask the service systemd-rfkill.service and socket systemd-rfkill.socket to avoid conflicts and assure proper operation of TLP's radio device switching options.
$ sudo systemctl mask systemd-rfkill.service
$ sudo systemctl mask systemd-rfkill.socket

Bluetooth

  1. Install the bluez package, providing the Bluetooth protocol stack.
  2. Install the bluez-utils package, providing the bluetoothctl utility.
  3. The generic Bluetooth driver is the btusb Kernel module. Check whether that module is loaded. If it's not, then load the module.
  4. Start/enable bluetooth.service.
$ yay -S bluez bluez-utils
$ sudo systemctl enable --now bluetooth
$ lsmod | grep btusb
# Optionally load the module
$ sudo modprobe btusb
  1. Install Blueman, a full featured Bluetooth manager.
$ yay -S blueman
$ blueman-applet

Root filesystem snapshots

Such snapshots can be used for full system backups with minimal downtime or testing system updates with the option to revert them.

Create /etc/systemd/system/mk-lvm-snapshots.service containing:

[Unit]
Description=make LVM snapshots
Requires=local-fs-pre.target
Wants=local-fs.target
DefaultDependencies=no
Conflicts=shutdown.target
After=local-fs-pre.target
Before=local-fs.target

[Install]
WantedBy=make-snapshots.target

[Service]
Type=oneshot
ExecStart=/usr/sbin/lvcreate -l 100%%FREE -n root-snapshot -s /dev/vg0/root

Note: Character % have to be escaped in systemd files using another %.

Create a new systemd target /etc/systemd/system/make-snapshots.target:

[Unit]
Description=Make Snapshots
Requires=graphical.target

Enable mk-lvm-snapshots.service:

$ sudo systemctl enable mk-lvm-snapshots.service 

Create GRUB menu netry in /boot/grub/custom.cfg based on the /boot/grub/grub.cfg entry for your normal startup. The kernel command line is extended to start the new make-snapshots.target:

### make snapshots ###
menuentry 'Arch Linux - make snapshots' --class arch --class gnu-linux --class gnu --class os {
... # copy from /boot/grub/grub.cfg
        echo    'Loading Linux core repo kernel ...'
        linux   /boot/vmlinuz-linux root=/dev/vg0/root rw loglevel=3 quiet systemd.unit=make-snapshots.target
        echo    'Loading initial ramdisk ...'
        initrd  /boot/intel-ucode.img /boot/initramfs-linux.img
}

If you want to create root filesystem snapshot e.g. when performing full system update boot Arch Linux - make snapshots. If you want to permantly stick to the updates just drop the snapshot with sudo lvremove /dev/vg0/root-snapshot. If you want to revert to the snapshotted state issue a sudo lvconvert --merge /dev/vg0/root-snapshot for the snapshot. During the next restart of the system (use the default target) the snapshot is merged back into your regular volume. All changes to the volume happened after the snapshot are undone.

Screen locking

  1. Install slock.
$ yay -S slock
  1. Create the following service /etc/systemd/system/[email protected] which turns off the monitor and locks the screen before suspend.
[Unit]
Description=Lock X session using slock for user %i
Before=sleep.target

[Service]
User=%i
Environment=DISPLAY=:0
ExecStartPre=/usr/bin/xset dpms force suspend
ExecStart=/usr/bin/slock

[Install]
WantedBy=sleep.target
  1. Enable for username user (change to your username).
$ sudo systemctl enable [email protected]

Note: If you want patches, download and install slock by hand using sudo make install. Before installation, change user and group in config.def.h to nobody. Patches can be applied using patch -p1 < patch -p1 < path/to/patch.diff. Do not forget to remove config.h when patching.

NVIDIA Docker

For gpu support install nvidia-docker. Currently working method is to install nvidia-container-toolkit.

$ yay -S nvidia-container-toolkit
$ sudo systemctl restart docker

Verify correct installation of nvidia-container-toolkit by running a base CUDA container.

$ docker run --rm --gpus all nvidia/cuda:11.0-base nvidia-smi

This should result in a similar console output.

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 450.51.06    Driver Version: 450.51.06    CUDA Version: 11.0     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  Tesla T4            On   | 00000000:00:1E.0 Off |                    0 |
| N/A   34C    P8     9W /  70W |      0MiB / 15109MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+

After successful verification you can remove the CUDA image.

$ docker rmi nvidia/cuda:11.0-base

nvidia-container-toolkit cgroups v2 support

Cgroups v2 is the default as of systemd v248, but nvidia-container doesn't support it yet [1, 2]. To make GPU support work, you have to force using of cgroups v1 instead of v2.

To do this, add systemd.unified_cgroup_hierarchy=0 kernel command line parameter to /etc/default/grub.

/etc/default/grub

GRUB_CMDLINE_LINUX_DEFAULT="... systemd.unified_cgroup_hierarchy=0"

Don't forget to regenerate grub config /boot/grub/grub.cfg using grub-mkconfig.

$ grub-mkconfig -o /boot/grub/grub.cfg

Printing

  1. Install cups package.
$ yay -S cups
  1. Enable org.cups.cupsd.socket.
$ sudo systemctl enable --now org.cups.cupsd.socker
  1. Install printer drivers.
# For HP install hplip and setup a printer
$ yay -S hplip
$ hp-setup -i

Scanning

  1. Install sane package with drivers.
$ yay -S sane sane airscan ipp-usb
  1. Enable and start ipp-usb.service to allow using IPP protocol over USB connection.
$ sudo systemctl enable --now ipp-usb.service
  1. Install hplip-plugin for HP scanner support.
$ yay -S hplip-plugin
  1. Check whether sane recognizes scanner.
$ scanimage -L

Scanner should be in the output.

device `v4l:/dev/video0' is a Noname Integrated_Webcam_HD: Integrate virtual device
device `hpaio:/usb/HP_LaserJet_MFP_M129-M134?serial=VNFYY50649' is a Hewlett-Packard HP_LaserJet_MFP_M129-M134 all-in-one
  1. Install Simple Scan frontend.
$ yay -S simple-scan

Electronic ID in Slovakia

  1. Install required packages (eID client, web signer, IcedTea, and Java).

    $ yay -S eidklient disig-web-signer icedtea-web jre8-openjdk jre8-openjdk-headless java8-openjfx java11-openjfs
  2. Download and install D.Launcher.

    $ wget https://www.slovensko.sk/static/zep/apps/DLauncher.linux.x86_64.zip
    $ unzip DLauncher.linux.x86_64.zip
    $ chmod +x DLauncher.linux.x86_64.run
    $ ./DLauncher.linux.x86_64.run
  3. Enable and start pcscd service to access the built in card reader.

    $ sudo systemctl enable --now pcscd.service
  4. Start eID client via EAC_MW_klient.

References

Logical volume (LV) extending by adding a new physical volume (PV)

The extendind consists of these steps:

  1. Create a new LVM partition using fdisk.

  2. Add a new PV for the created LVM partition.

  3. Extend VG and LV.

Create a new partition for LVM

  1. Use fdisk for the appropriate device.

    # fdisk /dev/sdX
  2. Press n to add a new partition.

  3. If prompted, specify the partition type, type p to create a primary partition or e to create an extended one. There may be up to four primary partitions.

  4. Press Enter to select default partition number (e.g. 1 so the full path is /dev/sdX1).

  5. Press Enter to select default starting sector.

  6. Press Enter to select default ending sector or use the + symbol to specify a position relative to the start sector measured in sectors, kibibytes (K), mebibytes (M), gibibytes (G), tebibytes (T), or pebibytes (P); for instance, setting +2G as the last sector will specify a point 2GiB after the start sector.

  7. Type 43 (Linux LVM) as the partition's type id. If not promted, press t to change a partition type, then press Enter to select default (latest) partition number and then type 30 as the partition type.

  8. Press w to write table to disk and exit.

  9. Check out whether the partition was created successfuly.

    $ lsblk

Add a new PV for the created LVM partition

  1. Check out existing physical volumes.

    # pvs
  2. Create a new PV for the created LVM partition (adjust the partition path).

    # pvcreate /dev/sdX1
  3. Check out whether the physical volume was created successfuly.

    # pvs

Extend VG and LV

  1. Find out the name of the VG that will be extented (LV is in VG that will be extended).

    # lvs
  2. Extend the appropriate VG with the created PV.

    # vgextend <VG-name> /dev/sdX1
  3. Check out whether the VG was extended successfuly.

    # vgs
  4. Extend the approriate LV by the appropriate size (e.g. 5G).

    # lvextend -L +5G /dev/<VG-name>/<LV-name>
  5. Check out whether the LV was extented successfuly.

    $ lsblk
    # pvs
    # vgs
    # lvs
  6. Resize the file system.

    # resize2fs /dev/<VG-name>/<LV-name>
  7. Check out whether the file system was resized successfuly.

    $ df -h

Install daily application

File managers

vifm as vi file manager (also install ueberzug for image preview)

thunar, as GUI file manager

* `thunar-archive-plugin`
* `tumbler` as a photo thumbnails generator
* `ffmpegthumbnailer` as a video thumbnails generaator

Media

spotify as a digital music streaming service

sxiv as a simple X image viewer

mpv as a media player

playerctl as a media players controller

Media editors

gimp as image manipulation program

Office tools

libreoffice-fresh as a office suite

Communication tools

thunderbird as a e-mail client

pidgin as a XMPP client

slack-desktop as team communicator

whatsapp-for-linux as WhatsApp

Archive tools

zip as zip archive tool

rar as rar archive tool

xarchiver as GTK+ front end for managing archives

Terminal stuff

neofetch as a command-line system information tool

cmatrix as Matrix

bat, bat-extras, prettier as a cat clone with wings (prettier is needed for prettybat)

fzf as a command-line fuzzy finder

cht.sh-git as the only cheat sheet you need

ncdu as a command-line disk usage manager

VPNs

openvpn, networkmanager-openvpn as a OpenVPN client

Other tools

arandr as visual front end for XRandR

zathura, zathura-pdf-mupdf as PDF viewer

prismatik-psieg as control to Lightpack devices (ambilight control)

⚠️ **GitHub.com Fallback** ⚠️