Install Archlinux onto a USB key using QEMU Download the image Download a mirror from https://www.archlinux.org/download/ Save it to $HOME Launch the VM $ diskutil list to find out where the USB key is on the system we will assume it is located on disk2 $ diskutil unmount /dev/disk2 unmount the device so it is not busy when QEMU uses it $ sudo qemu-system-x86_64 -m 1024 -boot d -smp 3 -net nic -net user -hda arch.img -cdrom archlinux-XXXXXX.iso -drive file=/dev/disk2,format=raw,cache=none,if=virtio open the QEMU VM using the ISO by the name of the file downloaded to $HOME Bootstrap Arch We are now in the QEMU VM, and will continue to be until the octothorps (#) become dollar signs ($) # fdisk -l figure out where the device is located in this example, we assume it is located at vda # parted /dev/vda . mktable gpt . mkpart primary fat32 1MiB 261MiB . set 1 esp on . mkpart primary ext4 261MiB 100% . quit make the partition table, generate two partitions of filesystem FAT32 (260MiB) and ext4 (the rest) on a GPT partition table each line after parted should begin with (parted) but to avoid confusion we write this just as “.” [ # parted /dev/vda print ] test to see if everything is good # mkfs.ext4 /dev/vda2 initialise proper ext4 filesystem on the root # mount /dev/vda2 /mnt mount the root # mkfs.fat-F32/dev/vda1 initialise the proper FAT32 filesystem on the ESP # mkdir /mnt/efi create the mount point for the ESP # mount /dev/vda1 /mnt/efi mount the ESP [ # vi /etc/pacman.d/mirrorlist move different URLs around based on geographical location ] for better response times automatically generated as well, but rectification sometimes required # pacstrap /mnt base base-devel pacstrap the base and base-devel packages handle errors * If you get a key-signing issue: “Signature from Andreas Radke […] is invalid […] Errors occurred, no packages were upgraded,” try pacman-key --refresh-keys and re-run the pacstrap command Configure Arch # genfstab -U /mnt >> /mnt/etc/fstab generate fstab, which is used to disk partitions mount onto the filesystem optionally check the resultant output if you can understand it # arch-chroot /mnt temporarily set the mounted disk as the root all commands after this will not actually begin with an octothorp (#), however we will represent them as such # ln -sf /usr/share/zoneinfo/America/Los_Angeles /etc/localtime Set timezone to local time (change as necessary) # hwclock --systohc generate /etc/adjtime (specifics aren’t important, you’re dealing with time) # vi /etc/locale.gen uncomment necessary lines (e.g. en_US.UTF-8 UTF-8, bi_VS UTF-8, en_GB.UTF-8 UTF-8, es_CR.UTF-8 UTF-8) # locale-gen regenerate the locale (“write out” the previous file into use) [ # locale -a ] check to see if everything is as it should be # echo “LANG=en_US.UTF-8” > /etc/locale.conf set language # echo “archenemy-beta” > /etc/hostname set your hostname—we will assume archenemy-beta as a hostname this is what will appear on servers and such # vi /etc/hosts write the following: 127.0.0.1 localhost ::1 localhost 127.0.1.1 archenemy-beta.localdomain archenemy-beta change 127.0.0.1 to the permanent IP if it exists # passwd set the password Install & Configure GRUB2 # pacman -S grub efibootmgr install grub, which is a package that helps install GRUB2, and efibootmgr, which is used by the GRUB installation script to write to NVRAM # grub-install --target=x86_64-efi --efi-directory=/efi --bootloader-id=GRUB this actually installs GRUB2 and all necessary packages # grub-mkconfig -o /boot/grub/grub.cfg make the config file for GRUB2 Bless EFI # exit exit from the arch-chroot [ # umount -R /mnt ] unmount all partitions Exit into Terminal and ^C to stop QEMU $ mkdir ~/efi create the new mount point ~/efi $ sudo mount -w -t msdos /dev/disk2s1 ~/efi mount the EFI System partition onto the new mount point ~/efi $ bless --folder ~/efi/EFI/GRUB --file ~/efi/EFI/GRUB/grubx64.efi bless the EFI System partition to make it bootable Boot Arch $ reboot hold Alt whilst the computer reboots Click on Arch and hit enter Bibliography * https://wiki.archlinux.org/index.php/EFI_system_partition * https://wiki.archlinux.org/index.php/Parted#UEFI/GPT_examples * https://wiki.archlinux.org/index.php/Installation_guide * https://wiki.archlinux.org/index.php/GRUB#Installation_2 * https://bbs.archlinux.org/viewtopic.php?id=149229 (key signing error handling) * https://wiki.archlinux.org/index.php/EFI_system_partition#Check_for_an_existing_partition * https://wiki.archlinux.org/index.php/Help:Reading#Installation_of_packages * https://wiki.archlinux.org/index.php/GRUB#Generate_the_main_configuration_file * https://wiki.archlinux.org/index.php/Unified_Extensible_Firmware_Interface#UEFI_variables * https://bombich.com/kb/ccc4/what-makes-volume-bootable (bootability) * https://wiki.archlinux.org/index.php/Unified_Extensible_Firmware_Interface#Mount_efivarfs * https://wiki.archlinux.org/index.php/Unified_Extensible_Firmware_Interface#Mount_efivarfs * https://unix.stackexchange.com/questions/91620/efi-variables-are-not-supported-on-this-system (efivars) * https://wiki.gentoo.org/wiki/EFI_stub_kernel