Skip to content

Instantly share code, notes, and snippets.

@gustavohenrique
Last active April 14, 2023 23:23
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save gustavohenrique/78b49b70e6401caf273e1ba941238baa to your computer and use it in GitHub Desktop.
Save gustavohenrique/78b49b70e6401caf273e1ba941238baa to your computer and use it in GitHub Desktop.
Arch Linux installation and setup

Installation

loadkeys us-acentos

Network

Wireless connection

pacman -S linux-lts-headers broadcom-wl-dkms

cat > /etc/modprobe.d/blacklist-b43.conf <<EOF
blacklist b43
blacklist b43legacy
blacklist ssb
blacklist bcm43xx
blacklist brcm80211
blacklist brcmfmac
blacklist brcmsmac
blacklist bcma
EOF

modprobe -r b43
modprobe -r wl
modprobe wl

ip link set wlan0 up
iw dev wlan0 scan | less
wpa_supplicant -B -i wlan0 -c <(wpa_passphrase MYSSID "password")
# or wpa_passphrase MYSSID passphrase > /etc/wpa_supplicant/MYSSD.conf
timedatectl set-ntp true

Wired connection

ip a add 192.168.100.2/24 dev enp1s0
ip link set enp1s0 up
ip r add default via 192.168.100.1
echo "nameserver 8.8.8.8" > /etc/resolv.conf

Partitioning

Single boot (GPT)

  • /dev/sda1: vfat 512MB
  • /dev/sda2: ext4
mkfs.fat -F32 /dev/sda1
mkfs.ext4 /dev/sda2
mount /dev/sda2 /mnt
mkdir /mnt/boot
mount /dev/sda1 /mnt/boot

Installation

pacstrap /mnt base linux-firmware linux-lts
arch-chroot /mnt

Base config

ln -sf /usr/share/zoneinfo/America/Sao_Paulo /etc/localtime
hwclock --systohc

echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
echo "pt_BR.UTF-8 UTF-8" >> /etc/locale.gen
locale-gen

cat > /etc/locale.conf <<EOF
LANG=C
LC_NUMERIC=en_US.UTF-8
LC_TIME=en_US.UTF-8
LC_MONETARY=en_US.UTF-8
LC_PAPER=en_US.UTF-8
LC_MEASUREMENT=en_US.UTF-8
EOF

echo KEYMAP=us-acentos >> /etc/vconsole.conf

echo air > /etc/hostname
cat > /etc/hosts <<EOF
127.0.0.1  localhost air
::1        localhost
EOF

Root password:

passwd

GPT (UEFI)

# arch-chroot /mnt
mkdir /esp
mount /dev/sda1 /esp
genfstab -U /mnt >> /mnt/etc/fstab

MBR

# /boot is another partition
mount /dev/sda2 /mnt
mkdir /mnt/boot
mount /dev/sda1 /mnt/boot

GRUB

pacman -S grub breeze-grub

// edit /etc/default/grub
GRUB_DEFAULT=saved
GRUB_TIMEOUT=2
GRUB_TIMEOUT_STYLE=menu
GRUB_DISTRIBUTOR='Arch Linux'
GRUB_CMDLINE_LINUX_DEFAULT="quiet resume=UUID=<uuid here>"
GRUB_CMDLINE_LINUX="acpi_osi=! acpi_osi=\"Windows 2009\""
# Nvidia video? GRUB_CMDLINE_LINUX="nouveau.modeset=0 acpi_osi=! acpi_osi=\"Windows 2009\""
GRUB_GFXMODE=1400x900,1280x960,1368x768,1280x1024,1024x768,auto
GRUB_DISABLE_RECOVERY=true
GRUB_COLOR_NORMAL="light-gray/black"
GRUB_COLOR_HIGHLIGHT="green/black"
GRUB_THEME="/usr/share/grub/themes/breeze/theme.txt"

Install GRUB

# grub-install --target=i386-pc /dev/sda  // without uefi

# dual boot UEFI
cat > /etc/grub.d/40_custom <<EOF
menuentry "Windows 10" {
  set root=(hd0,gpt1)
  chainloader (${root})/EFI/Microsoft/Boot/bootmgfw.efi
}
EOF
grub-install --target=x86_64-efi --efi-directory=/esp --bootloader-id=GRUB
grub-mkconfig -o /boot/grub/grub.cfg

Install Networking tools

