Installation - marco1475/linux-htpc GitHub Wiki
Getting to the Virtual Console
-
Ensure that USB devices have a higher boot priority than the internal hard drive.
- When you see the ASRock boot screen, hit
F2to enter the UEFI Setup. - On the Boot tab ensure the following
Boot Option Priorities:USB: <name of flash drive>UEFI: <name of flash drive>Linux Boot Manager(if available)AHCI P0: <name of internal disk>
- Note that putting
UEFI:beforeUSB:will spare you having to select the UEFI boot method from the Easy2Boot CSM Menu, but it will also prevent you from swapping bootable images (i.e. going back to the Easy2Boot Main Menu).
- When you see the ASRock boot screen, hit
-
Plug in the bootable flash drive and restart the machine.
-
In the Easy2Boot Main Menu select the Arch Linux image, hit
Enterand confirm overwriting the MBR. -
In the Easy2Boot CSM Menu select entry
4 Clover 64-bit UEFI Boot Menu (USB 2.0 ports only)and hitEnter.-
If your bootable flash drive is plugged into a non-USB 2.0 port you will have to:
- Reboot the machine.
- When you see the ASRock screen, hit
F11to enter the Boot Menu. - Select
UEFI: <name of flash drive>as the boot option.
-
Trying to boot the Arch UEFI boot image in MBR mode will result in the following Syslinux error message:
Unknown keyword in configuration file: PATH
boot/syslinux/whichsys.c32: not a COM32R image
-
-
In the Clover 64-bit UEFI Boot Menu select
Boot UEFI external from EASY2BOOT. -
In the Arch Linux Boot Menu select
Arch Linux archiso x86_64 UEFI USB.- If you have a 4K screen the default Linux kernel mode setting might not be able to set the correct resolution, resulting in a blank monitor screen ("There is no signal coming from your computer.").
- To override Linux kernel mode setting:
- With
Arch Linux archiso x86_64 UEFI USBselected hite. - Add
nomodesettingto the end of the command-line setting that appeared on the screen and hitEnter.
- With
-
You are now logged in as
rootin the virtual console of the Arch Linux installation.
Installation Preparation
-
Verify the boot mode:
-
If the following command lists entries in the directory you have correctly booted using UEFI.
ls /sys/firmware/efi/efivars
-
-
Verify the internet connection:
-
Ping
archlinux.orgwhere you'll be downloading packages from; if you get no timeouts you are connected to the internet.ping -c 3 archlinux.org
-
-
Update the system clock:
-
Synchronize the CPU's clock over the internet via NTP.
timedatectl set-ntp true -
After a while ensure the NTP synchronization was successful by running
timedatectl statusand look forNTP synchronized: yesin the output.
-
Partitioning the System Disk
Note that partitions should start on a clean 1 MiB boundary so that block size of the file system aligns with the block size of the SSD.
-
Start the
gdiskpartitioning utility:gdisk /dev/sda- If there are any partitions present remove them by creating a new, empty GUID partition table (
o).
- If there are any partitions present remove them by creating a new, empty GUID partition table (
-
Create a new EFI system partition.
- Press
nand hitEnterto create a new partition. - Press
Enterto accept the default partition number (in this case 1). - Press
Enteragain to accept the default first sector (in this case 2048). TODO: Different disks have different-sized sectors. What is this in MiB? - Enter
+1Gto set the last sector to be 1 GiB past the first sector. - Enter
ef00to set the partition type toEFI System.
- Press
-
Create the root partition.
- Press
nand hitEnterto create a new partition. - Press
Enterto accept the default partition number (in this case 2). - Press
Enteragain to accept the default first sector (in this case 2099200). TODO: Different disks have different-sized sectors. What is this in MiB? - Enter
+60Gto set the last sector to be 60 GiB past the first sector. - Press
Enterto accept the default file system to beLinux filesystem.
- Press
-
Press
pto print out the partition table:Number Start (sector) End (sector) Size Code Name 1 2048 2099199 1024.0 MiB EF00 EFI System 2 2099200 127928319 60.0 GiB 8300 Linux filesystem -
Press
wto write the partition table to disk.
Formatting the System Disk
-
The EFI System Partition must be formatted as
FAT32:mkfs.fat -F32 -L "babylon5:esp" /dev/sda1 -
The root partition will be formatted as
ext4:mkfs.ext4 -L "babylon5:root" /dev/sda2 -
Write down the UUIDs of the newly-formatted partitions:
lsblk -no name,uuid
Encrypting the System Disk
-
Encrypt the
rootpartition usingdm-crypt:cryptsetup -s 512 luksFormat /dev/sda2- Type
YESwhen prompted for confirmation that all data on/dev/sda2will be overwritten. - Enter the passphrase that will unlock the partition (hint: full+server+partition) and verify it.
- Type
-
Open the encrypted partition:
cryptsetup open --type luks /dev/sda2 cryptroot- The encrypted partition can now be accessed through
/dev/mapper/cryptroot.
- The encrypted partition can now be accessed through
-
Format the encrypted partition:
mkfs.ext4 /dev/mapper/cryptroot -
Write down the UUIDs of the newly-encrypted and formatted partitions.
lsblk -no name,uuid- Note that the encrypted partition has a different UUID locked vs. unlocked.
-
Close the partition:
cryptsetup close cryptroot
Mounting the System Disk
-
Open the encrypted partition:
cryptsetup open --type luks /dev/sda2 cryptroot -
Mount the
rootpartition:mount /dev/mapper/cryptroot /mnt -
Make a new directory for the EFI System Partition and mount it:
mkdir /mnt/esp mount /dev/sda1 /mnt/esp -
Create the EFI directory structure and bind-mount
bootto it:mkdir /mnt/boot mkdir -p /mnt/esp/EFI/arch mount --bind /mnt/esp/EFI/arch /mnt/bootgenfstabwill use this structure to generate/etc/fstabfor us.
Install the System
-
Before installing the system sort the
mirrorlistaccording to each server's latency:-
Backup the existing
mirrorlistfile:cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.backup -
Rank the mirrors and keep the six fastest in the
mirrorlist:rankmirrors -n 6 /etc/pacman.d/mirrorlist.backup > /etc/pacman.d/mirrorlist
-
-
Install the system using
pacstrap:pacstrap /mnt base base-devel efibootmgr vim
Configure the System
-
Generate an
fstabfile from the mounted partitions usingUUIDs:genfstab -U /mnt >> /mnt/etc/fstab -
Fix-up the
fstabfile:-
Change
relatimeon all non-boot partitions tonoatimeto reduce wear on the SSD. -
Change the bind-mount target from
/mnt/esp/EFI/archto/esp/EFI/arch. -
Change the
UUIDof/dev/mapper/cryptrootto/dev/mapper/cryptroot.- Since
/dev/mapper/cryptrootalready is the result of a unique partition mapping, there is no need to specify anUUIDfor it.
- Since
-
Make
/tmpa ramdisk:tmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0
- TODO: Copy /etc/fstab to Backup.
-
-
Change root into the new system:
arch-chroot /mnt -
Setup the system clock:
ln -s /usr/share/zoneinfo/US/Eastern /etc/localtime hwclock --systohc --utc -
Uncomment
en_US.UTF-8 UTF-8in/etc/locale.genand generate locales with:locale-gen -
Set the
LANGvariable accordingly in/etc/locale.conf:LANG=en_US.UTF-8TODO: Copy /etc/locale.conf to Backup.
-
Set the host name
-
Create the
/etc/hostnamefile and add:babylon5 -
Edit the
/etc/hostsfile and add:127.0.0.1 babylon5.localdomain babylon5- Make sure to keep the existing
localhostentries.
- Make sure to keep the existing
- TODO: Copy the files to Backup.
-
-
Set the
rootpassword:passwd -
Configure swapping:
-
Create a swap file:
fallocate -l 4G /swapfile -
Set the right permissions:
chmod 600 /swapfile -
Format the file to swap:
mkswap /swapfile -
Activate the swap file:
swapon /swapfile -
Edit
/etc/fstabto include the swap file:/swapfile none swap defaults 0 0
-
-
Configure the network:
-
Get the list of current device names:
ls /sys/class/net -
Change the device name from
enp2s0tonet0:-
Get the
MACaddress of the network card:cat /sys/class/net/enp2s0/address -
Add the
MACaddress to audevrule in/etc/udev/rules.d/10-network.rules:SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="bc:5f:f4:bd:cb:dd", NAME="net0"
-
-
Ensure that
systemd-networkdwill be started on boot:systemctl enable systemd-networkd.service systemctl enable systemd-resolved.service -
Add the
/etc/systemd/network/wired.networkconfiguration file:[Match] Name=net0 [Network] Address=192.168.1.2/24 Gateway=192.168.1.1 -
Add DNS to the
/etc/resolv.conffile:# OpenNIC nameserver 45.32.215.96 nameserver 96.90.175.167 # OpenDNS nameserver 208.67.222.222 nameserver 208.67.220.220 # Google DNS nameserver 8.8.8.8 nameserver 8.8.4.4
-
-
Install Intel micro-codes:
pacman -S intel-ucode -
Install the Intel GPU driver:
pacman -S xf86-video-intel -
Generate the initial ramdisk:
-
Edit the
/etc/mkinitcpio.conffile:MODULES="vfat ext4 i915" HOOKS="base udev keyboard autodetect modconf block encrypt filesystems fsck"- TODO: Copy the file to Backup.
-
Generate the
initrdimage:mkinitcpio -p linux
-
Configure the Bootloader
-
Install
systemd-bootto provide a boot menu at startup:bootctl --path=/esp install -
Create a boot configuration file
/esp/loader/entries/arch.conf:title Arch Linux linux /EFI/arch/vmlinuz-linux initrd /EFI/arch/intel-ucode.img initrd /EFI/arch/initramfs-linux.img options cryptdevice=PARTUUID=5f95d9a8-1f7e-4459-b849-b7a702d155a4:cryptroot root=/dev/mapper/cryptroot rw nomodesetting- Get the
PARTUUIDby executingls -l /dev/disk/by-partuuid/. - Note that the
intel-ucode.imgmust be the firstinitrdentry. nomodesettingis only necessary with UHD+ displays.
- Get the
-
Edit
/esp/loader/loader.confthe loader configuration file to point to the boot configuration file:default arch timeout 15 editor 0
Reboot into the New System
-
Exit the
chrooted system:exit -
Unmount all partitions:
umount -R /mnt -
Close the encrypted partition:
cryptsetup close cryptroot -
Restart the machine:
reboot- Don't forget to remove the bootable USB drive.