/arch-linux-installer

Arch Linux with ZFS installer

Primary LanguageShellMozilla Public License 2.0MPL-2.0

Arch Linux Installer

CI CI Status
License Crate license

Table of Contents

Usage

install

You can use the -h/--help flag to get:

$ ./bin/install --help
install 0.1.0

Arch Linux with ZFS installer.

USAGE:
    install [FLAGS] [OPTIONS] <DISK> <NETIF>

FLAGS:
    -e, --encrypt     Encrypts the partition for the zpool
                      (default: no)
    -h, --help        Prints help information
    -I, --hibernation Enables hibernation/resume (WARNING: experimental!)
                      (default: no)
    -S, --suffix      Appends a unique suffix to zpool names
    -V, --version     Prints version information
    -W, --no-swap     Do not include a swap partition
                      (default: create swap)

OPTIONS:
    -b, --boot-part=<PART>      Choose a boot partition for type partition
                                (ex: nvme0n1p3)
    -E, --encrypt-pass=<FILE>   Read the root pool password from file
                                (default: prompt)
    -l, --legacy-part=<PART>    Choose a legacy BIOS boot partition for
                                type partition (ex: nvme0n1p5)
    -p, --partition=<TYPE>      Choose a partitioning type (default: whole)
                                (values: existing, remaining, whole)
    -P, --root-pass=<FILE>      Read initial root password from file
                                (default: prompt)
    -r, --root-part=<PART>      Choose a root partition for type partition
                                (ex: nvme0n1p4)
    -s, --swap-part=<PART>      Choose a swap partition for type partition
                                (ex: nvme0n1p2)
    -t, --timezone=<TZ>         Timezone (ex: `America/Edmonton')
                                (default: `UTC')
        --bpool-size=<SIZE>     Size for boot pool partition, using sgdisk
                                sizes (default: 4G)
        --esp-size=<SIZE>       Size for ESP partition if using whole
                                partitioning type, using sgdisk sizes
                                (default: 4G)
        --rpool-size=<SIZE>     Size for root pool partition, using sgdisk
                                sizes (default: empty, uses all remaining)
        --swap-size=<SIZE>      Size for swap partition if enabled, using
                                sgdisk sizes (default: size of RAM)

ARGS:
    <DISK>      The disk to use for installation (ex: `nvme0n1')
                This can be found by using the `lsblk' program.
    <NETIF>     The network interface to setup for DHCP (ex: `ens33')
                This can be found by using the `ip addr' program.

EXAMPLES:
    Example 1 Installing with default behavior
      The following command installs Arch Linux using the whole disk,
      with a swap partition, without encryption, and a timezone of
      `UTC'.

      # install nvme0n1 ens33

    Example 2
      The following command installs Arch Linux using the whole disk,
      without a swap partition, with root pool encryption, and a
              timezone of Mountain time in North America.

      # install --encrypt --no-swap -timezone=America/Edmonton \
        nvme0n1 ens33

    Example 3
      The following command installs Arch Linux using the remaining space
      on the disk, with a swap partition, without encryption, and a
      timezone of `UTC'.

      # install --partition=remaining nvme0n1 ens33

AUTHOR:
    Fletcher Nichol <fnichol@nichol.ca>

remote-install

You can use the -h/--help flag to get:

./bin/remote-install --help

Custom Version of Kernel

If the version of archzfs-linux requires an older version of linux and linux-headers you can download an older version of each of these from the rolling release archives at: https://archive.archlinux.org/repos/YYYY/MM/DD/core/os/x86_64/. You can create an override/ directory which will be used by archiso/build to add an [override] Arch repository and will start a web server to serve up packages back to itself. For this, you'll also need to run repo-add (on an Arch system) in that directory to prepare the metadata files.

./libexec/run-with-docker
cd archiso
mkdir override
cd override

version=5.3.13.1-1
date=2019/12/02
url="https://archive.archlinux.org/repos/$date/core/os/x86_64"
for u in $url/linux{,-headers}-${version}.arch1-1-x86_64.pkg.tar.zst{,.sig}; do
  curl -SfL $u -o $(basename $u)
done
repo-add override.db.tar.xz *.pkg.tar.zst

Recovering a System with ArchISO

Start the system with an Archiso USB key or CD/DVD image mounted to boot from.

Login

(Optional) Once booted, the system may require network connectivity if it isn't plugged into wired networking. In this case, connect to a Wifi network with:

wifi-menu

(Optional) If it's easier to connect to the system remotely, then use SSH and connect with the root user. To ignore the randomly generated server key use ssh options with:

ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@$HOST

Find Partitions

Let's start by setting up some variables for the boot and root ZFS pools:

boot_pool=bpool
root_pool=rpool

To find the EFI System Partition (ESP):

esp_dev="$(fdisk -l | awk '/EFI System$/ { print $1 }')"

Import Pools

Next, import the ZFS pools with:

zpool import -N -d /dev/disk/by-id -R /mnt "$root_pool"
zpool import -N -d /dev/disk/by-id -R /mnt "$boot_pool"

(Optional) Opening Encrypted Partitions

If the root pool is encrypted then decrypt it with:

zfs load-key "$root_pool"

Mount Filesystems

The ZFS filesystems need to be mounted in a particular order to replicate how they would be presented on a booted system:

# Root fs has `canmount=off` so must be mounted explicitly first
zfs mount "$root_pool/ROOT/default"

# Boot fs has `mountpoint=legacy` so must be mounted with target
mount -t zfs "$boot_pool/BOOT/default" /mnt/boot

# Remaining fs can be auto-mounted
zfs mount -a

Finally, the ESP can be mounted:

mount "$esp_dev" /mnt/boot/efi

Chroot into System

Now that the filesystem is setup, enter a chroot with:

arch-chroot /mnt /bin/bash

And when done, exit to exit the chroot:

exit

Unmount Filesystems

Unmounting the filesystems work in the reverse order of mounting:

umount /mnt/boot/efi
zfs unmount -a
umount /mnt/boot
zfs unmount "$root_pool/ROOT/default"

Export Pools

Ensure that the ZFS pools are exported so they will cleanly import on the next system boot:

zpool export "$boot_pool"
zpool export "$root_pool"

Reboot

And finally, reboot while ensuring that the USB key or CD/DVD is removed on bootup:

reboot

References

ZFS Root Installation Reference Materials

Package Repository Links

Code of Conduct

This project adheres to the Contributor Covenant code of conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to fnichol@nichol.ca.

Issues

If you have any problems with or questions about this project, please contact us through a GitHub issue.

Contributing

You are invited to contribute to new features, fixes, or updates, large or small; we are always thrilled to receive pull requests, and do our best to process them as fast as we can.

Before you start to code, we recommend discussing your plans through a GitHub issue, especially for more ambitious contributions. This gives other contributors a chance to point you in the right direction, give you feedback on your design, and help you find out if someone else is working on the same thing.

Authors

Created and maintained by Fletcher Nichol (fnichol@nichol.ca).

License

Licensed under the Mozilla Public License Version 2.0 (LICENSE.txt).

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the MPL-2.0 license, shall be licensed as above, without any additional terms or conditions.