summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2024-07-20 15:03:25 +0200
committerxengineering <me@xengineering.eu>2024-07-20 18:33:02 +0200
commit2f2210b8ebf37a2737806b6841ce52a4ed26fa29 (patch)
tree53ab4cd1eca49b714cb8906d29196b4cccbee36c
parent9e006275150cde0c1102b11701481597fcd6527d (diff)
downloadcraft-2f2210b8ebf37a2737806b6841ce52a4ed26fa29.tar
craft-2f2210b8ebf37a2737806b6841ce52a4ed26fa29.tar.zst
craft-2f2210b8ebf37a2737806b6841ce52a4ed26fa29.zip
Document how to build an Arch Linux Guest VM
This is important to document how the guest VM is built since the image will not be committed.
-rw-r--r--.gitignore1
-rw-r--r--README.md82
2 files changed, 83 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..054ca6b
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+vms
diff --git a/README.md b/README.md
index 715e6c6..75ce45f 100644
--- a/README.md
+++ b/README.md
@@ -21,3 +21,85 @@ submodules to that location, execute the `build` function from the `craft.sh`
file inside the root of the repo and remove the temporary directory.
Log output is redirected to the calling terminal.
+
+## Build Arch Linux guest virtual machine for builds
+
+Craft will use a QEMU virtual machine to execute build processes. The following
+commands can be used to create an Arch Linux based virtual machine suitable for
+this purpose.
+
+It is expected that the Arch Linux installation image file
+(`archlinux-2024.02.01-x86_64.iso`) or a symbolic link to it is present in the
+root of the craft repository.
+
+```
+# create virtual machine disk file and boot with installation media
+qemu-img create -f qcow2 vms/archlinux.qcow2 30G
+qemu-system-x86_64 \
+ -enable-kvm \
+ -m 4G \
+ -nic user,model=virtio \
+ -drive file=vms/archlinux.qcow2,media=disk,if=virtio \
+ -smp cpus=4 \
+ -nographic \
+ -cdrom archlinux-2024.02.01-x86_64.iso
+
+# press TAB in bootloader menu and append ` console=ttyS0` to kernel args
+
+# check if time is synchronized
+timedatectl
+
+# create partitions and file systems
+parted /dev/vda --script mklabel msdos
+parted /dev/vda --script mkpart primary 1MiB 2GiB
+parted /dev/vda --script set 1 boot on
+parted /dev/vda --script mkpart primary 2GiB 100%
+mkfs.vfat -n BOOT /dev/vda1
+mkfs.btrfs -L ROOT /dev/vda2
+
+# mount root and boot partition
+mount /dev/vda2 /mnt
+mount --mkdir /dev/vda1 /mnt/boot
+
+# install Arch Linux packages
+pacstrap -K /mnt \
+ base \
+ linux \
+ linux-firmware \
+ syslinux \
+ btrfs-progs \
+ networkmanager \
+ chrony \
+ nano \
+ neovim \
+ htop \
+ which \
+ openssh \
+ rsync \
+ base-devel \
+ go
+
+# system configuration
+genfstab -L /mnt >> /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 'craft-archlinux' > /etc/hostname
+mkinitcpio -P
+echo 'root' | passwd -s
+systemctl enable NetworkManager
+systemctl enable chronyd
+
+# bootloader installation
+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
+sed -i 's|root=/dev/sda3 rw|root=/dev/vda2 rw console=ttyS0|g' /boot/syslinux/syslinux.cfg
+
+exit
+poweroff
+```