linux-surface / aarch64-arch-mkimg

Scripts to create Arch Linux AArch64 disk images (e.g. for flashing to a USB stick), adapted for the Surface Pro X
MIT License
15 stars 7 forks source link

AArch64 Arch Linux Bootable Disk Image Utility

Utility to create a bootable and easily customizable AArch64 Arch Linux disk image. Supports running on x86 hosts via binfmt_misc and qemu-user-static.

Usage

The aarch64-arch-mkimage utility allows for multiple profiles, which, in essence, shape the generated disk image. See notes below for running on an x86 host system.

Running the script directly requires an Arch Linux host system. To build a disk image or file system trees, run

sudo ./aarch64-arch-mkimg <profile>

where <profile> is the desired profile. Outputs and intermediate build files are stored in ./build. Disk images are written to ./build/disk.img and final file system trees to ./build/disk/root for the root partition and ./build/disk/efi for the EFI/EFS partition.

You can also run the script via the provided Docker container (e.g. in case you do not have access to an Arch Linux host system). A pre-built container for an x86 host can be obtained via

docker pull ghcr.io/linux-surface/aarch64-arch-mkimg

Disk images can then be generated via

docker run --rm --privileged                  \
    --mount type=tmpfs,destination=/run/shm   \
    -v /dev:/dev                              \
    -v "${PWD}/build":/build                  \
    aarch64-arch-mkimg <profile>

Default login credentials are the ones provided by the Arch Linux ARM root file system, i.e. user/password alarm/alarm and root/root. Note that, by default, an OpenSSH server is running. Therefore, please do not connect this machine directly to the internet (without firewall) before changing those.

Running on an x86 Host

To run this script on an x86 host, emulation for AArch64 is needed. This can be set up via binfmt_misc and qemu-user-static. See e.g. https://github.com/multiarch/qemu-user-static for details on how to set this up. In short, running

docker run --rm --privileged multiarch/qemu-user-static --reset -p yes

should set everything up for you.

Details

The aarch64-arch-mkimage utility works in three major steps:

  1. The basic root file system (rootfs) is prepared using the official Arch Linux ARM root archive and base files specified in the profile (profiles/<name>/base, these are simply copied to the rootfs tree).
  2. The utility switches into the prepared root tree via arch-chroot. Here, requested packages (profiles/name/packages) are installed or uninstalled and customizations to the rootfs specified via the respective profile modules (profiles/<name>/modules) are applied.
  3. Depending on the profile, a disk image and/or root and EFI file system trees are generated from the final rootfs. These are provided in build/disk.img and build/disk/efi as well as build/disk/root.

Profiles

Customization

You can create or adapt custom profiles. Each profile provides:

See the provided profiles for examples.