pacman -S networkmanager net-tools iw

Post Installation

Move USA mirror to top of the file /etc/pacman.d/mirrorlist.
https://wiki.archlinux.org/index.php/Mirrors

Clock

Fixing Windows showing wrong time in a dual boot setup with Linux:

  • Make Windows use UTC time for the hardware clock
  • Make Linux use local time for the hardware clock
timedatectl set-local-rtc 1

Dotfiles

curl -sL http://dotfiles.gustavohenrique.com | bash

Network

More info: https://wiki.archlinux.org/index.php/Systemd-networkd#Basic_usage

systemctl enable NetworkManager

# Wired
cat > /etc/systemd/network/20-wired.network <<EOF
[Match]
Name=enp1s0

[Network]
DHCP=ipv4
EOF

# Wireless
nmcli device wifi list
nmcli device wifi connect MYSSID password 123456
# If SSID is hidden
# nmcli device wifi connect MYSSID password 123456 hidden yes
nmcli device
nmcli connection show
nmcli radio wifi off

Extra packages

pacman -S \
    base-devel \
    dhcpd \
    man-db \
    wireless_tools \
    wavemon \
    zsh \
    zip \
    unzip \
    unrar \
    alsa-utils \
    pulseaudio \
    pavucontrol \
    sudo \
    git \
    xsel \
    pyenv \
    docker \
    tmux \
    tilix \
    gdmap \
    firefox \
    chromium \
    vlc \
    mplayer \
    ffmpeg \
    bind \
    xorg xorg-drivers xorg-server-devel xterm xorg-xrandr mesa

# codecs & themes
pacman -S \
    a52dec \
    faac \
    faad2 \
    flac \
    jasper \
    lame \
    libdca \
    libdv \
    libmad \
    libmpeg2 \
    libtheora \
    libvorbis \
    libxv \
    wavpack \
    x264 \
    xvidcore \
    libgtop \
    faenza-icon-theme

# qemu
sudo pacman -S qemu qemu-headless qemu-guest-agent qemu-arch-extra qemu-headless-arch-extra

# gnome
pacman -S
    gnome \
    gnome-tweaks \
    alacarte \
    dconf-editor \
    gitg \
    gnome-icon-theme \
    gnome-icon-theme-extras \
    gnome-keyring \
    arc-gtk-theme arc-solid-gtk-theme materia-gtk-theme

# xfce4
pacman -S xfce4 xfce4-goodies && systemctl --user enable pulseaudio

# cinnamon
pacman -S
    cinnamon \
    nemo-fileroller \
    gnome-keyring \
    lightdm lightdm-gtk-greeter lightdm-gtk-greeter-settings ukui-greeter

User account

Create user account

useradd -d /home/gustavo -s /bin/zsh -u 1000 -g 1000 -G audio,video,docker,wheel,kvm,storage,games,log,users,systemd-journal,polkitd -p 123456 gustavo
mkdir /home/gustavo
chmod 710 /home/gustavo
chown gustavo:gustavo /home/gustavo

Sudo

cp /usr/share/doc/sudo/examples/sudoers /etc
EDITOR=vim visudo

Encrypt home

pacman -S ecryptfs-utils rsync lsof
modprobe ecryptfs
echo ecryptfs > /etc/modules-load.d/ecryptfs.conf
ecryptfs-migrate-home -u gustavo

su gustavo
ecryptfs-unwrap-passphrase
ecryptfs-mount-private

Fix Cedilla

cat /etc/environment
GTK_IM_MODULE=cedilla
QT_IM_MODULE=cedilla

# Add en to line's end
cat /usr/lib/gtk-3.0/3.0.0/immodules.cache
"/usr/lib/gtk-3.0/3.0.0/immodules/im-cedilla.so"
"cedilla" "Cedilla" "gtk30" "/usr/share/locale" "az:ca:co:fr:gv:oc:pt:sq:tr:wa:en"

To work in the terminal:

sudo sed -i 's/Ć/Ç/g' /usr/share/X11/locale/en_US.UTF-8/Compose
sudo sed -i 's/ć/ç/g' /usr/share/X11/locale/en_US.UTF-8/Compose

Graphical Interface

Wayland

Boot in text mode and starts manually the X (Wayland + Gnome)

alias gno='XDG_SESSION_TYPE=wayland dbus-run-session gnome-session'

Xorg

Force GDM to use Xorg:

