arch_install.md (20624B)
1 Arch Linux Install with UEFI Boot 2 ================================= 3 4 This provides a basic rundown of the process of installing Arch Linux with the 5 following setup: 6 7 * UEFI boot 8 * Full-disk encryption 9 * Sway WM using Wayland 10 11 For a more thorough walkthrough of the install instructions, see the 12 [Installation guide][install_guide]. 13 14 This guide assumes a wired ethernet connection and a working DHCP server. 15 16 17 Create USB boot disk 18 -------------------- 19 20 Download an install image from https://www.archlinux.org/download/, then write 21 it to a disk using `dd`. Reboot the machine to be imaged and use the machine's 22 BIOS features to boot from the USB drive in UEFI mode. 23 24 25 Set up your install environment 26 ------------------------------- 27 28 Once booted, you'll be dropped to a root command prompt. We'll be doing our 29 install in English, but substituting any other language here will allow you to 30 follow the install steps in that language. Note that this only affects the 31 language used during the install process, and does _not_ affect the languages 32 of the installation. 33 34 # Set the desired keyboard layout; e.g. jp106. 35 # Full list in /usr/share/kbd/keymaps/**/*.map.gz 36 loadkeys us 37 38 # Generate localizations and set language. 39 # Uncomment desired language(s), e.g. en_CA.UTF-8. 40 vi /etc/locale.gen 41 locale-gen 42 export LANG=en_CA.UTF-8 43 44 Next we'll verify that the machine is booted in UEFI mode: 45 46 ls /sys/firmware/efivars 47 48 If the directory does not exist, the system is likely booted in BIOS mode. You 49 will want to enter the BIOS and enable UEFI boot. Then reboot from the USB 50 drive in UEFI mode. 51 52 53 Check internet connection 54 ------------------------- 55 56 This guide assumes a wired ethernet connection and a working DHCP server. To 57 verify your network interface is detected and enabled, run: 58 59 ip link 60 61 To check if you have a working connection, try: 62 63 ping archlinux.org 64 65 Assuming that's working, we'll set the system clock: 66 67 timedatectl set-ntp true 68 69 Then verify the service status: 70 71 timedatectl status 72 73 74 Prepare the disk 75 ---------------- 76 77 Next we'll partition and re-format the disk. The end result is that we'd like 78 to have two physical disk partitions -- an EFI boot partition and a main 79 partition which we'll manage via the Logical Volume Manager (lvm). 80 81 82 ### Partition the disk 83 84 To list the current disks and partitions: 85 86 fdisk -l 87 88 The following steps will assume that we're partitioning and formatting the disk 89 `/dev/sda`: 90 91 cgdisk /dev/sda 92 93 For UEFI boot on a 2 TB drive, we want something like: 94 95 sda1 512M type=ef00 /efi 96 sda2 1.9T type=8e00 / 97 98 99 ### Set up full-disk encryption 100 101 Optionally, we set up [LUKS full-disk encryption][luks_guide] on the main 102 partition. This can be skipped if not desired. 103 104 First, create a LUKS-encrypted container on the system partition: 105 106 cryptsetup luksFormat /dev/sda2 107 108 Next, we open the container. The decrypted container will be available at 109 `/dev/mapper/sda2_crypt`. 110 111 cryptsetup open --type luks /dev/sda2 sda2_crypt 112 113 Later, when we get to GRUB bootloader setup steps, we'll need to configure it 114 to recognize that the partition is encrypted, and prompt to decrypt. 115 116 117 ### Create the logical volumes 118 119 Next we'll prepare the disk for use with the Logical Volume Manager 120 ([LVM][lvm_guide]). LVM uses the kernel's device mapper to provide a system of 121 logical volumes that are independent of the underlying disk layout. 122 123 The basic building blocks of LVM are: 124 * Physical Volume (PV): a Unix block device node, usable for storage by LVM. 125 For example, a hard disk, a physical partition, a loopback file, or a 126 device-mapper file such as a dm-crypt volume, like we're using. 127 * Volume Group (VG): a group of PVs. Physical Extents (PEs) are allocated from 128 a VG for use by a Logical Volume (LV). 129 * Logical Volume (LV): a 'virtual' or 'logical' partition that resides in a VG 130 and is composed of Physical Extents (PEs). LVs are Unix block devices 131 analogous to physical partitions, e.g., they can be directly formatted with a 132 filesystem. 133 * Physical Extent (PE): the smallest contiguous extent (default 4 MiB) that 134 resides in a VG and can be assigned to an LV. PEs can be thought of as parts 135 of PVs that can be allocated to any given LV. 136 137 To view physical volumes, volume groups, and logical volumes, use: 138 139 pvdisplay 140 vgdisplay 141 lvdisplay 142 143 To view all devices capable of being used as a physical volume, run: 144 145 lvmdiskscan 146 147 We'll start by creating the physical volume for the disk: 148 149 pvcreate /dev/sda2 # or /dev/mapper/sda2_crypt if using LUKS. 150 151 Next, we'll create a volume group, `vg0`: 152 153 vgcreate vg0 /dev/sda2 # or dev/mapper/sda2_crypt if using LUKS. 154 155 Then, we'll partition that into logical volumes for the root partition and 156 swap: 157 158 lvcreate -L 1.8T vg0 -n lv_root 159 160 If we need to tweak the size by some smaller amount, we can use lvresize with a 161 relative size. For example: 162 163 lvresize -L +5G vg0 -n lv_root 164 165 Next, we'll use the remainder of the disk for swap: 166 167 lvcreate -L 15.96G vg0 -n lv_swap 168 169 170 ### Create filesystems for volumes 171 172 Format the EFI partition as 32-bit FAT: 173 174 mkfs.fat -F32 /dev/sda1 175 176 Format the root filesystem as ext4: 177 178 mkfs.ext4 /dev/mapper/vg0-lv_root 179 180 Format the swap partition: 181 182 mkswap /dev/mapper/vg0-lv_swap 183 swapon /dev/mapper/vg0-lv_swap 184 185 Mount the filesystems: 186 187 mount /dev/mapper/vg0-lv_root /mnt 188 mkdir /mnt/efi 189 mount /dev/sda1 /mnt/efi 190 191 192 Install the base system 193 ----------------------- 194 195 The disk is now prepared for installation and mounted under `/mnt`. Next, we'll 196 install the base system to the target disk. 197 198 ### Bootstrap the install 199 200 First, we install the base system, kernel, and firmware blobs: 201 202 pacstrap -i /mnt base linux linux-firmware 203 204 Next, we generate an `/etc/fstab` file to mount the disk partitions at boot 205 based on what's currently mounted: 206 207 genfstab -U -p /mnt >> /mnt/etc/fstab 208 cat /mnt/etc/fstab # check it! 209 210 211 ### Chroot ourselves into the new root filesystem 212 213 Now that we've got a basic install, we'll chroot jail ourselves into `/mnt`: 214 215 arch-chroot /mnt 216 217 Since a system is literally not POSIX-compliant without `ed` and `vi`, and we 218 desperately need an editor from here on in, we'll install them now: 219 220 pacman -S ed vi 221 222 223 ### Set up system locales 224 225 Configure the available locales for the system. These are what will be 226 available to users on the final system, and also what we'll use during install 227 steps from here on in: 228 229 vi /etc/locale.gen 230 # uncomment en_CA, fr_CA, en_US, ja_JP 231 locale-gen 232 echo LANG=en_CA.UTF-8 > /etc/locale.conf 233 export LANG=en_CA.UTF-8 234 235 236 ### Create a console keymap that replaces caps lock with control 237 238 Since I prefer a control key where it was intended to be, we'll create a new 239 keyboard layout that remaps the Caps Lock key to control: 240 241 cp /usr/share/kbd/keymaps/i386/qwerty/us.map.gz us-ctrlcaps.map.gz 242 gunzip us-ctrlcaps.map.gz 243 # edit the file to set keycode 58 to Control 244 vi us-ctrlcaps.map 245 gzip us-ctrlcaps.map 246 cp us-ctrlcaps.map.gz /usr/share/kbd/keymaps/i386/qwerty/ 247 chown root /usr/share/kbd/keymaps/i386/qwerty/us-ctrlcaps.map.gz 248 chgrp root /usr/share/kbd/keymaps/i386/qwerty/us-ctrlcaps.map.gz 249 250 Next, let's configure the system console keymap: 251 252 vi /etc/vconsole.conf 253 254 Add the following to the file: 255 256 KEYMAP=us # or us-ctrlcaps if you do the step above 257 FONT=Lat2-Terminus16 # if you want a fancy terminal font 258 259 260 ### Configure system timezone 261 262 We'll set the system timezone to Vancouver, BC, Canada: 263 264 ln -s /usr/share/zoneinfo/America/Vancouver /etc/localtime 265 266 Next, we generate sync the hardware clock to UTC based on the current system 267 time, and generate `/etc/adjtime`: 268 269 hwclock --systohc --utc 270 271 272 ### Set the hostname 273 274 Here, we set the system hostname: 275 276 echo myawesomehostname > /etc/hostname 277 278 And generate the hosts file: 279 280 vi /etc/hosts 281 282 The file contents should just contain the IPv4 and IPv6 entries for localhost: 283 284 127.0.0.1 localhost 285 ::1 localhost 286 287 288 ### Configure DHCP 289 290 Arch, and most Linux distributions these days, use [systemd][systemd_guide] to 291 manage running daemons and logging. Now would be a good time do read up on it. 292 293 Install [dhcpcd][dhcpcd_guide]: 294 295 pacman -S dhcpcd 296 297 Edit the configuration in `/etc/dhcpcd.conf` to add the interface to configure at the top of the file: 298 299 interface eno1 300 301 Enable the service: 302 303 systemctl enable dhcpcd.service 304 305 306 ### Configure NTP 307 308 Install [ntpd][ntpd_guide]: 309 310 pacman -S ntp 311 312 Then edit the `/etc/ntpd.conf`. It's recommended to add the `iburst` option at 313 the end of every `server` line in the config file. This triggers a burst of 314 packets only if it cannot obtain a connection on the first attempt. Do not use 315 the `burst` option, which sends a burst of packets on _all_ attempts and can 316 get you blacklisted. 317 318 Finally, enable the service: 319 320 systemctl enable ntpd.service 321 322 323 Enable and start the NTP service: 324 325 systemctl enable ntpd.service 326 systemctl start ntpd.service 327 328 329 330 ### Initramfs 331 332 The initial ramdisk is a very small environment which loads various kernel 333 modules and sets up necessary prerequisites before handing over control to 334 `init`. This makes it possible to have encrypted root filesystems and root 335 filesystems on a software RAID array. The `pacstrap` step earlier generates an 336 initial ramdisk, but since we're using LVM and full-disk encryption, we need to 337 generate a new one with those options enabled, using 338 [mkinitcpio][mkinitcpio_guide]. First, edit the config file: 339 340 vi /etc/mkinitcpio.conf 341 342 We'll need to modify the `HOOKS` line to add `encrypt lvm2` immediately before 343 the `filesystems` entry on the line: 344 345 HOOKS=(... block encrypt lvm2 filesystems ...) 346 347 Next, we'll then regenerate the initial ramdisk: 348 349 mkinitcpio -p linux 350 351 352 ### Set root passwd 353 354 Next, we'll set the root password: 355 356 passwd 357 358 Once we've got `doas` installed in a later step, and an administrator user 359 created, we'll disable the root account, but for now, we'll want to be able to 360 log in as root to configure the system. 361 362 363 Install GRUB bootloader 364 ----------------------- 365 366 Next up, let's install the [UEFI][uefi_guide]-capable GRUB bootloader: 367 368 pacman -S grub efibootmgr 369 grub-install --target=x86_64-efi \ 370 --efi-directory=/efi \ 371 --bootloader-id=GRUB \ 372 --recheck \ 373 --debug 374 375 ### Install Intel/AMD microcode updates 376 377 Next, assuming we're using an Intel or AMD process, we'll enable microcode 378 loading support, to enable CPU microcode patching that fixes security issues or 379 bugs in the CPU. 380 381 If you have an Intel CPU: 382 383 pacman -S intel-ucode 384 385 Or, if you have an AMD processor: 386 387 pacman -S amd-ucode 388 389 In the `grub-mkconfig` step that follows, these packages are automatically 390 detected and GRUB will be configured appropriately. 391 392 393 ### Configure LUKS encryption support 394 395 Next, if you elected to configure LUKS full-disk encryption above, we'll 396 configure GRUB to handle full-disk encryption, so it doesn't look like a 397 physical partition full of random noise: 398 399 vi /etc/default/grub 400 401 Edit the `GRUB_CMDLINE_LINUX` line to indicate that /dev/sda2:vg0 is encrypted: 402 403 GRUB_CMDLINE_LINUX="cryptdevice=/dev/sda2:vg0 404 405 406 ### Regenerate GRUB config 407 408 Next regenerate the GRUB config file on the boot partition: 409 410 grub-mkconfig -o /boot/grub/grub.cfg 411 412 413 Reboot 414 ------ 415 416 Exit the chroot environment by typing `exit` or pressing ctrl-d. 417 418 Unmount all partitions, in case any are busy: 419 420 umount -R /mnt 421 422 Finally, reboot the machine by typing `reboot`. Once the machine reboots, yank 423 the USB drive so you boot from disk, not the USB drive. 424 425 426 Post-installation 427 ----------------- 428 429 Now that we've got a working base system, we'll configure the machine to be 430 somewhat useful. Log in as `root`, with the password you set earlier for the 431 following steps. 432 433 ### Install additional shells 434 435 Since zsh is generally a nicer ksh, and I prefer it to bash, let's install that 436 first: 437 438 pacman -S zsh 439 440 441 ### Create admin user 442 443 Next, let's create a new user and set their password: 444 445 useradd -m -g users -G wheel -s /bin/zsh chris 446 passwd chris 447 448 449 ### Install doas 450 451 For security reasons, we'd like to disable the root account and force all 452 administrative actions to occur via the `doas` command. First install it: 453 454 pacman -S opendoas 455 456 Then we edit `/etc/doas.conf` and uncomment (or add) the following line: 457 458 permit nopass :wheel 459 permit :wheel cmd reboot 460 permit :wheel cmd shutdown 461 permit nopass keepenv root as root 462 463 To verify this worked, log out of the root account, then log in as the admin 464 user created in the previous step and verify they can issue commands with 465 `doas`. 466 467 doas ls /root 468 469 If that worked, lock-down the root account: 470 471 doas passwd -l root 472 473 If you even need to unlock the root account, issue: 474 475 doas passwd -u root 476 477 Now that the root account is disabled, the remainder of the steps should be 478 executed via doas from an admin user account. 479 480 481 ### Install essential packages 482 483 First, we install core packages we can't live without: 484 485 pacman -S man-db man-pages 486 pacman -S openssh 487 488 489 ### Configure auto-mounting USB devices 490 491 Next, we'll set up automounting USB disks. Since many of these are FAT32 492 format, we'll also install tools for dealing with DOS partitions: 493 494 pacman -S udisks2 495 pacman -S dosfstools 496 497 498 ### Install useful packages 499 500 Since `vim` is far nicer to work in than `ed`, `ex`, or `vim`, we'll install 501 it first: 502 503 pacman -S vim 504 pacman -S pacman -S vim-spell-en vim-spell-fr 505 506 Support for zip archives is handy: 507 508 pacman -S zip unzip 509 510 Networking tooling for nslookup, dig, netstat: 511 512 pacman -S dnsutils net-tools 513 514 Next, terminal multiplexing support via tmux: 515 516 pacman -S tmux 517 518 Next, compilers and development tools: 519 520 pacman -S base-devel 521 pacman -S binutils 522 pacman -S clang lld lldb 523 pacman -S python 524 pacman -S go 525 pacman -S rust 526 pacman -S nasm 527 pacman -S gn 528 pacman -S ninja 529 pacman -S cmake 530 pacman -S meson 531 pacman -S scdoc 532 533 And, source control: 534 535 pacman -S git tig 536 537 For a GUI environment, we install Sway, an i3-like Wayland-based window manager: 538 539 pacman -S sway swaylock swayidle # Sway: Use noto fonts if prompted 540 pacman -S xorg-server-xwayland xorg-xrdb # Xwayland support 541 pacman -S alacritty # terminal 542 pacman -S grim jq slurp libnotify wl-clipboard # screenshots 543 pacman -S wofi # app launcher (dmenu alternative) 544 pacman -S mako # notifications 545 546 Next, install some additional Western and Japanese fonts: 547 548 pacman -S adobe-source-code-pro-fonts 549 pacman -S adobe-source-serif-pro-fonts 550 pacman -S adobe-source-han-sans-otc-fonts 551 pacman -S otf-ipafont 552 pacman -S noto-fonts noto-fonts-cjk noto-fonts-emoji noto-fonts-extra 553 554 Add some media players: 555 556 pacman -S sxiv 557 pacman -S mpv 558 pacman -S cmus 559 560 Add chat clients: 561 562 pacman -S signal-desktop 563 pacman -S weechat 564 565 Add web/gopher/gemini browsers: 566 567 pacman -S firefox 568 pacman -S w3m 569 pacman -S lynx 570 pacman -S amfora 571 572 Add a password manager: 573 574 pacman -S pass 575 576 577 ### Audio 578 579 It's useful to have the `alsa-utils` package installed for playing around with 580 audio levels via `alsa-mixer`. 581 582 pacman -S alsa-utils 583 pacman -S pulseaudio-alsa 584 585 Also useful to have `pavucontrol` installed for editing audio-levels at the 586 pulseaudio level: 587 588 pacman -S pavucontrol 589 590 Then start pulseaudio on user login: 591 592 systemctl --user start pulseaudio 593 594 If using Intel HDA audio, via the `snd_hda_intel` kernel module you may need to 595 ensure the following line exists in `/etc/modprobe.d/alsa-base.conf` (or other 596 equivalent file you edit/create under the `/etc/modprobe.d` directory): 597 598 options snd-hda-intel model=auto 599 600 Without this, Intel audio sometimes simply utterly fails to work. 601 602 603 ### Install yay for AUR support 604 605 To support installing packages from AUR, we install the `yay` tool, which is a 606 wrapper around `pacman` similar to what `yaourt` used to support. First we 607 clone the source from AUR: 608 609 git clone https://aur.archlinux.org/yay.git 610 cd yay 611 612 Next we run `makepkg` with the `-s` (build from source) and `-i` (install) 613 options: 614 615 makepkg -si 616 617 If you get a warning along the lines of "ERROR: Cannot find the fakeroot 618 binary", install it via the following command: 619 620 pacman -S fakeroot 621 622 Fakeroot is a tool that makes it easier to create tar archives, etc. containing 623 files with root ownership, which would otherwise require root user privileges. 624 625 626 ### Install firmware for NUC 627 628 Intel NUC devices may need particular closed-source firmware blobs installed. 629 For the NUC8i5BEK, install: 630 631 yay -S wd719x-firmware 632 yay -S aic94xx-firmware 633 634 635 ### Install Japanese input support 636 637 fcitx5 is the IME frontend for Japanese input, while mozc provides the candidate 638 selection backend. Install all the required packags: 639 640 pacman -S fcitx5-mozc fcitx5-configtool fcitx5-gtk 641 642 Note that as of summer 2021, the Wayland IME protocol is still unstable. fcitx5 643 only has partial integration with the sway window manager on Wayland. Under 644 Xwayland, it works fine. 645 646 647 ### Install mutt email client 648 649 Install mutt: 650 651 pacman -S mutt 652 653 Install msmtp for SMTP sending and ca-certificates for TLS: 654 655 pacman -S msmtp 656 pacman -S ca-certificates 657 658 Install notmuch for search/indexing: 659 660 pacman -S notmuch-mutt 661 662 Install HTML-to-text support and URL handling: 663 664 pacman -S w3m urlscan 665 666 Install isync (also known as mbsync): 667 668 pacman -S isync 669 670 Install abook for address book support: 671 672 pacman -S abook 673 674 675 ### NFS support 676 677 By default, NFS assumes identical user and group IDs on the client and server. 678 NFSv4 can be configured to use `idmapd` to map user IDs between client and 679 server, but this requires a little bit of legwork up front on the server and all 680 clients. 681 682 On both the client and server, edit `/etc/idmapd.conf` ensure the domain line is 683 set consistently across both: 684 ``` 685 Domain = bracken.jp 686 ``` 687 688 With the default security mechanism, [idmapd][idmapping] support is disabled. 689 You can verify this by running: 690 ```sh 691 cat /sys/module/nfs/parameters/nfs4_disable_idmapping 692 cat /sys/module/nfsd/parameters/nfs4_disable_idmapping 693 ``` 694 695 To re-enable ID mapping, you can manually `echo N` into each of those files as 696 root to temporarily re-enable it until next boot. To make these changes 697 permanent across re-boots, edit `/etc/modprobe.d/nfs.conf` to contain: 698 ``` 699 options nfs nfs4_disable_idmapping=0 700 options nfsd nfs4_disable_idmapping=0 701 ``` 702 703 Note that, as noted in the [idmapd][idmapping] section of the NFS wiki, it is 704 _not_ necessary to run the nfs-imapd systemd service since there's already a 705 newer ID mapper built-in. You can see this by running: 706 ```sh 707 dmesg | grep id_resolver 708 ``` 709 710 Finally, we edit `/etc/fstab` to add the new mounts: 711 ``` 712 # Filesystem Mountpoint Type Options Dump Pass 713 servername:/path/to/directory /path/to/mountpoint nfs rw,nfsvers=4,_netdev,noauto 0 0 714 ``` 715 716 ``` 717 systemctl start nfs-idmapd 718 ``` 719 720 [idmapping]: https://wiki.archlinux.org/title/NFS#Enabling_NFSv4_idmapping 721 722 723 ### HP printer support 724 725 Next, we'll configure [CUPS][cups_guide] printer support for HP printers, 726 mostly since that's what I have. 727 728 pacman -S cups hplip 729 doas vi /etc/sane.d/dll.d/hpaio # uncomment or add hpaio 730 731 Start the CUPS printer daemon: 732 733 doas systemctl enable org.cups.cupsd.service 734 doas hp-setup -i # PPD files under /usr/share/ppd/HP/ 735 736 737 ### Install windows8 fonts 738 739 See details in the [MS Fonts guide][ms_fonts_guide]. 740 741 These instructions are out-of-date and probably a bad idea: 742 curl -o ttf-ms-win8.tgz \ 743 https://drive.google.com/open?id=0BxQqjcVVn0shNGpqdDZYUjdaNUU 744 tar zxvf ttf-ms-win8.tgz 745 cd ttf-ms-win8.tgz 746 makepkg -if 747 748 749 [install_guide]: https://wiki.archlinux.org/index.php/Installation_guide 750 [luks_guide]: https://wiki.archlinux.org/index.php/Dm-crypt 751 [lvm_guide]: https://wiki.archlinux.org/index.php/LVM 752 [systemd_guide]: https://wiki.archlinux.org/index.php/Systemd 753 [dhcpcd_guide]: https://wiki.archlinux.org/index.php/Dhcpcd 754 [ntpd_guide]: https://wiki.archlinux.org/title/Network_Time_Protocol_daemon 755 [mkinitcpio_guide]: https://wiki.archlinux.org/index.php/mkinitcpio 756 [uefi_guide]: https://wiki.archlinux.org/index.php/Unified_Extensible_Firmware_Interface 757 [cups_guide]: https://wiki.archlinux.org/index.php/CUPS 758 [ms_fonts_guide]: https://wiki.archlinux.org/index.php/MS_Fonts 759 [gnome_guide]: https://wiki.archlinux.org/index.php/GNOME