Skip to content

Instantly share code, notes, and snippets.

@redxef
Last active July 20, 2018 10:24
Show Gist options
  • Save redxef/7de6c45b6976a370465112aa6d3c7f71 to your computer and use it in GitHub Desktop.
Save redxef/7de6c45b6976a370465112aa6d3c7f71 to your computer and use it in GitHub Desktop.

Howto, install Arch with EFI boot

1. What you'll need

  • Arch-Linux live Image download
  • VirtualBox + Extension Pack download
  • A USB KEY for Arch Linux This device will be formatted, back up any data left on it
  • The knowledge to use the terminal/command line

*All instructions have been taken form the Arch wiki link

2. Converting the install iso to a VDI device

Since we want to install Arch-Linux for EFI systems, we need to boot in EFI mode. This is not possible, if the install-media is recognized as a optical disk. Thus we are going to convert the disk to an VDI disk image.

  1. Install VirtualBox and the Extension Pack
  2. Open Terminal (Spitlight: Terminal)
  3. Type in the command:
    VBoxManage convertfromraw path/to/arch.iso path/to/arch.iso.vdi
    Note, the spaces! To easily get the path, you can just drop the item from Finder into the Terminal window. The last argument is the output file, this you cant drop it, but will need to drop the iso and append .vdi or something like this to the String.
  4. The program should have created a file with .vdi at the end, you don't need the iso anymore, delete it.

3. Setting up the install Environment

Since modern Apple devices have High DPI we are going to use VirtualBox for the creation of the usb key.

  1. Create a new Box which is named Arch (VB will automatically select Arch as OS and the correct bitness - 32 or 64 bit)
  2. Select the Box and click Settings
  3. Go to System>Motherboard and Tick the Enable EFI (special OSes only) checkbox
  4. Go to Storage and remove the empty disc slot under Controller: IDE
  5. Click on the disc icon on the righ beside Controller: SATA choose the arch-linux live vdi image
  6. Remove all drives Controller: SATA/IDE
  7. Exit Settings and Boot the System

4. Configuring the live boot

  1. After starting up the VirtualBox you should be presented with a simple menu, if not, retrace your steps and try again
  2. You should not need to do anything, after a short delay the live usb will boot. If this is not the case the choose option which mentions Arch Linux (ex. Arch Linux archiso x86_64 UEFI USB on my system)
  3. After the boot process you should be presented with a command prompt (root@archiso ~#), this is the root prompt, be careful from now on when messing with partitions, you can mess up anything attached to the system in this prompt.
  4. Verify that the system is booted in EFI mode with ls /sys/firmware/efi/efivars, after hitting enter there should pop up a lot of text describing the system efi variables. If this is not the case, then you have booted using BIOS and can't install Arch Linux for EFI systems (thats a lie, it can be done, but its inconvenient).
  5. Since we are using VirtualBox, there should be no need to set up a connection, VirtualBox uses the connection from your HOST-PC. Check, if we really have internet access: ping google.com
    You can abort any command by pressing CTRL+C
  6. Type timedatectl set-ntp true to ensure the system clock is accurate.
4.1 Partitioning the disk
  1. Insert the USB-KEY you want to install the System to
  2. On the host os, click on Devices>USB and klick on your device, it should now be connected to the guest os
  3. type fdisk -l to identify your device (it should be /dev/sdb if you have followed the instructions carefully until now)
  4. In the following instructions I am going to mention /dev/sdb, replace this with your true device failing to do so will format a different disk
  5. type gdisk /dev/sdb to enter the partitioning tool
  6. Create a new GPT partiton table (this will erase all partitions on the disk) by typing o
  7. Create a new efi partition: n
  • Select the partition number (1): ENTER
  • Select the first sector: ENTER
  • Specify the sice of the disk (200MiB): +200M
  • Set its HEX code to EFI: ef00
  1. Create a swap partition: n
  • Select the partition number (2): <enter>
  • Select the first sector: ENTER
  • Specify the sice of the disk, I went for 0.5GiB (512MiB): +512M
  • Set its HEX code to EFI: 8200
  1. Create a partition for the os to live in: n
  • Select the partition number (1): ENTER
  • Select the first sector: ENTER
  • Specify the sice of the disk (200MiB): ENTER
  • Set its HEX code to EFI: ENTER
  1. Write the changes to disk: w
  2. and quit: q
4.2 Format the parititions
  1. Format the EFI partition: mkfs.fat /dev/sdb1
  2. Format the OS partition: mkfs.ext4 /dev/sdb3
  3. Utilize sdb2 as swap: mkswap /dev/sdb2 && swapon /dev/sdb2

4.3 Installing Arch Linux

  1. Mount the OS partition: mount /dev/sdb3 /mnt
  2. Mount the efi partition: mkdir /mnt/boot && mount /dev/sdb1 /mnt
  3. Install the base system: pacstrap /mnt base base-devel
  4. Generate an fstab file for booting: genfstab -U /mnt >> /mnt/etc/fstab
  5. (Optional) Set the /tmp directory as a ramdisk: echo 'tmpfs /tmp tmpfs defaults,noatime,nosuid,nodev,noexec,mode=1777,size=512M 0 0' >> /mnt/etc/fstab

4.4 Configuring the system

It's finally time to enter our system! yay!

  1. Enter system: arch-chroot /mnt
  2. Set the locale: ln -s /usr/share/zoneinfo/<Region>/<City> /etc/localtime
    Example: ln -s /usr/share/zoneinfo/Europe/Vienna /etc/localtime
  3. Generate /etc/adjtime: hwclock --systohc
  4. Set your desired language, we are going to use the nano editor: nano /etc/locale.gen
  5. Search for your language ond uncomment both the UTF-8 and the ISO entries (uncomment = delete the leading #)
  6. Save: CTRL+O
  7. Exit: CTRL+X
  8. Add Language: echo "LANG=<your uncommented lang utf8>" > /etc/locale.conf
  9. Set the Host Name (you computer's name): hn='<yourname>' && echo "$hn" > /etc/hostname &&
    echo "127.0.0.1 $hn.localdomain $hn" >> /etc/hosts &&
    echo "::1 $hn.localdomain $hn" >> /etc/hosts
    Type this command in one line without the backslashes.
  10. Set the root password: passwd

4.5 Installing the EFI bootloader (systemd-boot)

  1. Install systemd: bootctl install
  2. Write the boot configuration:
  • outfile=/boot/loader/entries/arch.conf
  • echo 'title Arch Linux' > $outfile
  • echo 'linux /vmlinuz-linux' >> $outfile
  • echo 'initrd /initramfs-linux.img' >> $outfile
  • echo 'options root=UUID=' blkid | grep /dev/sdb3 | grep -o ' UUID="[^"]*"' |
    sed -n 's/ UUID="\([^"]*\)"/\1/p' >> $outfile
  • echo ' rw' >> $outfile

4.6 Finishing up

  1. Exit the OS: exit
  2. Unmount EFI partition: umount /mnt/boot
  3. Unmount OS partition: umount /mnt
  4. Shutdown the VirtualBox: shutdown -h +0
  5. PROFIT! USB Key is ready for booting on EFI systems.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment