Minimal Arch Install.
Simple working arch install before fermenting with more advanced configurations.
Arch Simple Install
- Three Partitions, ESP (Bootloader), Swap and Root
- No encryption
- Serve to experiment with more exotic configurations later
First create a (UEFI) VM and give the VM's disk a unique ID.
This can be done with virt-manager by going to the disk and giving it a serial number here we made it
9123456789
.
After booting into the live ISO we can get the IP address from the NIC in
virt-manager
or in the terminal of the VM with ip addr
ssh [email protected] -o "UserKnownHostsFile=/dev/null" -o "StrictHostKeychecking=no"
Clean the disk.
export DISK=/dev/disk/by-id/virtio-9123456789 wipefs -a $DISK blkdiscard -f $DISK sgdisk --zap-all $DISK
Creation Partitions
We can see partition types with the following.
sgdisk --list-types
# ESP (EFI System Partition) sgdisk -n1:1M:+2GB -t1:EF00 $DISK # Swap sgdisk -n2:0:+1G -t2:8200 $DISK # Root sgdisk -n3:0:0 -t3:8304 $DISK
Creating the filesystems on the partitions
# Make the ESP Filesystem mkfs.fat -F 32 ${DISK}-part1 # Swap mkswap ${DISK}-part2 # Root file system mkfs.ext4 ${DISK}-part3
Mount the partitions under
/mnt
mount --mkdir ${DISK}-part1 /mnt/esp swapon ${DISK}-part2 mount ${DISK}-part3 /mnt
Install the Operating System to
/mnt
pacstrap -K /mnt base linux linux-firmware
Generate the
fstab
file which tells linux how to mount the various file systems early in the booting process.
genfstab -U /mnt >> /mnt/etc/fstab
Chroot into the operating system, this is how you can get into the file system from another operating system during recovery procedures as well.
arch-chroot /mnt
Sync the hardware clock
ln -sf /usr/share/zoneinfo/America/Chicago /etc/localtime hwclock --systohc
Set Lang and Local
# This uncomments en_US.UTF-8 UTF-8 from /etc/locale.gen sed -i '/#en_US.UTF-8 UTF-8/s/^#//' /etc/locale.gen locale-gen
Set a hostname
echo "archvm" > /etc/hostname
Install a network manager
pacman -S networkmanager systemctl enable NetworkManager.service
Install OpenSSH Server
pacman -S openssh systemctl enable sshd.service
Set the password with
passwd
or chpasswd
# passwd printf 'root:arch' | chpasswd
Creating the Unified Kernel Image
We can save some time during boot by decompressing the images now.
sed -i '/#MODULES_DECOMPRESS="yes"/s/^#//' /etc/mkinitcpio.conf # Speed boot up by disabling compressed Unikernal sed -i '/^HOOKS=(base udev autodetect modconf kms keyboard keymap consolefont block filesystems fsck)/s/udev/systemd/' /etc/mkinitcpio.conf
We are going to replace the default mkinitcpio linux preset with one that creates a unikernal and mounts to the ESP partition
mkdir -p /esp/EFI/Linux cat << 'EOF' > /etc/mkinitcpio.d/linux.preset # mkinitcpio preset file for the 'linux' package #ALL_config="/etc/mkinitcpio.conf" ALL_kver="/boot/vmlinuz-linux" ALL_microcode=(/boot/*-ucode.img) PRESETS=('default' 'fallback') #default_config="/etc/mkinitcpio.conf" default_uki="/esp/EFI/Linux/arch-linux.efi" default_options="--splash=/usr/share/systemd/bootctl/splash-arch.bmp" fallback_uki="/esp/EFI/Linux/arch-linux-fallback.efi" fallback_options="-S autodetect" EOF
Regenerate
mkinitcpio -P
pacman -S efibootmgr efibootmgr --create --disk ${DISK} --part 1 --label "Arch Linux" --loader '\EFI\Linux\arch-linux.efi' --unicode efibootmgr --create --disk ${DISK} --part 1 --label "Arch Linux Fallback" --loader '\EFI\Linux\arch-linux-fallback.efi' --unicode
Exit and Reboot
exit umount -R /mnt reboot now
Recovery
export DISK=/dev/disk/by-id/virtio-9123456789 sleep 1 mount --mkdir ${DISK}-part1 /mnt/esp sleep 1 swapon ${DISK}-part2 sleep 1 mount ${DISK}-part3 /mnt arch-chroot /mnt