summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2025-04-27 12:29:51 +0200
committerxengineering <me@xengineering.eu>2025-05-04 22:06:22 +0200
commita8aa565d8b3484b1fe926d30f8979b09ff710c3d (patch)
tree2397e2525aa067321c1af4bf1af23d781d7b11f7
parent4341dc3ccae6c76e6146bb9c8e2688eb0fae9378 (diff)
downloadwebsite-arch-installation.tar
website-arch-installation.tar.zst
website-arch-installation.zip
WIP: articles: Add qemu-arch-installation.mdarch-installation
Commands are already validated, explanation text is missing.
-rw-r--r--content/articles/arch-installation.md185
1 files changed, 185 insertions, 0 deletions
diff --git a/content/articles/arch-installation.md b/content/articles/arch-installation.md
new file mode 100644
index 0000000..7f3a775
--- /dev/null
+++ b/content/articles/arch-installation.md
@@ -0,0 +1,185 @@
+{
+ "title": "Arch Linux installation",
+ "subtitle": "Installation guide for the Arch Linux operating system"
+}
+
+#### Introduction
+
+This article describes how to install [Arch Linux][1]. It is based on the
+[official installation guide][2].
+
+This primary documentation does not describe one specific installation option
+but instead points out the different options the user has like selecting
+bootloaders, boot modes or filesystems.
+
+As a complement this article documents one specific installation inside a QEMU
+virtual machine (VM). It might be used as a VM or converted to a binary image
+file which can be written to a physical drive like an USB stick or SSD.
+
+#### Design decisions
+
+The installation is based on the following design decisions.
+
+- MBR-based partition table and BIOS / legacy boot
+- full disc encryption
+- Btrfs file system
+- only a minimalistic set of installed packages (no graphical environment)
+
+Those might change in the future. A GPT-based partition table and a UEFI boot
+based on a unified kernel image would be appreciated to support secure boot but
+could not be achieved so far.
+
+#### Installation
+
+First a virtual drive is created as a file as a starting point for the VM
+installation.
+
+```
+qemu-img create -f qcow2 archlinux.qcow2 8G
+```
+
+It is expected that the Arch Linux `*.iso` installation image is downloaded,
+verified and saved in the same folder. See the [download page][3] for details.
+
+The installation image can be booted with `qemu-system-x86_64`. The just
+created virtual machine disk is attached as an additional drive.
+
+```
+qemu-system-x86_64 \
+ -enable-kvm \
+ -m 4G \
+ -nic user,model=virtio \
+ -drive file=archlinux.qcow2,media=disk,if=virtio \
+ -smp cpus=4 \
+ -nographic \
+ -boot order=d \
+ -cdrom archlinux-*.iso
+```
+
+On the first screen of the bootloader it needs to be specified that only the
+serial console should be used which is mapped to the host terminal. For that
+purpose the text below has to be typed before the bootloader picks the default
+options.
+
+```
+<TAB> console=ttyS0
+```
+
+This is annoying but worth it since it allows to copy and paste all subsequent
+commands instead of typing them by hand.
+
+After specifying the console the installation image should boot. Next the user
+`root` without password is used to log in.
+
+The following command allows to check if the time is properly synchronized.
+
+```
+timedatectl
+```
+
+The virtual machine disk can be partitioned with `parted`.
+
+```
+parted /dev/vda --script mklabel msdos
+parted /dev/vda --script mkpart primary fat32 1MiB 2GiB
+parted /dev/vda --script mkpart primary 2GiB 100%
+parted /dev/vda --script set 1 boot on
+```
+
+Answer following questions of luksFormat.
+
+```
+cryptsetup luksFormat --batch-mode --label CRYPTO_ROOT /dev/vda2
+cryptsetup open /dev/vda2 root
+```
+
+```
+mkfs.vfat -n BOOT /dev/vda1
+mkfs.btrfs -L ROOT /dev/mapper/root
+```
+
+```
+mount /dev/mapper/root /mnt
+mount --mkdir /dev/vda1 /mnt/boot
+```
+
+```
+systemctl start reflector
+```
+
+```
+pacstrap -K /mnt \
+ base \
+ linux \
+ linux-firmware \
+ parted \
+ syslinux \
+ btrfs-progs \
+ networkmanager \
+ chrony \
+ nano \
+ htop \
+ openssh \
+ man-db \
+ man-pages \
+ texinfo
+```
+
+```
+genfstab -L /mnt | tee /mnt/etc/fstab
+```
+
+```
+arch-chroot /mnt
+```
+
+```
+ln -sf /usr/share/zoneinfo/Europe/Berlin /etc/localtime
+hwclock --systohc
+sed -i 's/#en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/g' /etc/locale.gen
+locale-gen
+echo 'LANG=en_US.UTF-8' > /etc/locale.conf
+echo 'archlinux' > /etc/hostname
+echo 'root' | passwd -s
+systemctl enable NetworkManager
+systemctl enable chronyd
+```
+
+```
+mkdir -p /boot/syslinux
+cp /usr/lib/syslinux/bios/*.c32 /boot/syslinux/
+extlinux --install /boot/syslinux
+dd bs=440 count=1 conv=notrunc if=/usr/lib/syslinux/bios/mbr.bin of=/dev/vda
+cp /usr/share/syslinux/syslinux.cfg /boot/syslinux/
+sed -i 's|root=/dev/sda3 rw|cryptdevice=/dev/disk/by-label/CRYPTO_ROOT:root root=/dev/mapper/root rw|g' /boot/syslinux/syslinux.cfg
+```
+
+```
+sed -i 's/^HOOKS.*$/HOOKS=(base udev autodetect microcode modconf kms keyboard keymap consolefont block encrypt btrfs filesystems fsck)/g' /etc/mkinitcpio.conf
+mkinitcpio -P
+```
+
+```
+exit
+poweroff
+```
+
+```
+qemu-img convert -f qcow2 -O raw archlinux.qcow2 archlinux.img
+```
+
+```
+dd if=archlinux.img of=/dev/sdb bs=512 status=progress
+```
+
+Resizing last partition to full extend
+
+```
+parted /dev/sdb --script resizepart 2 100% # TODO replace static path
+cryptsetup resize root # interactive / password required
+btrfs filesystem resize max /
+```
+
+[1]: https://archlinux.org/
+[2]: https://wiki.archlinux.org/title/Installation_guide
+[3]: https://archlinux.org/download/