til/install-archlinux.md

327 lines
6.2 KiB
Markdown
Raw Permalink Normal View History

2020-05-24 10:44:40 +00:00
# Install Arch Linux
2020-02-02 04:02:43 +00:00
2020-05-24 10:44:40 +00:00
Install Arch Linux is thing I always want to do for my laptop/PC since I had my laptop in ninth grade.
2020-02-02 04:02:43 +00:00
2021-04-28 08:44:21 +00:00
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.
2020-02-24 15:33:09 +00:00
2020-03-13 04:04:51 +00:00
## [Installation guide](https://wiki.archlinux.org/index.php/Installation_guide)
2020-02-02 04:02:43 +00:00
2021-04-02 11:10:49 +00:00
### Pre-installation
2020-05-20 09:14:22 +00:00
Check disks carefully:
2020-05-19 18:49:39 +00:00
```sh
lsblk
```
2021-04-02 11:10:49 +00:00
[USB flash installation medium](https://wiki.archlinux.org/index.php/USB_flash_installation_medium)
2021-04-02 11:07:14 +00:00
#### Verify the boot mode
2020-02-02 04:02:43 +00:00
2021-04-02 11:07:14 +00:00
Check UEFI mode:
```sh
ls /sys/firmware/efi/efivars
```
#### Connect to the internet
2020-02-02 04:02:43 +00:00
2022-12-20 17:56:32 +00:00
For wifi, use [iwd](https://wiki.archlinux.org/index.php/Iwd).
2020-02-02 04:02:43 +00:00
2021-04-02 11:07:14 +00:00
#### Partition the disks
2020-02-02 04:02:43 +00:00
2021-04-28 08:26:27 +00:00
[GPT fdisk](https://wiki.archlinux.org/index.php/GPT_fdisk):
2020-03-13 04:04:51 +00:00
```sh
2021-04-28 08:26:27 +00:00
cgdisk /dev/sdx
2020-03-13 04:04:51 +00:00
```
2021-04-27 04:00:35 +00:00
[Partition scheme](https://wiki.archlinux.org/index.php/Partitioning#Partition_scheme)
UEFI/GPT layout:
2021-04-28 08:46:45 +00:00
| Mount point | Partition | Partition type | Suggested size |
| ----------- | ------------------------------------- | ------------------------------ | -------------- |
| `/mnt/efi` | `/dev/efi_system_partition` | EFI System Partition | 512 MiB |
| `/mnt/boot` | `/dev/extended_boot_loader_partition` | Extended Boot Loader Partition | 1 GiB |
| `/mnt` | `/dev/root_partition` | Root Partition | |
2021-04-28 08:26:27 +00:00
BIOS/GPT layout:
2021-04-28 08:40:57 +00:00
| Mount point | Partition | Partition type | Suggested size |
| ----------- | --------------------- | ------------------- | -------------- |
| | | BIOS boot partition | 1 MiB |
| `/mnt` | `/dev/root_partition` | Root Partition | |
2020-03-28 14:38:17 +00:00
2021-11-04 18:17:21 +00:00
LVM:
```sh
# Create physical volumes
pvcreate /dev/sdaX
# Create volume groups
vgcreate RootGroup /dev/sdaX /dev/sdaY
# Create logical volumes
lvcreate -l +100%FREE RootGroup -n rootvol
```
2020-05-19 18:49:39 +00:00
Format:
```sh
2021-04-02 11:07:14 +00:00
# efi
mkfs.fat -F32 /dev/efi_system_partition
# boot
2021-04-28 08:46:45 +00:00
mkfs.fat -F32 /dev/extended_boot_loader_partition
2020-05-19 18:49:39 +00:00
2021-04-02 11:07:14 +00:00
# root
2021-04-21 11:50:36 +00:00
mkfs.ext4 -L ROOT /dev/root_partition
2021-11-04 18:17:21 +00:00
# root with btrfs
2021-04-21 11:50:36 +00:00
mkfs.btrfs -L ROOT /dev/root_partition
2021-11-04 18:17:21 +00:00
# root on lvm
mkfs.ext4 /dev/RootGroup/rootvol
2020-05-19 18:49:39 +00:00
```
2020-08-11 06:05:09 +00:00
Mount:
```sh
2021-04-02 11:07:14 +00:00
# root
mount /dev/root_partition /mnt
2021-11-04 18:17:21 +00:00
# root with btrfs
mount -o compress=zstd /dev/root_partition /mnt
2020-10-07 08:40:52 +00:00
2021-11-04 18:44:47 +00:00
# root on lvm
mount /dev/RootGroup/rootvol /mnt
2021-04-02 11:07:14 +00:00
# efi
2022-12-20 17:56:32 +00:00
mount --mkdir /dev/efi_system_partition /mnt/efi
2020-08-11 06:05:09 +00:00
2021-04-02 11:07:14 +00:00
# boot
2022-12-20 17:56:32 +00:00
mount --mkdir /dev/extended_boot_loader_partition /mnt/boot
2020-08-11 06:05:09 +00:00
```
2020-08-11 17:00:24 +00:00
### Installation
```sh
2022-12-20 17:56:32 +00:00
pacstrap -K /mnt base linux linux-firmware
2021-04-02 11:07:14 +00:00
2021-03-30 03:34:16 +00:00
# AMD
2022-12-20 17:56:32 +00:00
pacstrap -K /mnt amd-ucode
2021-02-13 06:45:01 +00:00
2021-03-30 03:34:16 +00:00
# Intel
2022-12-20 17:56:32 +00:00
pacstrap -K /mnt intel-ucode
2021-04-04 09:55:44 +00:00
2021-04-21 11:50:36 +00:00
# Btrfs
2022-12-20 17:56:32 +00:00
pacstrap -K /mnt btrfs-progs
2021-04-21 11:50:36 +00:00
2021-11-04 18:17:21 +00:00
# LVM
2022-12-20 17:56:32 +00:00
pacstrap -K /mnt lvm2
2021-11-04 18:17:21 +00:00
2021-04-21 11:50:36 +00:00
# Text editor
2022-12-20 17:56:32 +00:00
pacstrap -K /mnt neovim
2021-02-13 06:45:01 +00:00
```
2021-04-02 11:07:14 +00:00
### Configure
#### [fstab](https://wiki.archlinux.org/index.php/Fstab)
2021-04-02 11:07:14 +00:00
```sh
genfstab -U /mnt >> /mnt/etc/fstab
```
#### Chroot
```sh
arch-chroot /mnt
```
#### Time zone
```sh
ln -sf /usr/share/zoneinfo/Region/City /etc/localtime
hwclock --systohc
```
#### Localization:
Edit `/etc/locale.gen`:
```txt
2021-04-02 11:10:49 +00:00
# Uncomment en_US.UTF-8 UTF-8
2021-04-02 11:07:14 +00:00
```
Generate locales:
```sh
locale-gen
```
Edit `/etc/locale.conf`:
```txt
LANG=en_US.UTF-8
```
#### Network configuration
Edit `/etc/hostname`:
```txt
myhostname
```
2021-11-04 18:17:21 +00:00
#### Initramfs
Edit `/etc/mkinitcpio.conf`:
```txt
2022-12-20 17:56:32 +00:00
# LVM
2021-11-04 18:17:21 +00:00
# https://wiki.archlinux.org/title/Install_Arch_Linux_on_LVM#Adding_mkinitcpio_hooks
HOOKS=(base udev ... block lvm2 filesystems)
2021-11-04 19:09:22 +00:00
# https://wiki.archlinux.org/title/mkinitcpio#Common_hooks
# Replace udev with systemd
2021-11-04 18:17:21 +00:00
```
```sh
mkinitcpio -P
```
2021-04-02 11:07:14 +00:00
#### Root password
```sh
passwd
```
#### Addition
```sh
# NetworkManager
pacman -Syu networkmanager
systemctl enable NetworkManager.service
# Bluetooth
2021-05-20 16:18:42 +00:00
pacman -Syu bluez
systemctl enable bluetooth.service
# Clock
timedatectl set-ntp true
```
2021-04-02 11:07:14 +00:00
#### Boot loader
2020-03-13 04:04:51 +00:00
2020-08-11 17:00:24 +00:00
[systemd-boot](Applications/System/systemd-boot.md)
2020-03-13 04:04:51 +00:00
2021-04-28 08:26:27 +00:00
[GRUB](https://wiki.archlinux.org/index.php/GRUB)
2020-03-13 04:04:51 +00:00
## [General recommendations](https://wiki.archlinux.org/index.php/General_recommendations)
2020-02-02 04:02:43 +00:00
2020-03-28 14:38:17 +00:00
Always remember to check **dependencies** when install packages.
2020-02-23 17:54:34 +00:00
2020-03-13 04:04:51 +00:00
### System administration
2021-04-28 11:09:22 +00:00
[Sudo](https://wiki.archlinux.org/index.php/sudo):
2021-04-28 09:30:13 +00:00
```sh
pacman -Syu sudo
EDITOR=nvim visudo
# Uncomment group wheel
2021-12-19 16:19:20 +00:00
# Add user if don't want to use systemd-homed
useradd -m -G wheel -c "The Joker" joker
# Or using zsh
useradd -m -G wheel -s /usr/bin/zsh -c "The Joker" joker
# Set password
passwd joker
2021-04-28 09:30:13 +00:00
```
2022-12-20 17:56:32 +00:00
[systemd-homed (WIP)](https://wiki.archlinux.org/index.php/Systemd-homed):
2021-04-28 06:28:15 +00:00
```sh
systemctl enable systemd-homed.service
homectl create joker --real-name="The Joker" --member-of=wheel
2021-11-04 18:19:20 +00:00
# Using zsh
homectl update joker --shell=/usr/bin/zsh
2021-04-28 06:28:15 +00:00
```
2021-04-28 10:27:14 +00:00
**Note**:
Can not run `homectl` when install Arch Linux.
Should run on the first boot.
2021-04-28 08:40:57 +00:00
2020-08-11 17:00:24 +00:00
### Desktop Environment
2020-02-02 04:02:43 +00:00
2020-05-19 19:27:28 +00:00
Install [Xorg](https://wiki.archlinux.org/index.php/Xorg):
2020-02-02 04:02:43 +00:00
2020-05-19 19:27:28 +00:00
```sh
pacman -Syu xorg-server
```
2020-02-02 04:02:43 +00:00
2021-04-03 15:58:00 +00:00
#### [GNOME](https://wiki.archlinux.org/index.php/GNOME)
2020-02-02 04:02:43 +00:00
2021-02-13 06:17:05 +00:00
```sh
2021-04-21 04:29:08 +00:00
pacman -Syu gnome-shell \
2021-05-11 02:59:54 +00:00
gnome-control-center gnome-system-monitor \
2022-12-20 17:56:32 +00:00
gnome-tweaks gnome-backgrounds gnome-screenshot gnome-keyring gnome-logs \
gnome-console gnome-text-editor \
nautilus xdg-user-dirs-gtk file-roller evince eog
2021-02-13 06:17:05 +00:00
2021-04-03 15:58:00 +00:00
# Login manager
2021-05-11 02:59:54 +00:00
pacman -Syu gdm
2020-05-19 19:27:28 +00:00
systemctl enable gdm.service
2020-03-13 04:04:51 +00:00
```
2022-12-20 17:56:32 +00:00
#### [KDE (WIP)](https://wiki.archlinux.org/title/KDE)
2021-09-25 09:19:29 +00:00
```sh
pacman -Syu plasma-meta \
kde-system-meta
# Login manager
pacman -Syu sddm
systemctl enable sddm.service
```
2020-03-13 04:04:51 +00:00
## [List of applications](https://wiki.archlinux.org/index.php/List_of_applications)
2020-05-06 18:38:17 +00:00
### [pacman](https://wiki.archlinux.org/index.php/pacman)
2020-10-07 08:40:52 +00:00
Uncomment in `/etc/pacman.conf`:
2020-05-06 18:38:17 +00:00
```txt
# Misc options
Color
2021-09-01 17:36:46 +00:00
ParallelDownloads
2020-05-06 18:38:17 +00:00
```
2021-03-29 17:38:38 +00:00
## [Improving performance](https://wiki.archlinux.org/index.php/improving_performance)
https://wiki.archlinux.org/index.php/swap#Swap_file
2021-04-28 05:18:04 +00:00
https://wiki.archlinux.org/index.php/swap#Swappiness
2021-03-29 17:38:38 +00:00
2021-04-28 05:18:04 +00:00
https://wiki.archlinux.org/index.php/Systemd/Journal#Journal_size_limit
2021-03-29 17:38:38 +00:00
2021-04-28 05:18:04 +00:00
https://wiki.archlinux.org/index.php/Core_dump#Disabling_automatic_core_dumps
2021-03-29 18:00:18 +00:00
2021-04-28 05:18:04 +00:00
https://wiki.archlinux.org/index.php/Solid_state_drive#Periodic_TRIM
2021-03-29 17:38:38 +00:00
2021-04-28 05:18:04 +00:00
https://wiki.archlinux.org/index.php/Silent_boot
2021-04-04 17:45:58 +00:00
2021-11-04 19:13:57 +00:00
https://wiki.archlinux.org/title/Improving_performance#Watchdogs
2022-07-08 17:59:23 +00:00
https://wiki.archlinux.org/title/PRIME
2020-03-13 04:04:51 +00:00
## In the end
2020-02-04 13:19:22 +00:00
2020-03-28 14:38:17 +00:00
This guide is updated regularly I promise.