Mostly overhaul Arch installation guide to how I'm using it.

- Add rEFInd
    - Add more explaination on /efi vs /boot

    - Remove GRUB
    - Remove F2FS
    - Remove old headings

    - Change shell command presentation
    - Change LUKS setup
    - Use new btrfs command to create swapfile
    - Generally slightly more commentary on choices or steps
This commit is contained in:
exu 2023-11-17 14:42:26 +01:00
parent 67e6d374f5
commit 41556ada44

View File

@ -5,26 +5,59 @@ visible: true
[toc] [toc]
Last modified: 2023-11-17
## Keyboard layout ## Keyboard layout
`loadkeys de_CH-latin1` [shroot]
```
loadkeys de_CH-latin1
```
[/shroot]
## Check UEFI mode ## Check UEFI mode
If the following command works, the system is booted in EFI. If the following command works, the system is booted in EFI.
`ls /sys/firmware/efi/efivars`
[shroot]
```
ls /sys/firmware/efi/efivars
```
[/shroot]
## Verify internet connection ## Verify internet connection
`ping www.realstickman.net` [shroot]
```
ping wiki.exu.li
```
[/shroot]
## Update system clock ## Update system clock
`timedatectl set-ntp true` [shroot]
```
timedatectl set-ntp true
```
[/shroot]
## Creating partitions ## Creating partitions
`cfdisk` [shroot]
```
cfdisk
```
[/shroot]
Use `EFI System` for EFI partition Use `EFI System` for EFI partition
Use `Linux filesystem` for other partitions Use `Linux filesystem` for other partitions
@ -33,15 +66,25 @@ Use `Linux filesystem` for other partitions
_Note: Do not put your /efi partition on an encrypted partition!_ _Note: Do not put your /efi partition on an encrypted partition!_
Create encrypted Partition Create encrypted Partition with a label. This label will later be used to identified the bootdevice as a simpler alternative to UUIDs.
`cryptsetup luksFormat /dev/(partition) --type luks1`
To view if this worked correctly [shroot]
`cryptsetup luksDump /dev/(partition)`
Open the partition ```
Give it a fitting name cryptsetup luksFormat --label=(label) /dev/(partition)
`cryptsetup open /dev/(partition) (name)` ```
[/shroot]
Open the partition and specify a name
[shroot]
```
cryptsetup open /dev/(partition) (name)
```
[/shroot]
Check if this worked with `ls /dev/mapper/` Check if this worked with `ls /dev/mapper/`
The name should show up there The name should show up there
@ -49,26 +92,50 @@ The name should show up there
## Format partitions ## Format partitions
Fat 32: Fat 32:
`mkfs.fat -F32 /dev/(partition)`
[shroot]
```
mkfs.fat -F32 /dev/(partition)
```
[/shroot]
_For EFI or BOOT partition_ _For EFI or BOOT partition_
Ext4: Ext4:
`mkfs.ext4 /dev/(partition)`
[shroot]
```
mkfs.ext4 /dev/(partition)
```
[/shroot]
_All other partitions_ _All other partitions_
btrfs: Btrfs:
`mkfs.btrfs /dev/(partition)`
_All other partitions_ [shroot]
```
mkfs.btrfs /dev/(partition)
```
[/shroot]
F2FS:
`mkfs.f2fs -O extra_attr,inode_checksum,sb_checksum,compression /dev/(partition)`
_All other partitions_ _All other partitions_
## Mounting partitions ## Mounting partitions
Generally partitions have to be mounted where you will later use them in your system. Generally partitions have to be mounted where you will later use them in your system.
BTRFS with its subvolumes is a special case BTRFS with its subvolumes is a special case, see the additional chapter below.
For EFI, prefer the /efi mountpoint Be careful in choosing you EFI mountpoint when using full disk encryption.
Using `/efi` will lead to much longer boot times in GRUB and be completely unsupported in other bootloaders.
See [this feature comparison](https://wiki.archlinux.org/title/Arch_boot_process#Boot_loader) for details.
For `/efi` size really doesn't matter much and can be 1 or 2 megabytes. 16MB is probably a good size.
If you're using `/boot`, the kernel and initramfs will also be stored on this partition among others. Recommended sizes range from 256MB to 512MB
``` ```
Root: /mnt Root: /mnt
@ -80,105 +147,137 @@ etc...
### (BTRFS) Btrfs preparation of subvolumes and mounting ### (BTRFS) Btrfs preparation of subvolumes and mounting
Mount root partition Mount root partition
`mount /dev/(partition) /mnt`
[shroot]
```
mount /dev/(partition) /mnt
```
[/shroot]
Root subvolume Root subvolume
`btrfs subv create /mnt/@`
[shroot]
```
btrfs subv create /mnt/@
```
[/shroot]
Home subvolume Home subvolume
`btrfs subv create /mnt/@home`
[shroot]
```
btrfs subv create /mnt/@home
```
[/shroot]
Snapshots subvolume for snapper Snapshots subvolume for snapper
`btrfs subv create /mnt/@snapshots`
Snapshots subvolume for timeshift [shroot]
`btrfs subv create /mnt/@timeshift`
```
btrfs subv create /mnt/@snapshots
```
[/shroot]
Var subvolume Var subvolume
`btrfs subv create /mnt/@var_log`
[shroot]
```
btrfs subv create /mnt/@var_log
```
[/shroot]
_If you want to use a swapfile with Snapper, create a new subvolume now_ _If you want to use a swapfile with Snapper, create a new subvolume now_
Swap subvolume Swap subvolume
`btrfs subv create /mnt/@swap`
`umount /mnt` [shroot]
```
btrfs subv create /mnt/@swap
```
[/shroot]
[shroot]
```
umount /mnt
```
[/shroot]
Mount root Mount root
`mount -o noatime,compress-force=zstd,space_cache=v2,subvol=@ /dev/(partition) /mnt` `mount -o noatime,compress-force=zstd,subvol=@ /dev/(partition) /mnt`
With /efi With /efi
`mkdir -p /mnt/{efi,home,.snapshots,var/log,swap}` `mkdir -p /mnt/{efi,home,.snapshots,var/log,swap}`
With /boot With /boot
`mkdir -p /mnt/{boot,home,.snapshots,var/log,swap}` `mkdir -p /mnt/{boot,home,.snapshots,var/log,swap}`
With /boot and timeshift
`mkdir -p /mnt/{boot,home,timeshift-btrfs,var/log,swap}`
Mount home Mount home
`mount -o noatime,compress-force=zstd,space_cache=v2,subvol=@home /dev/(partition) /mnt/home` `mount -o noatime,compress-force=zstd,subvol=@home /dev/(partition) /mnt/home`
Mount snapshots for snapper Mount snapshots for snapper
`mount -o noatime,compress-force=zstd,space_cache=v2,subvol=@snapshots /dev/(partition) /mnt/.snapshots` `mount -o noatime,compress-force=zstd,subvol=@snapshots /dev/(partition) /mnt/.snapshots`
Mount snapshots for timeshift
`mount -o noatime,compress-force=zstd,space_cache=v2,subvol=@timeshift /dev/(partition) /mnt/timeshift-btrfs`
Mount var Mount var
`mount -o noatime,compress-force=zstd,space_cache=v2,subvol=@var_log /dev/(partition) /mnt/var/log` `mount -o noatime,compress-force=zstd,subvol=@var_log /dev/(partition) /mnt/var/log`
Swap subvolume Swap subvolume
`mount -o noatime,compress-force=zstd,space_cache=v2,subvol=@swap /dev/(partition) /mnt/swap` `mount -o noatime,subvol=@swap /dev/(partition) /mnt/swap`
**Don't forget mounting other partitions!!**
### (F2FS) Mounting
Mount partition with compression algorithm specified
`mount -o compress_algorithm=zstd /dev/(partition) /mnt`
With /efi
`mkdir -p /mnt/efi`
With /boot
`mkdir -p /mnt/boot`
**Don't forget mounting other partitions!!** **Don't forget mounting other partitions!!**
## Swap ## Swap
### Swap partition
TODO
### Swapfile ### Swapfile
#### Normal way #### Normal way
**NOT FOR BTRFS!** **NOT FOR BTRFS!**
`dd if=/dev/zero of=/mnt/swapfile bs=1M count=(size) status=progress`
[shroot]
```
dd if=/dev/zero of=/mnt/swapfile bs=1M count=(size) status=progress
```
[/shroot]
#### (BTRFS) Swapfile in btrfs #### (BTRFS) Swapfile in btrfs
_Does not work with snapper_ _Use a separate subvolume to work with snapper_
_Use a separate subvolume in that case_
```sh [shroot]
truncate -s 0 /mnt/swapfile
chattr +C /mnt/swapfile ```
btrfs property set /mnt/swapfile compression none btrfs fi mkswapfile --size [SIZE]g --uuid clear /mnt/swap/swapfile
fallocate -l (size)M /mnt/swapfile swapon /mnt/swap/swapfile
``` ```
#### Initialising swapfile [/shroot]
```sh
chmod 600 /mnt/swapfile
mkswap /mnt/swapfile
swapon /mnt/swapfile
```
## Essential packages ## Essential packages
Some things like the userspace utilities for file management will vary. Install a few essential packages using `pacstrap`.
See [file systems](https://wiki.archlinux.org/index.php/File_systems#Types_of_file_systems) Additional packages might also be necessary, see the list below.
`pacstrap /mnt base linux linux-firmware vim git openssh networkmanager network-manager-applet dialog base-devel linux-headers`
[shroot]
```
pacstrap /mnt base base-devel linux linux-firmware linux-headers vim git openssh networkmanager dialog
```
[/shroot]
### Microcode ### Microcode
@ -197,9 +296,6 @@ Ext4:
Btrfs: Btrfs:
`btrfs-progs compsize` `btrfs-progs compsize`
F2FS:
`f2fs-tools`
### Wifi ### Wifi
`wpa_supplicant` `wpa_supplicant`
@ -218,12 +314,25 @@ F2FS:
## Generate fstab ## Generate fstab
`genfstab -U /mnt >> /mnt/etc/fstab` [shroot]
```
genfstab -U /mnt >> /mnt/etc/fstab
```
[/shroot]
**Make sure the fstab file has everything included** **Make sure the fstab file has everything included**
## Chroot into the system ## Chroot into the system
`arch-chroot /mnt` [shroot]
```
arch-chroot /mnt
```
[/shroot]
## Set timezone ## Set timezone
@ -254,89 +363,63 @@ Make sure to use a UTF-8 entry.
Edit `/etc/hosts` Edit `/etc/hosts`
``` ```
127.0.0.1 localhost 127.0.0.1 localhost (hostname)
::1 localhost ::1 localhost
127.0.1.1 (hostname).localdomain (hostname)
``` ```
## Change root password ## Change root password
`passwd` [shroot]
```
passwd
```
[/shroot]
## Bootloader installation ## Bootloader installation
### GRUB UEFI ### rEFInd
`pacman -S grub efibootmgr` [shroot]
If you are using encryption, see the next section first. **Make sure to come back here again though** ```
`grub-install --target=x86_64-efi --efi-directory=(efi partition mountpoint) --bootloader-id=GRUB` pacman -S refind
```
`grub-mkconfig -o /boot/grub/grub.cfg` [/shroot]
#### (LUKS) Encryption with /efi Use the rEFInd installation script. In most cases no specific configuration is necessary
Create keyfile and add it to mkinitcpio.conf [shroot]
`dd bs=512 count=4 if=/dev/random of=/crypto_keyfile.bin iflag=fullblock`
`chmod 600 /crypto_keyfile.bin` ```
refind-install
```
**This command should be run after installing a new kernel!** [/shroot]
`chmod 600 /boot/initramfs-linux*`
`cryptsetup luksAddKey /dev/(partition) /crypto_keyfile.bin` **Manual editing of the generated configuration file is necessary when installing rEFInd from the Arch boot ISO**
Include the file in `/etc/mkinitcpio.conf` _TODO insert config here_
`FILES=(/crypto_keyfile.bin)`
Edit the `HOOKS` section as well. _Example:_ ### mkinitcpio with LUKS
`HOOKS=(base udev autodetect keyboard keymap modconf block encrypt filesystems fsck)`
`mkinitcpio -p linux` Some additional settings are necessary in `/etc/mkinitcpio.conf` in order to enable booting from LUKS-encrypted disks.
Edit `/etc/default/grub` Edit the `HOOKS` section in `/etc/mkinitcpio.conf` by adding `encrypt` after `block` and before `filesystems`
`GRUB_ENABLE_CRYPTODISK=y`
Some options in `GRUB_CMDLINE_LINUX_DEFAULT` Also ensure `keyboard keymap` are present before `encrypt` in order to allow the loading of the default keyboard language from `/etc/vconsole.conf` to enter the decryption password.
**Make sure to change /dev/(partition) to UUID ASAP!**
_Not sure how to actually do that though, will have to read some more._
`cryptdevice=/dev/(partition):(name)`
`cryptkey=/dev/mapper/(name):(filesystem):/crypto_keyfile.bin`
**Go back and install grub!!** Regenerate all initramfs presets
#### (LUKS) Encryption with /boot [shroot]
Edit the `HOOKS` section in `/etc/mkinitcpio.conf` _Example:_ ```
`HOOKS=(base udev autodetect keyboard keymap modconf block encrypt filesystems fsck)` mkinitcpio -P
```
`mkinitcpio -p linux` [/shroot]
Next, edit `/etc/default/grub`
Add an option in `GRUB_CMDLINE_LINUX_DEFAULT`
**Make sure to change /dev/(partition) to UUID ASAP!**
_Not sure how to actually do that though, will have to read some more._
`cryptdevice=/dev/(partition):(name)`
**Go back and install grub!!**
## Mkinitcpio
### BTRFS
Load required modules
`vim /etc/mkinitcpio.conf`
`MODULES=(btrfs)`
`BINARIES=("/usr/bin/btrfs")`
`mkinitcpio -p linux`
**Go back and install grub!!**
### EXT4
### F2FS
## Networking ## Networking
@ -391,7 +474,7 @@ Change these things:
``` ```
TIMELINE_LIMIT_HOURLY="5" TIMELINE_LIMIT_HOURLY="5"
TIMELINE_LIMIT_DAILY="7" TIMELINE_LIMIT_DAILY="7"
TIMELINE_LIMIT_WEEKLY="0" TIMELINE_LIMIT_WEEKLY="4"
TIMELINE_LIMIT_MONTHLY="0" TIMELINE_LIMIT_MONTHLY="0"
TIMELINE_LIMIT_YEARLY="0" TIMELINE_LIMIT_YEARLY="0"
``` ```
@ -406,22 +489,33 @@ Allow user to access snapshots
## Install AUR helper ## Install AUR helper
### yay
```sh
git clone https://aur.archlinux.org/yay.git
cd yay
makepkg -si
```
### paru ### paru
```sh [shuser]
git clone https://aur.archlinux.org/paru.git
cd paru ```
cd $(mktemp -d)
git clone https://aur.archlinux.org/paru-bin.git
cd paru-bin
makepkg -si makepkg -si
``` ```
## (Snapper) Snap pac and GUI [/shuser]
`$ paru -S snap-pac-grub snapper-gui` ## Automatic snapshots on package changes
[shroot]
```
pacman -S snap-pac
```
[/shroot]
## (rEFInd) Show snapshots in bootmenu
_WIP_
`paru -S refind-btrfs`
`systemctl enable --now refind-btrfs.service`