Alexander Stephan All things Unix Enthusiast for various things including UNIX, keyboards & photography. Student at Technical University of Munich

Getting started with Arch Linux

Warranty Disclaimer:

I am not responsible for data loss, possible hardware failures, thermonuclear war, or you getting fired because your arch driven atomic plant failed.

If you have any concerns regarding the installation don’t hesitate to do some research on your own to prevent possible failures or bugs.

After booting the arch iso you’ll will have to proceed with the following steps:

Prerequisites:

sudo dd if=<path-to-image.iso> of=/dev/<name-of-usb> bs=4M status=progress
  • A BIOS that is capable of UEFI

Step 1: Prepare root file system

Temporarily load your preferred keyboard layout.

loadkeys de

Find out your block device name (-Sp makes it easier to recognize the drive).

lsblk -Sp

For quick formatting use parted, otherwise you can proceed using fdisk or gdisk.

Option 1:

parted
mkpart primary fat32 1MiB 261MiBi # Create EFI system partition
set 1 esp on
mkpart primary ext4 261MiB 100% # Use the rest as ext4

This command creates a primary GPT partition on your device and a 260MiB boot partition at the start sector that will later become the EFI partiton for UEFI boot. Then we use the rest of the drive for installing the system. Of course you can tweak these commands according to your specific needs.

Option 2:

Type in fdisk and navigate your way through the dialogs.

Now you can format both partitions you just created to your desired filesystem.

mkfs.vfat /dev/<devicename>1
mkfs.ext4 /dev/<devicename>2

Mount devices so we can install the base root system on our drive.

mkdir /mnt/boot/
mount /dev/<devicename>2 /mnt
mount /dev/<devicename>1 /mnt/boot/

Install the base system including developer tools and patches for Intel processors on target device.

pacstrap /mnt base base-devel intel-ucode

Generate fstab (contains all drives that will be mounted during booting).

genfstab -p /mnt > /mnt/etc/fstab

Step 2: Setup the new root system

arch-chroot /mnt

Now, as we moved to our new system, we can proceed to set all the basic parameters and settings. A good start is to set the host name:

echo myhost > /etc/hostname

Now we want to set our language. We do that by writing the LANG variable to /etc/locale.conf.

echo LANG=en_US.UTF-8 > /etc/locale.conf

Afterwards we want to uncomment the disired entry in /etc/locale.gen with the editor of your choice, so we can generate it in the next step with the following command:

locale-gen

Now we can set our keyboard layout. You can check your current layout with localectl status and to print all options use localectl list-keymaps.

echo KEYMAP=de-latin1 > /etc/vconsole.conf

In the next step we should set our time zone. To check out the current time zone use timedatectl status. To list all time zones use timedatectl list-timezones. Later we can install an NTP client that automatically syncs the clock over the network.

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

It’s also a good idea to rank the mirros, so we can have faster download speeds when installing software. You can either manually sort them or use Reflector. This command for example sorts the 5 most recent mirrors by download speed. If you want only mirrors for your specific country use -- country.

reflector --verbose --latest 50 --sort rate --protocol https --save /etc/pacman.d/mirrorlist

To continously refresh the mirrorlist we can create the file /etc/pacman.d/hooks/mirrorupgrade.hook.

[Trigger]
Operation = Upgrade
Type = Package
Target = pacman-mirrorlist

[Action]
Description = Updating pacman-mirrorlist with reflector and removing pacnew...
When = PostTransaction
Depends = reflector
Exec = /bin/sh -c "reflector --country 'United Germany' --latest 50 --age 24 --sort rate --save /etc/pacman.d/mirrorlist; rm -f /etc/pacman.d/mirrorlist.pacnew"

Now we should set up our local domains, so we can things like localhost.

reflector --verbose --latest 50 --sort rate --protocol https --save /etc/pacman.d/mirrorlist

Also for compabilities sake it’s a good idea to enable 32-bit libraries. Do that by uncommenting the[multilib] entry in /etc/pacman.conf. To refresh the mirrorlist use pacman -Sy.

A root password is always a good idea. Create one by using passwd.

Create an initramfs that loads programs very early in the userspace.

mkinitcpio -p linux

Now we need to install a boot loader. If you use UEFI you can do the following after installing it with pacman -S grub.

grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=grub
grub-mkconfig -o /boot/grub/grub.cfg

Now we can create a non-root user and add him to any group for example wheel and audio:

useradd -m -g users -s /bin/bash alex
gpasswd -a alex wheel audio

Automatically set the system time:

systemctl enable --now systemd-timesyncd.service

Step 3: Moving to a graphical envirement

Now, as we have a layed down a solid foundation for our system we can move on by installing a window manager or a desktop environment to finally feel at home. For better performance install a sufficient driver. The open source drivers are xf86-video-intel for Intel, xf86-video-amdgpu for AMD and finally xf86-video-nouveau for Nvidia users.

If you don’t rely on any X depenend software, I’d recommend you to give sway a try. Installing it via pacman will also install all important dependencies.

sudo pacman -S sway dmenu rxvt-unicode xorg-server-xwayland

You can start sway by adding it to the end of your ~/.bashrc.

For further customization please refer to my dotfiles repo.

I hope this was helpful!

Programming a GH60 on Linux

I recently wanted to update my keyboards layout and thought it was a good opportunity to come with a guide since many friends keep asking me how to flash their keyboard on Linux. In this case I am requiring an Atmel-based PCB as we’re using DFU-Programmer which is developed for Atmel-Microcontrollers. But there is a good chance, that you have one in your keyboard as well since they are the most popular manufacturer for micro controllers.

Install prerequisites:

sudo pacman -S python python-pip python-wxpython  dfu-programmer

First of all we need to come up with our layout, which we use easykeymap.sh from the EasyAVR package for. It also generates a .hex file which we later use for flashing. In order to run easykeymap.sh we need to clone the project from GitLab.

git clone https://gitlab.com/ChuckN408/EasyAVR.git && cd EasyAVR
sudo ./easykeymap.sh

Firstly you need to create a new layout file and select your board accordingly. In my case it’s a GH60. There is also an option that lets you roughly determine the keyboard layout. In my case I selected ISO here as it’s the standard here in Europe. Now you can either further modify your selected layout in easykeymapper itself or use one from an external source. For example you can generate layout files online by using the [keyboard-layout-editor(https://keyboard-layout-editor.com).

To map the keys select the key you want to remap and click on the white rectangle beneath the scan code in the context menu. Now a virtual keyboard assists you in finding the correct key. In order to use function layers, you need to define a key as Fn1, Fn0 will not work. If you finished your layout you can go ahead and save it now in .json format for later modifications.

Now you need to export the .hex file, that we will going to flash on to the keyboards microcontroller. To program your board you can either choose the “Build & Program” option or use dfu-programmer manually. I prefer the by hand method for security reasons since it doesn’t require you to open easykeymapper as root user. But keep in mind that you first need to put your board into boot mode by either pressing a reset button at the back of your PCB or use a predefined boot button.

The programming steps are as follows. If you’re board uses a different microntroller than the atmega32u4 simply replace the name. But keep in mind you need to use a second keyboard to enter the commands. Alternatively you can use a script as well.

Using the script:

wget https://gist.githubusercontent.com/alexanderstephan/655e9fc4ab07f268af271c4084c19fef/raw/bee744308b81e524557fde6ad2890ba4a74414da/gh60.sh -O gh60.sh
chmod +x gh60.sh
sudo ./gh60.sh

Or just do it manually, if you only do it once in a while.

dfu-programmer atmega32u4 erase --suppress-validation
dfu-programmer atmega32u4 flash <filename>.hex