vim /etc/gdm/custom.conf
WaylandEnable=false

NVIDIA

Using optimus to disable i915 and use only GeForce GTX 1050 Ti.

pacman -S  nvidia nvidia-utils nvidia-settings opencl-nvidia
echo "blacklist nouveau" > /lib/modprobe.d/nvidia.conf

cat > /etc/X11/xorg.conf <<EOF
Section "ServerLayout"
    Identifier     "layout"
    Screen         0  "nvidia"
    Inactive       "intel"
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"
EndSection

Section "Files"
EndSection

Section "InputDevice"
    Identifier     "Mouse0"
    Driver         "mouse"
    Option         "Protocol" "auto"
    Option         "Device" "/dev/psaux"
    Option         "Emulate3Buttons" "no"
    Option         "ZAxisMapping" "4 5"
EndSection

Section "InputDevice"
    Identifier     "Keyboard0"
    Driver         "kbd"
EndSection

Section "Monitor"
    Identifier     "Monitor0"
    VendorName     "Unknown"
    ModelName      "Unknown"
    Option         "DPMS"
EndSection

Section "Device"
    Identifier  "intel"
	#Driver      "intel"
	Driver      "modesetting"
	BusID       "PCI:0:2:0"  # lspci | grep -i vga
EndSection

Section "Screen"
	Identifier "intel"
	Device     "intel"
	Monitor    "Monitor0"
	DefaultDepth    24
	SubSection     "Display"
		Depth       24
	EndSubSection
EndSection

Section "Device"
    Identifier  "nvidia"
	Driver      "nvidia"
	BusID       "PCI:1:0:0"  # lspci | grep -i 3d
	VendorName  "NVIDIA Corporation"
	BoardName   "GeForce GTX 1050 Ti"
EndSection

Section "Screen"
	Identifier  "nvidia"
	Device      "nvidia"
	Monitor     "Monitor0"
	#Option     "AllowIndirectGLXProtocol" "off"
	#Option     "TripleBuffer" "on"
	Option      "AllowEmptyInitialConfiguration" "on"
	DefaultDepth    24
	SubSection     "Display"
		Depth       24
	EndSubSection
EndSection
EOF

cat > /etc/X11/xorg.conf.d/10-nvidia-drm-outputclass.conf <<EOF
Section "OutputClass"
    Identifier "intel"
    MatchDriver "i915"
    Driver "modesetting"
EndSection

Section "OutputClass"
    Identifier "nvidia"
    MatchDriver "nvidia-drm"
    Driver "nvidia"
    Option "AllowEmptyInitialConfiguration"
    Option "PrimaryGPU" "yes"
    ModulePath "/usr/lib/nvidia/xorg"
    ModulePath "/usr/lib/xorg/modules"
EndSection
EOF

cat > /usr/share/gdm/greeter/autostart/optimus.desktop <<EOF
[Desktop Entry]
Type=Application
Name=Optimus
Exec=sh -c "xrandr --setprovideroutputsource modesetting NVIDIA-0; xrandr --auto"
NoDisplay=true
X-GNOME-Autostart-Phase=DisplayServer
EOF

cp /usr/share/gdm/greeter/autostart/optimus.desktop /etc/xdg/autostart


glxinfo | grep NVIDIA
server glx vendor string: NVIDIA Corporation
client glx vendor string: NVIDIA Corporation

glxgears
96447 frames in 5.0 seconds = 19289.375 FPS
96896 frames in 5.0 seconds = 19379.127 FPS
97257 frames in 5.0 seconds = 19451.389 FPS
97054 frames in 5.0 seconds = 19410.719 FPS

See more: https://wiki.archlinux.org/index.php/NVIDIA_Optimus#Use_NVIDIA_graphics_only

Extra configuration

Fonts

Install the fonts that look similar or better than the ones on macOS.

cd /tmp
git clone https://aur.archlinux.org/ttf-vista-fonts.git
cd ttf-vista-fonts && makepkg -si && cd ..
git clone https://aur.archlinux.org/ttf-ms-fonts.git
cd ttf-ms-fonts && makepkg -si

sudo pacman -S tex-gyre-fonts noto-fonts-emoji
  • sans-serif: tex-gyre-fonts, free alternative to Helvetica and Arial and looks really really similar
  • serif: Libertinus Serif, suprisingly looks really great
  • monospace: DM Mono from Google Fonts, for monospace fonts that look great
  • emoji: noto-fonts-emoji, get some colorful emojis

