posts-go/docs/2022-12-25-archlinux.html

777 lines
24 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/5.2.0/github-markdown-dark.min.css"
/>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Inter&family=JetBrains+Mono&display=swap"
rel="stylesheet"
/>
<title>haunt98 posts</title>
</head>
<style>
.markdown-body {
box-sizing: border-box;
min-width: 200px;
max-width: 980px;
margin: 0 auto;
padding: 45px;
}
@media (max-width: 767px) {
.markdown-body {
padding: 15px;
}
}
.markdown-body {
font-family: "Inter", sans-serif;
}
.markdown-body code,
.markdown-body pre {
font-family: "JetBrains Mono", monospace;
}
</style>
<body class="markdown-body">
<div><a href="index.html">Index</a></div>
<h1>
<a
id="user-content-install-arch-linux"
class="anchor"
aria-hidden="true"
href="#install-arch-linux"
><span aria-hidden="true" class="octicon octicon-link"></span></a
>Install Arch Linux
</h1>
<p>
Install Arch Linux is thing I always want to do for my laptop/PC since I
had my laptop in ninth grade.
</p>
<p>
This is not a guide for everyone, this is just save for myself in a future
and for anyone who want to walk in my shoes.
</p>
<h2>
<a
id="user-content-installation-guide"
class="anchor"
aria-hidden="true"
href="#installation-guide"
><span aria-hidden="true" class="octicon octicon-link"></span></a
><a
href="https://wiki.archlinux.org/index.php/Installation_guide"
rel="nofollow"
>Installation guide</a
>
</h2>
<h3>
<a
id="user-content-pre-installation"
class="anchor"
aria-hidden="true"
href="#pre-installation"
><span aria-hidden="true" class="octicon octicon-link"></span></a
>Pre-installation
</h3>
<p>Check disks carefully:</p>
<div class="highlight highlight-source-shell"><pre>lsblk</pre></div>
<p>
<a
href="https://wiki.archlinux.org/index.php/USB_flash_installation_medium"
rel="nofollow"
>USB flash installation medium</a
>
</p>
<h4>
<a
id="user-content-verify-the-boot-mode"
class="anchor"
aria-hidden="true"
href="#verify-the-boot-mode"
><span aria-hidden="true" class="octicon octicon-link"></span></a
>Verify the boot mode
</h4>
<p>Check UEFI mode:</p>
<div class="highlight highlight-source-shell">
<pre>ls /sys/firmware/efi/efivars</pre>
</div>
<h4>
<a
id="user-content-connect-to-the-internet"
class="anchor"
aria-hidden="true"
href="#connect-to-the-internet"
><span aria-hidden="true" class="octicon octicon-link"></span></a
>Connect to the internet
</h4>
<p>
For wifi, use
<a href="https://wiki.archlinux.org/index.php/Iwd" rel="nofollow">iwd</a>.
</p>
<h4>
<a
id="user-content-partition-the-disks"
class="anchor"
aria-hidden="true"
href="#partition-the-disks"
><span aria-hidden="true" class="octicon octicon-link"></span></a
>Partition the disks
</h4>
<p>
<a href="https://wiki.archlinux.org/index.php/GPT_fdisk" rel="nofollow"
>GPT fdisk</a
>:
</p>
<div class="highlight highlight-source-shell">
<pre>cgdisk /dev/sdx</pre>
</div>
<p>
<a
href="https://wiki.archlinux.org/index.php/Partitioning#Partition_scheme"
rel="nofollow"
>Partition scheme</a
>
</p>
<p>UEFI/GPT layout:</p>
<table>
<thead>
<tr>
<th>Mount point</th>
<th>Partition</th>
<th>Partition type</th>
<th>Suggested size</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>/mnt/efi</code></td>
<td><code>/dev/efi_system_partition</code></td>
<td>EFI System Partition</td>
<td>512 MiB</td>
</tr>
<tr>
<td><code>/mnt/boot</code></td>
<td><code>/dev/extended_boot_loader_partition</code></td>
<td>Extended Boot Loader Partition</td>
<td>1 GiB</td>
</tr>
<tr>
<td><code>/mnt</code></td>
<td><code>/dev/root_partition</code></td>
<td>Root Partition</td>
<td></td>
</tr>
</tbody>
</table>
<p>
Why not <code>/boot/efi</code>? See
<a
href="https://github.com/systemd/systemd/pull/3757#issuecomment-234290236"
>Lennart Poettering comment</a
>.
</p>
<p>BIOS/GPT layout:</p>
<table>
<thead>
<tr>
<th>Mount point</th>
<th>Partition</th>
<th>Partition type</th>
<th>Suggested size</th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td></td>
<td>BIOS boot partition</td>
<td>1 MiB</td>
</tr>
<tr>
<td><code>/mnt</code></td>
<td><code>/dev/root_partition</code></td>
<td>Root Partition</td>
<td></td>
</tr>
</tbody>
</table>
<p>LVM:</p>
<div class="highlight highlight-source-shell">
<pre><span class="pl-c"><span class="pl-c">#</span> Create physical volumes</span>
pvcreate /dev/sdaX
<span class="pl-c"><span class="pl-c">#</span> Create volume groups</span>
vgcreate RootGroup /dev/sdaX /dev/sdaY
<span class="pl-c"><span class="pl-c">#</span> Create logical volumes</span>
lvcreate -l +100%FREE RootGroup -n rootvol</pre>
</div>
<p>Format:</p>
<div class="highlight highlight-source-shell">
<pre><span class="pl-c"><span class="pl-c">#</span> efi</span>
mkfs.fat -F32 /dev/efi_system_partition
<span class="pl-c"><span class="pl-c">#</span> boot</span>
mkfs.fat -F32 /dev/extended_boot_loader_partition
<span class="pl-c"><span class="pl-c">#</span> root</span>
mkfs.ext4 -L ROOT /dev/root_partition
<span class="pl-c"><span class="pl-c">#</span> root with btrfs</span>
mkfs.btrfs -L ROOT /dev/root_partition
<span class="pl-c"><span class="pl-c">#</span> root on lvm</span>
mkfs.ext4 /dev/RootGroup/rootvol</pre>
</div>
<p>Mount:</p>
<div class="highlight highlight-source-shell">
<pre><span class="pl-c"><span class="pl-c">#</span> root</span>
mount /dev/root_partition /mnt
<span class="pl-c"><span class="pl-c">#</span> root with btrfs</span>
mount -o compress=zstd /dev/root_partition /mnt
<span class="pl-c"><span class="pl-c">#</span> root on lvm</span>
mount /dev/RootGroup/rootvol /mnt
<span class="pl-c"><span class="pl-c">#</span> efi</span>
mount --mkdir /dev/efi_system_partition /mnt/efi
<span class="pl-c"><span class="pl-c">#</span> boot</span>
mount --mkdir /dev/extended_boot_loader_partition /mnt/boot</pre>
</div>
<h3>
<a
id="user-content-installation"
class="anchor"
aria-hidden="true"
href="#installation"
><span aria-hidden="true" class="octicon octicon-link"></span></a
>Installation
</h3>
<div class="highlight highlight-source-shell">
<pre>pacstrap -K /mnt base linux linux-firmware
<span class="pl-c"><span class="pl-c">#</span> AMD</span>
pacstrap -K /mnt amd-ucode
<span class="pl-c"><span class="pl-c">#</span> Intel</span>
pacstrap -K /mnt intel-ucode
<span class="pl-c"><span class="pl-c">#</span> Btrfs</span>
pacstrap -K /mnt btrfs-progs
<span class="pl-c"><span class="pl-c">#</span> LVM</span>
pacstrap -K /mnt lvm2
<span class="pl-c"><span class="pl-c">#</span> Text editor</span>
pacstrap -K /mnt neovim</pre>
</div>
<h3>
<a
id="user-content-configure"
class="anchor"
aria-hidden="true"
href="#configure"
><span aria-hidden="true" class="octicon octicon-link"></span></a
>Configure
</h3>
<h4>
<a id="user-content-fstab" class="anchor" aria-hidden="true" href="#fstab"
><span aria-hidden="true" class="octicon octicon-link"></span></a
><a href="https://wiki.archlinux.org/index.php/Fstab" rel="nofollow"
>fstab</a
>
</h4>
<div class="highlight highlight-source-shell">
<pre>genfstab -U /mnt <span class="pl-k">&gt;&gt;</span> /mnt/etc/fstab</pre>
</div>
<h4>
<a
id="user-content-chroot"
class="anchor"
aria-hidden="true"
href="#chroot"
><span aria-hidden="true" class="octicon octicon-link"></span></a
>Chroot
</h4>
<div class="highlight highlight-source-shell">
<pre>arch-chroot /mnt</pre>
</div>
<h4>
<a
id="user-content-time-zone"
class="anchor"
aria-hidden="true"
href="#time-zone"
><span aria-hidden="true" class="octicon octicon-link"></span></a
>Time zone
</h4>
<div class="highlight highlight-source-shell">
<pre>
ln -sf /usr/share/zoneinfo/Region/City /etc/localtime
hwclock --systohc</pre
>
</div>
<h4>
<a
id="user-content-localization"
class="anchor"
aria-hidden="true"
href="#localization"
><span aria-hidden="true" class="octicon octicon-link"></span></a
>Localization:
</h4>
<p>Edit <code>/etc/locale.gen</code>:</p>
<div class="highlight highlight-text-adblock">
<pre><span class="pl-c"># Uncomment en_US.UTF-8 UTF-8</span></pre>
</div>
<p>Generate locales:</p>
<div class="highlight highlight-source-shell"><pre>locale-gen</pre></div>
<p>Edit <code>/etc/locale.conf</code>:</p>
<div class="highlight highlight-text-adblock">
<pre>LANG=en_US.UTF-8</pre>
</div>
<h4>
<a
id="user-content-network-configuration"
class="anchor"
aria-hidden="true"
href="#network-configuration"
><span aria-hidden="true" class="octicon octicon-link"></span></a
>Network configuration
</h4>
<p>Edit <code>/etc/hostname</code>:</p>
<div class="highlight highlight-text-adblock"><pre>myhostname</pre></div>
<h4>
<a
id="user-content-initramfs"
class="anchor"
aria-hidden="true"
href="#initramfs"
><span aria-hidden="true" class="octicon octicon-link"></span></a
>Initramfs
</h4>
<p>Edit <code>/etc/mkinitcpio.conf</code>:</p>
<div class="highlight highlight-text-adblock">
<pre><span class="pl-c"># LVM</span>
<span class="pl-c"># https://wiki.archlinux.org/title/Install_Arch_Linux_on_LVM#Adding_mkinitcpio_hooks</span>
HOOKS=(base udev ... block lvm2 filesystems)
<span class="pl-c"># https://wiki.archlinux.org/title/mkinitcpio#Common_hooks</span>
<span class="pl-c"># Replace udev with systemd</span></pre>
</div>
<div class="highlight highlight-source-shell"><pre>mkinitcpio -P</pre></div>
<h4>
<a
id="user-content-root-password"
class="anchor"
aria-hidden="true"
href="#root-password"
><span aria-hidden="true" class="octicon octicon-link"></span></a
>Root password
</h4>
<div class="highlight highlight-source-shell"><pre>passwd</pre></div>
<h4>
<a
id="user-content-addition"
class="anchor"
aria-hidden="true"
href="#addition"
><span aria-hidden="true" class="octicon octicon-link"></span></a
>Addition
</h4>
<h5>
<a
id="user-content-networkmanager-wip"
class="anchor"
aria-hidden="true"
href="#networkmanager-wip"
><span aria-hidden="true" class="octicon octicon-link"></span></a
><a href="https://wiki.archlinux.org/title/NetworkManager" rel="nofollow"
>NetworkManager (WIP)</a
>
</h5>
<div class="highlight highlight-source-shell">
<pre>pacman -Syu networkmanager dhcpcd iwd
systemctl <span class="pl-c1">enable</span> NetworkManager.service
systemctl <span class="pl-c1">enable</span> systemd-resolved.service</pre>
</div>
<p>Edit <code>/etc/NetworkManager/conf.d/dns.conf</code>:</p>
<div class="highlight highlight-text-adblock">
<pre>[<span class="pl-ii">main</span>]
dns=systemd-resolved</pre>
</div>
<p>Edit <code>/etc/NetworkManager/conf.d/dhcp-client.conf</code>:</p>
<div class="highlight highlight-text-adblock">
<pre>[<span class="pl-ii">main</span>]
dhcp=dhcpcd</pre>
</div>
<p>Edit <code>/etc/NetworkManager/conf.d/wifi_backend.conf</code>:</p>
<div class="highlight highlight-text-adblock">
<pre>[<span class="pl-ii">device</span>]
wifi.backend=iwd</pre>
</div>
<p>
See
<a href="https://wiki.archlinux.org/title/Dhcpcd" rel="nofollow"
>dhcpcd</a
>
</p>
<p>Append <code>/etc/dhcpcd.conf</code></p>
<div class="highlight highlight-text-adblock">
<pre>
noarp
nohook resolv.conf</pre
>
</div>
<h5>
<a
id="user-content-bluetooth"
class="anchor"
aria-hidden="true"
href="#bluetooth"
><span aria-hidden="true" class="octicon octicon-link"></span></a
>Bluetooth
</h5>
<div class="highlight highlight-source-shell">
<pre>pacman -Syu bluez
systemctl <span class="pl-c1">enable</span> bluetooth.service</pre>
</div>
<h5>
<a id="user-content-clock" class="anchor" aria-hidden="true" href="#clock"
><span aria-hidden="true" class="octicon octicon-link"></span></a
>Clock
</h5>
<div class="highlight highlight-source-shell">
<pre>timedatectl set-ntp <span class="pl-c1">true</span></pre>
</div>
<h4>
<a
id="user-content-boot-loader"
class="anchor"
aria-hidden="true"
href="#boot-loader"
><span aria-hidden="true" class="octicon octicon-link"></span></a
>Boot loader
</h4>
<h5>
<a
id="user-content-systemd-boot"
class="anchor"
aria-hidden="true"
href="#systemd-boot"
><span aria-hidden="true" class="octicon octicon-link"></span></a
><a
href="https://wiki.archlinux.org/index.php/Systemd-boot"
rel="nofollow"
>systemd-boot</a
>
</h5>
<p>Install using XBOOTLDR:</p>
<div class="highlight highlight-source-shell">
<pre>bootctl --esp-path=/efi --boot-path=/boot install
systemctl <span class="pl-c1">enable</span> systemd-boot-update.service</pre>
</div>
<p>
<a
href="https://wiki.archlinux.org/index.php/persistent_block_device_naming#by-label"
rel="nofollow"
>Label partition</a
>
</p>
<p>Edit <code>/efi/loader/loader.conf</code>:</p>
<div class="highlight highlight-text-adblock">
<pre>
default archlinux.conf
timeout 4
editor no
console-mode max</pre
>
</div>
<p>Edit <code>/boot/loader/entries/archlinux.conf</code>:</p>
<div class="highlight highlight-text-adblock">
<pre>title Arch Linux
linux /vmlinuz-linux
<span class="pl-c"># Intel</span>
initrd /intel-ucode.img
<span class="pl-c"># AMD</span>
initrd /amd-ucode.img
initrd /initramfs-linux.img
<span class="pl-c"># Kernel parameters</span>
<span class="pl-c">#</span>
<span class="pl-c"># Acer Nitro AN515-45</span>
<span class="pl-c"># https://wiki.archlinux.org/title/backlight#Kernel_command-line_options</span>
<span class="pl-c"># acpi_backlight=vendor</span>
<span class="pl-c">#</span>
<span class="pl-c"># NVIDIA</span>
<span class="pl-c"># https://wiki.archlinux.org/title/NVIDIA#DRM_kernel_mode_setting</span>
<span class="pl-c"># nvidia-drm.modeset=1</span>
options root="LABEL=ROOT" rw</pre>
</div>
<h2>
<a
id="user-content-general-recommendations"
class="anchor"
aria-hidden="true"
href="#general-recommendations"
><span aria-hidden="true" class="octicon octicon-link"></span></a
><a
href="https://wiki.archlinux.org/index.php/General_recommendations"
rel="nofollow"
>General recommendations</a
>
</h2>
<p>
Always remember to check <strong>dependencies</strong> when install
packages.
</p>
<h3>
<a
id="user-content-system-administration"
class="anchor"
aria-hidden="true"
href="#system-administration"
><span aria-hidden="true" class="octicon octicon-link"></span></a
>System administration
</h3>
<p>
<a href="https://wiki.archlinux.org/index.php/sudo" rel="nofollow">Sudo</a
>:
</p>
<div class="highlight highlight-source-shell">
<pre>pacman -Syu sudo
EDITOR=nvim visudo
<span class="pl-c"><span class="pl-c">#</span> Uncomment group wheel</span>
<span class="pl-c"><span class="pl-c">#</span> Add user if don't want to use systemd-homed</span>
useradd -m -G wheel -c <span class="pl-s"><span class="pl-pds">"</span>The Joker<span class="pl-pds">"</span></span> joker
<span class="pl-c"><span class="pl-c">#</span> Or using zsh</span>
useradd -m -G wheel -s /usr/bin/zsh -c <span class="pl-s"><span class="pl-pds">"</span>The Joker<span class="pl-pds">"</span></span> joker
<span class="pl-c"><span class="pl-c">#</span> Set password</span>
passwd joker</pre>
</div>
<p>
<a
href="https://wiki.archlinux.org/index.php/Systemd-homed"
rel="nofollow"
>systemd-homed (WIP)</a
>:
</p>
<div class="highlight highlight-source-shell">
<pre>systemctl <span class="pl-c1">enable</span> systemd-homed.service
homectl create joker --real-name=<span class="pl-s"><span class="pl-pds">"</span>The Joker<span class="pl-pds">"</span></span> --member-of=wheel
<span class="pl-c"><span class="pl-c">#</span> Using zsh</span>
homectl update joker --shell=/usr/bin/zsh</pre>
</div>
<p>
<strong>Note</strong>: Can not run <code>homectl</code> when install Arch
Linux. Should run on the first boot.
</p>
<h3>
<a
id="user-content-desktop-environment"
class="anchor"
aria-hidden="true"
href="#desktop-environment"
><span aria-hidden="true" class="octicon octicon-link"></span></a
>Desktop Environment
</h3>
<p>
Install
<a href="https://wiki.archlinux.org/index.php/Xorg" rel="nofollow">Xorg</a
>:
</p>
<div class="highlight highlight-source-shell">
<pre>pacman -Syu xorg-server</pre>
</div>
<h4>
<a id="user-content-gnome" class="anchor" aria-hidden="true" href="#gnome"
><span aria-hidden="true" class="octicon octicon-link"></span></a
><a href="https://wiki.archlinux.org/index.php/GNOME" rel="nofollow"
>GNOME</a
>
</h4>
<div class="highlight highlight-source-shell">
<pre>pacman -Syu gnome-shell \
gnome-control-center gnome-system-monitor power-profiles-daemon \
gnome-tweaks gnome-backgrounds gnome-firmware \
gnome-console gnome-text-editor \
nautilus xdg-user-dirs-gtk xdg-desktop-portal evince eog
<span class="pl-c"><span class="pl-c">#</span> Login manager</span>
pacman -Syu gdm
systemctl <span class="pl-c1">enable</span> gdm.service</pre>
</div>
<h2>
<a
id="user-content-list-of-applications"
class="anchor"
aria-hidden="true"
href="#list-of-applications"
><span aria-hidden="true" class="octicon octicon-link"></span></a
><a
href="https://wiki.archlinux.org/index.php/List_of_applications"
rel="nofollow"
>List of applications</a
>
</h2>
<h3>
<a
id="user-content-pacman"
class="anchor"
aria-hidden="true"
href="#pacman"
><span aria-hidden="true" class="octicon octicon-link"></span></a
><a href="https://wiki.archlinux.org/index.php/pacman" rel="nofollow"
>pacman</a
>
</h3>
<p>Uncomment in <code>/etc/pacman.conf</code>:</p>
<div class="highlight highlight-text-adblock">
<pre><span class="pl-c"># Misc options</span>
Color
ParallelDownloads</pre>
</div>
<h3>
<a
id="user-content-pipewire-wip"
class="anchor"
aria-hidden="true"
href="#pipewire-wip"
><span aria-hidden="true" class="octicon octicon-link"></span></a
><a href="https://wiki.archlinux.org/title/PipeWire" rel="nofollow"
>Pipewire (WIP)</a
>
</h3>
<div class="highlight highlight-source-shell">
<pre>
pacman -Syu pipewire wireplumber \
pipewire-alsa pipewire-pulse \
gst-plugin-pipewire pipewire-v4l2</pre
>
</div>
<p>
See
<a
href="https://wiki.archlinux.org/title/Advanced_Linux_Sound_Architecture"
rel="nofollow"
>Advanced Linux Sound Architecture</a
>
</p>
<div class="highlight highlight-source-shell">
<pre>pacman -Syu sof-firmware</pre>
</div>
<h3>
<a
id="user-content-flatpak-wip"
class="anchor"
aria-hidden="true"
href="#flatpak-wip"
><span aria-hidden="true" class="octicon octicon-link"></span></a
><a href="https://wiki.archlinux.org/title/Flatpak" rel="nofollow"
>Flatpak (WIP)</a
>
</h3>
<div class="highlight highlight-source-shell">
<pre>pacman -Syu flatpak</pre>
</div>
<h2>
<a
id="user-content-improving-performance"
class="anchor"
aria-hidden="true"
href="#improving-performance"
><span aria-hidden="true" class="octicon octicon-link"></span></a
><a
href="https://wiki.archlinux.org/index.php/improving_performance"
rel="nofollow"
>Improving performance</a
>
</h2>
<p>
<a
href="https://wiki.archlinux.org/index.php/swap#Swap_file"
rel="nofollow"
>https://wiki.archlinux.org/index.php/swap#Swap_file</a
>
</p>
<p>
<a
href="https://wiki.archlinux.org/index.php/swap#Swappiness"
rel="nofollow"
>https://wiki.archlinux.org/index.php/swap#Swappiness</a
>
</p>
<p>
<a
href="https://wiki.archlinux.org/index.php/Systemd/Journal#Journal_size_limit"
rel="nofollow"
>https://wiki.archlinux.org/index.php/Systemd/Journal#Journal_size_limit</a
>
</p>
<p>
<a
href="https://wiki.archlinux.org/index.php/Core_dump#Disabling_automatic_core_dumps"
rel="nofollow"
>https://wiki.archlinux.org/index.php/Core_dump#Disabling_automatic_core_dumps</a
>
</p>
<p>
<a
href="https://wiki.archlinux.org/index.php/Solid_state_drive#Periodic_TRIM"
rel="nofollow"
>https://wiki.archlinux.org/index.php/Solid_state_drive#Periodic_TRIM</a
>
</p>
<p>
<a href="https://wiki.archlinux.org/index.php/Silent_boot" rel="nofollow"
>https://wiki.archlinux.org/index.php/Silent_boot</a
>
</p>
<p>
<a
href="https://wiki.archlinux.org/title/Improving_performance#Watchdogs"
rel="nofollow"
>https://wiki.archlinux.org/title/Improving_performance#Watchdogs</a
>
</p>
<h2>
<a
id="user-content-in-the-end"
class="anchor"
aria-hidden="true"
href="#in-the-end"
><span aria-hidden="true" class="octicon octicon-link"></span></a
>In the end
</h2>
<p>This guide is updated regularly I promise.</p>
<div>
Feel free to ask me via
<a href="mailto:hauvipapro+posts@gmail.com">email</a> or
<a rel="me" href="https://hachyderm.io/@haunguyen">Mastodon</a>. Source
code is available on
<a href="https://github.com/haunt98/posts-go">GitHub</a>
</div>
</body>
</html>