项目作者: fnichol

项目描述 :
Arch Linux with ZFS installer
高级语言: Shell
项目地址: git://github.com/fnichol/arch-linux-installer.git
创建时间: 2019-12-30T21:43:27Z
项目社区:https://github.com/fnichol/arch-linux-installer

开源协议:Mozilla Public License 2.0

下载


Arch Linux Installer

CI ![CI Status][badge-ci-overall]
License Crate license

Table of Contents

Usage

install

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

  1. $ ./bin/install --help
  2. install 0.1.0
  3. Arch Linux with ZFS installer.
  4. USAGE:
  5. install [FLAGS] [OPTIONS] <DISK> <NETIF>
  6. FLAGS:
  7. -e, --encrypt Encrypts the partition for the zpool
  8. (default: no)
  9. -h, --help Prints help information
  10. -I, --hibernation Enables hibernation/resume (WARNING: experimental!)
  11. (default: no)
  12. -S, --suffix Appends a unique suffix to zpool names
  13. -V, --version Prints version information
  14. -W, --no-swap Do not include a swap partition
  15. (default: create swap)
  16. OPTIONS:
  17. -b, --boot-part=<PART> Choose a boot partition for type partition
  18. (ex: nvme0n1p3)
  19. -E, --encrypt-pass=<FILE> Read the root pool password from file
  20. (default: prompt)
  21. -l, --legacy-part=<PART> Choose a legacy BIOS boot partition for
  22. type partition (ex: nvme0n1p5)
  23. -p, --partition=<TYPE> Choose a partitioning type (default: whole)
  24. (values: existing, remaining, whole)
  25. -P, --root-pass=<FILE> Read initial root password from file
  26. (default: prompt)
  27. -r, --root-part=<PART> Choose a root partition for type partition
  28. (ex: nvme0n1p4)
  29. -s, --swap-part=<PART> Choose a swap partition for type partition
  30. (ex: nvme0n1p2)
  31. -t, --timezone=<TZ> Timezone (ex: `America/Edmonton')
  32. (default: `UTC')
  33. --bpool-size=<SIZE> Size for boot pool partition, using sgdisk
  34. sizes (default: 4G)
  35. --esp-size=<SIZE> Size for ESP partition if using whole
  36. partitioning type, using sgdisk sizes
  37. (default: 4G)
  38. --rpool-size=<SIZE> Size for root pool partition, using sgdisk
  39. sizes (default: empty, uses all remaining)
  40. --swap-size=<SIZE> Size for swap partition if enabled, using
  41. sgdisk sizes (default: size of RAM)
  42. ARGS:
  43. <DISK> The disk to use for installation (ex: `nvme0n1')
  44. This can be found by using the `lsblk' program.
  45. <NETIF> The network interface to setup for DHCP (ex: `ens33')
  46. This can be found by using the `ip addr' program.
  47. EXAMPLES:
  48. Example 1 Installing with default behavior
  49. The following command installs Arch Linux using the whole disk,
  50. with a swap partition, without encryption, and a timezone of
  51. `UTC'.
  52. # install nvme0n1 ens33
  53. Example 2
  54. The following command installs Arch Linux using the whole disk,
  55. without a swap partition, with root pool encryption, and a
  56. timezone of Mountain time in North America.
  57. # install --encrypt --no-swap -timezone=America/Edmonton \
  58. nvme0n1 ens33
  59. Example 3
  60. The following command installs Arch Linux using the remaining space
  61. on the disk, with a swap partition, without encryption, and a
  62. timezone of `UTC'.
  63. # install --partition=remaining nvme0n1 ens33
  64. AUTHOR:
  65. Fletcher Nichol <fnichol@nichol.ca>

remote-install

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

  1. ./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.

  1. ./libexec/run-with-docker
  1. cd archiso
  1. mkdir override
  2. cd override
  3. version=5.3.13.1-1
  4. date=2019/12/02
  5. url="https://archive.archlinux.org/repos/$date/core/os/x86_64"
  1. for u in $url/linux{,-headers}-${version}.arch1-1-x86_64.pkg.tar.zst{,.sig}; do
  2. curl -SfL $u -o $(basename $u)
  3. done
  4. 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:

  1. 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:

  1. 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:

  1. boot_pool=bpool
  2. root_pool=rpool

To find the EFI System Partition (ESP):

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

Import Pools

Next, import the ZFS pools with:

  1. zpool import -N -d /dev/disk/by-id -R /mnt "$root_pool"
  2. 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:

  1. 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:

  1. # Root fs has `canmount=off` so must be mounted explicitly first
  2. zfs mount "$root_pool/ROOT/default"
  3. # Boot fs has `mountpoint=legacy` so must be mounted with target
  4. mount -t zfs "$boot_pool/BOOT/default" /mnt/boot
  5. # Remaining fs can be auto-mounted
  6. zfs mount -a

Finally, the ESP can be mounted:

  1. mount "$esp_dev" /mnt/boot/efi

Chroot into System

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

  1. arch-chroot /mnt /bin/bash

And when done, exit to exit the chroot:

  1. exit

Unmount Filesystems

Unmounting the filesystems work in the reverse order of mounting:

  1. umount /mnt/boot/efi
  2. zfs unmount -a
  3. umount /mnt/boot
  4. 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:

  1. zpool export "$boot_pool"
  2. zpool export "$root_pool"

Reboot

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

  1. reboot

References

ZFS Root Installation Reference Materials

Code of Conduct

This project adheres to the Contributor Covenant [code of
conduct][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][license]).

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.

[badge-check-format]:
https://img.shields.io/cirrus/github/fnichol/arch-linux-installer.svg?style=flat-square&task=check&script=format
[badge-check-lint]:
https://img.shields.io/cirrus/github/fnichol/arch-linux-installer.svg?style=flat-square&task=check&script=lint
[badge-ci-overall]:
https://img.shields.io/cirrus/github/fnichol/arch-linux-installer.svg?style=flat-square

[code-of-conduct]:
https://github.com/fnichol/arch-linux-installer/blob/master/CODE_OF_CONDUCT.md

[license]:
https://github.com/fnichol/arch-linux-installer/blob/master/LICENSE.txt