If you are using chrome, you can do something more too.

Goto Settings
Select Customize Fonts under Appearences
Set Standard to Libertinus Serif
Set Serif to Libertinus Serif
Set Sans-serif to TeX Gyre Heros
Set Fixed-width to Monospace

More fonts and configuration can be found in my dotfiles repo.

Games

Multilib (for old games)

# Enable multilib in /etc/pacman.conf
sudo pacman -Syu
sudo pacman -S lib32-glibc lib32-gcc-libs lib32-clang lib32-freeglut lib32-glu lib32-libxcursor lib32-nvidia-utils

Gnome

gsettings set org.gnome.shell.app-switcher current-workspace-only true

LXD

cat > /etc/subuid <<EOF
root:1:1000000000
lxd:1:1000000000
EOF

cat > /etc/subgid <<EOF
root:1:1000000000
lxd:1:1000000000
EOF

cat >> /etc/pam.d/system-login <<EOF
session    optional   pam_cgfs.so -c freezer,memory,name=systemd,unified
EOF

/etc/lxc/default.conf
lxc.net.0.type = empty
lxc.idmap = u 0 100000 65536
lxc.idmap = g 0 100000 65536

pacman -S lxd
sudo systemctl enable lxd
sudo systemctl start lxd
sudo usermod -a -G lxd gustavo
lxd init

Profiles

X11

mkdir -p ~/Workspace/lxd
cd ~/Workspace/lxd
HOST_DISPLAY=`echo $DISPLAY | cut -d ':' -f2`  # 0 or 1

cat > x11.profile <<EOF
config:
  environment.DISPLAY: :0
  environment.PULSE_SERVER: unix:/home/ubuntu/pulse-native
  user.user-data: |
    #cloud-config
    runcmd:
      - 'sed -i "s/; enable-shm = yes/enable-shm = no/g" /etc/pulse/client.conf'
      - 'echo "DISPLAY=:0" >> /etc/environment'
    packages:
      - mesa-utils
      - pulseaudio
description: GUI LXD profile
devices:
  PASocket1:
    bind: container
    connect: unix:/run/user/1000/pulse/native
    listen: unix:/home/ubuntu/pulse-native
    security.gid: "1000"
    security.uid: "1000"
    uid: "1000"
    gid: "1000"
    mode: "0777"
    type: proxy
  X0:
    bind: container
    connect: unix:@/tmp/.X11-unix/X$HOST_DISPLAY
    listen: unix:@/tmp/.X11-unix/X0
    security.gid: "1000"
    security.uid: "1000"
    type: proxy
  mygpu:
    type: gpu
name: x11
EOF

lxc profile create x11
cat x11.profile | lxc profile edit x11
xhost +local:

Downloads

cat > downloads.profile <<EOF
name: downloads
config:
  security.idmap.isolated: true
  raw.idmap: |
    uid 1000 1000
    gid 1000 1000
description: ""
devices:
  downloads:
    path: /Downloads
    type: disk
    source: /home/gustavo/Downloads
    readonly: false
EOF

lxc profile create downloads
cat downloads.profile | lxc profile edit downloads

Running

lxc launch ubuntu:20.04 --profile default --profile x11 --profile downloads x11
lxc exec x11 apt update -y
lxc exec x11 apt install -y alsa-utils firefox mesa-utils libcanberra-gtk3-module libcanberra-gtk3-dev libcanberra-gtk-dev

# Running firefox
lxc exec x11 -- sudo -u ubuntu --login firefox

# Shortcut
cat > ~/.local/share/applications/lxd-firefox.desktop <<EOF
[Desktop Entry]
Version=1.0
Name=Firefox in LXD
Comment=Access the Internet through an LXD container
Exec=lxc exec x11 -- sudo --login --user ubuntu firefox %U
Icon=/usr/share/icons/HighContrast/48x48/apps/firefox.png
Type=Application
Categories=Internet
EOF

DroidCam

Install Droidcam via Google Play Store and get the droicam Linux client in https://www.dev47apps.com/droidcam/linux.
It requires Android Studio for USB connection instead of WiFi.

git clone --depth 1 https://aur.archlinux.org/mokutil.git
cd mokutil
makepkg -si
sudo pacman -S libappindicator-gtk3 linux-headers

Links

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment