Arch Linux Notes
Table of Contents
- Resources
- Setup install USB Drive
- Connect to Internet
- Time
- Disks
- Pacstrap
- Generate fstab
- Chroot
- Timezone
- Locale
- Networking
- Initramfs
- Password
- Microcode
- Boot Manager
- Enabling Services
- Rebooting
- Join wifi
- User accounts
- Caps Lock Control
- Basic Packages
- Serial Communication
- X Windows
- Sound
- Laptop Media Keys
- Populate and refresh pacman keys
- Printing
- OpenTTD and MIDI
- Building Emacs
- XFCE4
Resources
Setup install USB Drive
- Obtain the latest archlinux iso and verify it downloaded correctly
- Use dd to write the image to the removable drive
dd bs=4M if=path/to/archlinux-version-x86_64.iso of=/dev/<YOUR_USB_DRIVE> conv=fsync oflag=direct status=progress
Connect to Internet
WiFi
- Use
iwctlto connect to a wifi network - Type
helpto see various examples of how to use iwctl station wlan0 connect <NAME_OF_NETWORK>- Enter the password at the prompt
- If it connected you can exit iwctl
Time
- Set the clock to use ntp
timedatectl set-ntp true
Disks
Partitioning
TODO MBR
UEFI
- Verify you booted in UEFI mode
ls /sys/firmware/efi/efivars - If you are able to run the above without errors then you are in uefi mode
- Use
lsblkto view the detected harddrives - Parition the main drive with
gdisk /dev/<YOUR_MAIN_DRIVE> - Delete any existing paritions
- Create a 512MB partition with code EF00
- Create a parition with the remaining space with code 8300
- Write the changes to disk
Formatting
Full Disk Encryption
- Run
lsblkagain to see the new partition numbers - Run cryptsetup on the main linux parition
cryptsetup luksFormat /dev/<MAIN_DRIVE_LINUX> - Open the encrypted partition as cryptroot
cryptsetup open /dev/<MAIN_DRIVE_LINUX> cryptroot - Format cryptroot with ext4
mkfs.ext4 /dev/mapper/cryptroot - Mount cryptroot to /mnt
mount /dev/mapper/cryptroot /mnt
TODO Unencrypted
EFI System Partition
- Run
mkfs.fat -F32 /dev/<MAIN_DRIVE_EFI> - Make mount point
mkdir /mnt/boot - Mount the efi partition
mount /dev/<MAIN_DRIVE_EFI> /mnt/boot
Pacstrap
- Use pacstrap to download initial packages
pacstrap /mnt base base-devel linux linux-firmware dhcpcd iwd mg mailutils
Generate fstab
- Use genfstab to generate an fstab
genfstab -U /mnt >> /mnt/etc/fstab
Chroot
- Use the arch-chroot command to chroot into the new partition
arch-chroot /mnt
Timezone
- Symlink your timezone to /etc/localtime
ln -sf /usr/share/zoneinfo/America/Kentucky/Louisville /etc/localtime
Locale
- Edit /etc/locale.gen and uncomment your locale
- For example
mg /etc/locale.genand uncomenten_US.UTF-8 UTF-8 - Generate locale
locale-gen - Set the locale
localectl set-locale LANG=en_US.UTF-8 - Create a file
/etc/locale.confand set the contents toLANG=en_US.UTF-8
Networking
- Create the hostname file with your hostname
/etc/hostname - Edit the
/etc/hoststo like below
127.0.0.1 localhost ::1 localhost
Initramfs
- If you are using full disk encryption you need to update the initramfs
- Edit
/etc/mkinitcpio.conf - Edit the hooks to be like this
HOOKS=(base udev autodetect modconf block keyboard encrypt filesystems fsck) - Run
mkinitcpio -Pto generate the image
Password
- Run
passwdto set the root password
Microcode
- Install either
pacman -Sy intel-ucodeorpacman -Sy amd-ucodeif that applies
Boot Manager
- Run
bootctl installto install the systemd boot manager - Create a boot loader entry in
/boot/loader/entries/arch.confwith the below text - You can get the partition UUID (not PARTUUID) from
blkidand make sure you set the ucode to match your CPU type - Ensure that it is the partition UUID and not the
/dev/mapper/cryptrootone
title Arch Linux linux /vmlinuz-linux initrd /intel-ucode.img initrd /initramfs-linux.img options cryptdevice=UUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX:cryptroot root=/dev/mapper/cryptroot rw
- Edit the
/boot/loader/loader.confto use your new config
default arch.conf timeout 5 console-mode max editor no
- You can see if it worked by running
bootctl list
Enabling Services
- Enable iwd wifi service
systemctl enable iwd - Enable dhcpcd service
systemctl enable dhcpcd
Rebooting
- Exit the chroot environment
- Unmount the
/mnt/bootpartition and the/mntpartition - Run
rebootand test out the new install - Ensure that the computer doesn't try to boot the usb stick again
Join wifi
- If you need to join wifi you should be able to use
iwctlto communicate withiwd - From there it should be same as before
- For example,
station wlan0 connect <NAME_OF_NETWORK>
Wifi interface is not visible?
- If you are unable to see the wifi interface after rebooting try restarting the
iwdservice
User accounts
- You should create a user outside of the root user on the machine
- Run
useradd -m -G wheel,uucp <USER_NAME>to create a new user - Run
passwd <USER_NAME>to set that new user's password - Install sudo if you haven't already
pacman -Sy sudo - Set the EDITOR environment variable and run visudo
export EDITOR=mg && visudo - From here uncomment the line that mentions the wheel group
- After this you should be able to log in as the newly created user and run sudo commands
Caps Lock Control
- Make the directory for keymaps
sudo mkdir -p /usr/local/share/kbd/keymaps - Create a file named
/usr/local/share/kbd/keymaps/personal.map(you might need to create any missing directories) - Give it the contents below
keymaps 0-127 keycode 58 = Control
- Edit
/etc/vconsole.confand set its contents to the followingKEYMAP=/usr/local/share/kbd/keymaps/personal.map - After the next reboot the caps lock key should be an extra control inside the console
Basic Packages
pacman -Sy emacs man man-pages tmux ncdu fzf mosh rsync pass pass-otp curl wget gnupg git cronie cdparanoia abcde beets python-pip ctags aspell aspell-en htop unzip zip pv nethack sshfs p7zip zbar ledger
- Don't forget to enable cronie
systemctl enable cronie.service
Serial Communication
- Install picocom
sudo pacman -Sy picocom - Plug in you USB serial device and try it out
- For example,
picocom -b 115200 /dev/ttyUSB0 - To find the serial device you can run dmesg and grep the output for tty
sudo dmesg | grep tty - I do not recommend running picocom inside eshell, ansi-term is a better choice
- Use
C-a C-xto exit picocom when you are done, if inside of emacs you might need to typeC-xtwice - If you have issues with permissions ensure your user is in the
uucpgroup with the commandgroups
X Windows
- Install xorg with
sudo pacman -Sy xorg-server xorg-apps xorg-xinit - Install the right graphics driver
sudo pacman -Sy xf86-video-{amdgpu, ati, intel, nouveau} - Proprietary nvidia drivers are installed with
sudo pacman -Sy nvidia - Based on you graphics driver you might also need to install mesa
sudo pacman -Sy mesa - Install git
sudo pacman -Sy git - Clone dwm
mkdir ~/src && cd ~/src && git clone https://git.suckless.org/dwm - Build and install dwm
cd ~/src/dwm && sudo make install - Clone dmenu
cd ~/src && git clone https://git.suckless.org/dmenu - Build and install dmenu
cd ~/src/dmenu && sudo make install - Clone slstatus
cd ~/src && git clone https://git.suckless.org/slstatus - Build and install slstatus
cd ~/src/slstatus && sudo make install - Create an .xinitrc in your homedir and set dwm and start dwm in it
- Test out x by running
startxfrom the terminal - Install lightdm and the gtk greeter
sudo pacman -Sy lightdm lightdm-gtk-greeter - Edit the
/etc/lightdm/lightdm.confand uncomment greeter-session and set it tolightdm-gtk-greeter - Enable lightdm
sudo systemctl enable lightdm - Create
/usr/share/xsessions/dwm.desktopand use the below code
[Desktop Entry] Name=dwm Comment=Login using dwm Exec=/usr/local/bin/dwm TryExec=/usr/local/bin/dwm Type=Application
Packages
sudo pacman -Sy xterm firefox arandr pavucontrol xlockmore xss-lock ttf-hack noto-fonts noto-fonts-cjk noto-fonts-emoji noto-fonts-extra terminus-font xorg-xbacklight pamixer mpv redshift thunar zathura zathura-pdf-mupdf zathura-cb xorg-fonts xorg-fonts-100dpi xorg-fonts-75dpi xorg-fonts-misc xorg-fonts-type1 xorg-fonts-cyrillic vlc kitty imagemagick feh mupdf mupdf-tools libmupdf ghostscript texlive-most
- Start lightdm to confirm its working
sudo systemctl start lightdm
Sound
- Install
pipewire pipewire-docs pipewire-pulse - You might need to restart for the the service to be started properly
Bluetooth Audio
- Install
bluez bluez-utils - Enable bluetooth service
bluetooth.service - Run
bluetoothctland follow the below example
power on agent on default-agent scan on # Find the address of the device you want to connect to # Ensure the device you want to connect to is in pairing mode pair <ADDRESS> connect <ADDRESS> trust <ADDRESS> # this is for auto connecting scan off exit
- After a reboot you might need to manually power on bluetooth and set the agent
power on agent on default-agent
Laptop Media Keys
- Install dunst for desktop notifications
sudo pacman -Sy libnotify dunst - There are various util commands that make it easy to bind to keys in dwm in the utils.org
Populate and refresh pacman keys
- Sometimes package signatures are out of date
- To update them run
sudo pacman-key --populateandsudo pacman-key --refresh-keys
Printing
- ArchWiki
- Install
cups - Enable cups
sudo systemctl enable --now cups - For network printing install
nss-mdnsandavahiand enabled avahisudo systemct enable --now avahi-daemon - Add
mdns_minimal [NOTFOUND=return]to the file/etc/nsswitch.confafter themymachinesand beforeresolveanddns - Use
lpinfo -vto see a list of printer URIs - Use
lpadminto add a printer queue, for examplelpadmin -p <PRINTER_QUEUE_NAME> -E -v "ipp://URL" -m everywhere - Use
lpoptions -d <PRINTER_QUEUE_NAME>to make the printer default - Enable the printer with
cupsenable <PRINT_QUEUE_NAME> - Set the printer to accept jobs
cupsaccept <PRINT_QUEUE_NAME> - To print a test page use
lpr /usr/share/cups/data/testprint - To print a file use
lpr <SOME_FILE>orlpr -# <NUMBER_OF_COPIES> <SOME_FILE> - cups has a web UI acceptable here http://localhost:631/
OpenTTD and MIDI
- Install OpenTTD packages:
openttd,openttd-opensfx,openttd-opengfx - In order to hear music you need to download some music from the online updater in the game
- Install the
soundfont-fluidin order to hear the music from the game
Building Emacs
- clone emacs from savannah
git clone -b master git://git.sv.gnu.org/emacs.git - Releases are usually in a branch with the version number, for example
emacs-28 - Run the
./autogen.shto build the configure script - Use this command to configure with native compilation
./configure --with-native-compilation - On Arch Linux you might need to grab
libgccjitfrom AURmkdir ~/aur && git clone https://aur.archlinux.org/libgccjit.git && cd ~/aur/libgccjit && makepkg -si - This will warn you about any missing dependencies, from there you should obtain them for your OS
- Build emacs with
make -j <NUMBER_OF_CPU_CORES+1> - Run
make installwith appropriate permissions to install the new version on the system - Use
M-x emacs-version RETto see the current version info, including the build date
XFCE4
- ArchWiki: XFCE4
- Install
xfce4andxfce4-goodies