.. | ||
images | ||
COPYING | ||
LICENSE | ||
README.adoc | ||
TODO |
AIF-NG User Manual
Preface
About the Author
I am a GNU/Linux Systems/Network Administrator/Engineer — I wear a lot of hats. I have a lot of side projects to keep me busy when I’m not working at ${dayjob}, mostly to assist in other side projects and become more efficient and proficient at those tasks. “Shaving the yak,” [1] indeed.
I got frustrated at the lack of options for installing Arch from a network or automated deployment environment and decided I needed a tool to do that for me.
What is AIF-NG?
AIF-NG (Arch Installation Framework, Next Generation) is a means to automatically install Arch Linux. Think of it as something akin to Kickstart.
AIF (classic) was written entirely in bash, required compilation, wasn’t flexible enough, and is obsolete/no longer maintained. So I rewrote it in Python3 and give it a more basic yet flexible structure.
The client (aifclient.py
) is a single script and gets its configuration from a combination of an XML file and kernel paramaters (which tell it where to find the former and how to access it).
AIF-NG is intended mainly for system administrators but if you find yourself turning up a lot of Arch Linux installations in other environments, you may find it useful.
What it’s Not
AIF-NG is not intended to be a complete turnup solution. Instead, it’s useful to build up from baremetal and configure a system to a point where you can use another management tool (such as Ansible, Chef, Puppet, SaltStack, and others).
Though if you’re really gung-ho about it, I suppose you could use the post-script feature to fully turn up a box.
It is also not a magic bullet. It will not make an Arch Linux installation easier, nor is it designed to do that. Don’t file bug reports for this. It’s designed to make it faster. I recommend you follow the manual installation process several times first so you’re comfortable with the process and understand what’s happening behind the scenes. (If you find it too hard to understand, you may instead be interested in Antergos instead.)
Copyright/Licensing
The AIF-NG code is GPLv3-licensed. This means that you can use it for business reasons, personal reasons, modify it, etc. Please be sure to familiarize yourself with the full set of terms. You can find the full license in docs/LICENSE
.
This document, and all other associated author-generated documentation, are released under the Creative Commons CC-BY-SA 4.0 copyright. It’s essentially the GPL for non-software, so similar terms apply.
Getting Started
Downloading
If it isn’t in your distro’s repositories (It is in Arch’s AUR! Both tagged release and git master.), you can still easily get rolling. Simply visit the project’s source code web interface and download a tarball under the Download column:
If you know the tag of the commit you want, you can use curl:
curl -sL -o aif.tar.xz https://git.square-r00t.net/AIF-NG/snapshot/AIF-NG-0.01-BETA.tar.xz
or wget:
wget -O aif.tar.xz https://git.square-r00t.net/AIF-NG/snapshot/AIF-NG-0.01-BETA.tar.xz
You can use https://git.square-r00t.net/AIF-NG/snapshot/AIF-NG-master.tar.xz
for the URL if you want the latest working version. If you want a snapshot of a specific commit, you can use e.g. https://git.square-r00t.net/AIF-NG/snapshot/AIF-NG-0e3b4572f9bc460741fe5cd3108b22fad89bfc71.tar.xz
and so on.
Alternatively, you can use git. Git most definitely should be in your distro’s repositories.
Tip
|
If you’re new to git and want to learn more, I highly recommend the book Pro Git. It is available for free download (or online reading). |
You can clone via https:
git clone https://git.square-r00t.net/AIF-NG
or native git protocol:
git clone git://git.square-r00t.net/aif-ng.git AIF-NG
The git protocol is much faster, but at a cost of lessened security.
Note
|
I also have a mirror at GitHub, but I don’t like GitHub very much and since it’s a mirror repository, it’s possible it will be out of date. For this reason, it’s recommended that you use the resources above. |
Prerequisites
This is a list of software you’ll need available to use the AIF-NG client.
Tip
|
Your distro’s package manager should have most if not all of these available, so it’s unlikely you’ll need to install from source. |
Note
|
Some versions may be higher than actually needed. |
Necessary
These are needed for using AIF-NG.
-
Python (>=3.6)
-
arch-install-scripts (for
pacstrap
)-
This has some useful methods of installing them in a non-Arch Linux distro.
-
These are no required Python modules, at least for the client; it will work fine with just the standard library for Python 3.
Starting an Install
First, aifclient.py
(/usr/bin/aifclient
in AUR packages) must be configured to start at boot after networking has initiated in the host environment. This can be done very easily with a oneshot systemd unit file.
However, this will do nothing on its own. This is a security measure; you can very easily destroy the host’s installation if you attempt to run AIF-NG with an inappropriate configuration. For this reason, AIF-NG will exit if it is not enabled via the kernel commandline/boot parameters (mkinitcpio hooks may be provided in future updates to the AUR packages to assist in creating more lightweight install environments).
Configure your bootloader to add the following options as necessary:
Parameter | Purpose |
---|---|
|
This enables AIF-NG; without this, a run will never be initiated — note that |
|
The URI to your XML configuration file (see below) |
|
(see below) |
|
(see below) |
|
(see below) |
|
(see below) |
Some notes on auth and URIs
-
aif_url
can be an HTTP/HTTPS URL, an FTP/FTPS URI, or afile://
URI. e.g.:-
aif_url=http://aif.square-r00t.net/aif.xml
-
aif_url=https://aif.square-r00t.net/aif.xml
-
aif_url=ftp://ftp.domain.tld/bootstrap/aif.xml
-
aif_url=ftps://secure.ftp.domain.tld/bootstrap/aif.xml
-
aif_url=file:///srv/aif/aif.xml
-
-
If
aif_url
is an HTTP/HTTPS URL, thenaif_user
is the username to use with the 401 (RFC 7235) auth (viaaif_auth
).-
If
aif_url
is an FTP/FTPS URI, thenaif_user
will be the FTP user. -
The same behavior applies for
aif_password
.
-
-
If
aif_auth
isdigest
, this is the realm we would use (we attempt to "guess" if it isn’t specified); otherwise it is ignored.
Logging
Currently, only one method of logging is enabled, and is always enabled. It can be found on the host and guest at /root/aif.log.<UNIX epoch timestamp>. Note that after the build finishes successfully, it will remove the host’s log (as it’s just a broken symlink at that point). You will be able to find the full log in the guest after the install, however.
Debugging
Sometimes it’s useful to get a little more information, or to start an installation from within an already-booted environment and you didn’t remember (or weren’t able to) change the kernel parameters. If this is the case, simply export the DEBUG
environment variable (it can be set to anything, it doesn’t matter) — if this is done, the arguments will be read from /tmp/cmdline instead. e.g.:
rm -f * export DEBUG=true cp /proc/cmdline /tmp/. chmod 600 /tmp/cmdline sed -i -e '1s/$/ aif aif_url=https:\/\/aif.square-r00t.net\/aif.xml/' /tmp/cmdline
It will also write the full configuration (after parsing) to the logfile.
Writing an XML Configuration File
I’ve included a sample aif.xml
file with the project which is fully functional. However, it’s not ideal — namely because it will add my personal SSH pubkeys to your new install, and you probably don’t want that. However, it’s fairly complete so it should serve as a good example. If you want to see the full set of supported configuration elements, take a look at the most up-to-date aif.xsd. For explanation’s sake, however, we’ll go through it here. The directives are referred to in XPath syntax within the documentation text for easier context (but not the titles).
<aif>
The /aif
element is the root element. It serves as a container for all the configuration data. The only attributes it contains are for formatting and verification of the containing XML.
<storage>
<disk>
The /aif/storage/disk
element holds information about disks on the system, and within this element are one (or more) part elements.
Attribute | Value |
---|---|
|
The disk to format (e.g. |
|
<part>
The /aif/storage/disk/part
element holds information on partitioning that it’s parent disk element should have.
Attribute | Value |
---|---|
|
The partition number (positive integer) |
|
The amount of the total disk size to start the partition at (see below) |
|
The amount of the total disk size to end the partition at (see below) |
|
The partition type. Must be in gdisk format (see below) |
The start
and size
attributes can be in the form of:
-
A percentage, indicated by a percentage sign (
"10%"
) -
A size, indicated by the abbreviation (
"300K"
,"30G"
, etc.)-
Accepts K (Kilobytes), M (Megabytes), G (Gigabytes), T (Terabytes), or P (Petabytes — I know, I know.)
-
Can also accept modifiers for this form (
"+500G"
,"-400M"
)
-
Note
|
The following is a table for your reference of partition types. Note that it may be out of date, so reference the link above for the most up-to-date table. |
fstype | Formatting type |
---|---|
|
Microsoft basic data |
|
Microsoft reserved |
|
Windows RE |
|
ONIE config |
|
Plan 9 |
|
PowerPC PReP boot |
|
Windows LDM data |
|
Windows LDM metadata |
|
Windows Storage Spaces |
|
IBM GPFS |
|
ChromeOS kernel |
|
ChromeOS root |
|
ChromeOS reserved |
|
Linux swap |
|
Linux filesystem |
|
Linux reserved |
|
Linux /home |
|
Linux x86 root (/) |
|
Linux x86-64 root (/ |
|
Linux ARM64 root (/) |
|
Linux /srv |
|
Linux ARM32 root (/) |
|
Intel Rapid Start |
|
Linux LVM |
|
FreeBSD disklabel |
|
FreeBSD boot |
|
FreeBSD swap |
|
FreeBSD UFS |
|
FreeBSD ZFS |
|
FreeBSD Vinum/RAID |
|
Midnight BSD data |
|
Midnight BSD boot |
|
Midnight BSD swap |
|
Midnight BSD UFS |
|
Midnight BSD ZFS |
|
Midnight BSD Vinum |
|
OpenBSD disklabel |
|
Apple UFS |
|
NetBSD swap |
|
NetBSD FFS |
|
NetBSD LFS |
|
NetBSD concatenated |
|
NetBSD encrypted |
|
NetBSD RAID |
|
Recovery HD |
|
Apple HFS/HFS+ |
|
Apple RAID |
|
Apple RAID offline |
|
Apple label |
|
AppleTV recovery |
|
Apple Core Storage |
|
Acronis Secure Zone |
|
Solaris boot |
|
Solaris root |
|
Solaris /usr & Mac ZFS |
|
Solaris swap |
|
Solaris backup |
|
Solaris /var |
|
Solaris /home |
|
Solaris alternate sector |
|
Solaris Reserved 1 |
|
Solaris Reserved 2 |
|
Solaris Reserved 3 |
|
Solaris Reserved 4 |
|
Solaris Reserved 5 |
|
HP-UX data |
|
HP-UX service |
|
Freedesktop $BOOT |
|
Haiku BFS |
|
Sony system partition |
|
Lenovo system partition |
|
EFI System |
|
MBR partition scheme |
|
BIOS boot partition |
|
Ceph OSD |
|
Ceph dm-crypt OSD |
|
Ceph journal |
|
Ceph dm-crypt journal |
|
Ceph disk in creation |
|
Ceph dm-crypt disk in creation |
|
VMWare VMFS |
|
VMWare reserved |
|
VMWare kcore crash protection |
|
Linux RAID |
Note
|
Automatic formatting is currently only enabled for the following (subject to further configuration in later versions): |
fstype | Formatted as |
---|---|
|
vFAT32 (mkfs.vfat -F 32) |
|
" |
|
" |
|
GNU/Linux swap (mkswap) |
|
ext4 |
|
" |
|
" |
|
" |
|
" |
|
" |
|
" |
|
" |
<mount>
Attribute | Value |
---|---|
|
The device to mount |
|
Where it should be mounted to in the filesystem (on the host system, not the new installation); if |
|
The order in which it should be mounted. These should be unique positive integers. |
|
The filesystem type; usually this is not required but if you need to manually specify the type of filesystem, this will allow you to do it |
|
The mount options; provide the string exactly as it would be provided to mount(8)'s |
<network>
The /aif/network
element specifies network configuration(s). It contains iface ("interface") elements.
Attribute | Value |
---|---|
|
The hostname of the new installation |
<iface>
The /aif/network/iface
element specifies various network configurations. Currently only ethernet is supported, and only limited support for IPv6 is available (but future improvements/flexible capabilities are planned).
Attribute | Value |
---|---|
|
The interface name (in Predictable Interface Naming) (e.g. |
|
The address to be assigned to the interface (in CIDR format); can be |
|
One of |
|
The gateway address for the interface/protocol pairing; only used if |
|
The DNS resolver addresses, if you wish/need to manually specify them; pass as a comma-separated list |
If "auto" is specified for device
, the system will configure the first (and only the first) interface it finds with an active link with the provided address information.
If "auto" is specified for address
, then DHCP (or DHCPv6, depending on the configuration of netproto
).
Note
|
Setting netproto to "both" is really only useful if "auto" is specified for address .
|
<system>
The /aif/system
element is for handling general system configuration. It contains the users, users/user, users/user/home, users/user/xgroup, and service elements.
Attribute | Value |
---|---|
|
The timezone for the installed system (can be independent of the host system) |
|
The locale of the installed system (e.g. |
|
The path on the host that will serve as the chroot path. This should be where your new install’s / (root filesystem partition) is mounted at in mounts |
|
The keyboard layout (if not US) |
<users>
The /aif/system/users
element is used to specify users you wish to create (if any). It contains the user, user/home, and user/xgroup elements.
Attribute | Value |
---|---|
|
A properly hashed-and-salted password. See below |
Note
|
To generate a proper hashed/salted password, you may want to reference this section from BDisk's user manual (another project of mine). You can use this python script to generate one. If you specify an empty string, the password will be BLANK (i.e. you can log in with just the username). This is very insecure. If you specify a ! instead of a salted hash, TTY login will be disabled (though it will still be possible to log in via other means such as SSH pubkey auth — assuming you configure it beforehand. This has some added security benefits).
|
<user>
The /aif/system/users/user
element specifies user(s) to create. It contains xgroup and home elements.
Attribute | Value |
---|---|
|
The username/login name |
|
If (full) sudo access should be granted to this user (boolean; must be one of |
|
The salted/hashed password (see above) |
|
A comment (typically, the user’s real/full name) |
|
The UID of the user; if specified, must be a positive integer |
|
The primary group of the user (the default is to create a new group named after that user) |
|
The GID to use for the primary group; must be a positive integer |
<xgroup>
The /aif/system/users/user/xgroup
elements specifies one (or more) "eXtra groups" (i.e. non-primary) that AIF-NG should add the user to.
Attribute | Value |
---|---|
|
The group name |
|
If the group should be created (boolean; must be one of |
|
The GID to use (if creating); must be a positive integer and not be taken by an existing group |
<home>
The /aif/system/users/user/home
element contains information for a user's home directory. It can be only specified once per user, but it is optional.
Attribute | Value |
---|---|
|
The path for the home directory; useful if you don’t want it to be /home/<username> |
|
If the home directory should be created (boolean; must be one of |
<service>
The /aif/system/service
element holds information about services that should explicitly be enabled/disabled on boot.
Attribute | Value |
---|---|
|
The service name. It can be shortform ( |
|
A boolean that specifies if the service should be enabled ( |
<pacman>
The /aif/pacman
element contains the repos, repos/repo, mirrorlist, mirrorlist/mirror, software, and software/packages elements.
Attribute | Value |
---|---|
|
The command to use to install a package |
If you configured an alternate package utility (using a execution="pkg"
script entry), you can specify the command here. Note that it should be configured/called with necessary options to avoid the necessity of user involvement (since that’s the entire point of AIF-NG). e.g.:
<aif ... > ... <pacman command="apacman --needed --noconfirm --noedit --skipinteg -S"> ... </aif>
<repos>
The /aif/pacman/repos
element contains one (or more) repo element(s).
<repo>
The /aif/pacman/repos/repo
elements specify information for configuring the installed system’s /etc/pacman.conf (specifically, the repositories).
Attribute | Value |
---|---|
|
The name of the repository |
|
A boolean that specifies if the repository should be enabled ( |
|
The siglevel of the repository (e.g. |
|
The URI for the mirror; if it begins with |
<mirrorlist>
The /aif/pacman/mirrorlist
element contains elements that should be in /etc/pacman.d/mirrorlist
. It is optional; if it isn’t specified, the default distributed mirrorlist will be used instead.
<mirror>
The /aif/pacman/mirrorlist/mirror
elements are mirrorlist entries.
<software>
The /aif/pacman/software
element contains one (or more) package element(s) that describe software to install. It is optional.
<package>
The /aif/pacman/software/package
element holds information about software to be installed.
Attribute | Value |
---|---|
|
The name of the package (e.g. |
|
Optional, but you can specify which repository to install the package from (in the case of multiple repositories providing the same package) |
<bootloader>
The /aif/bootloader
element specifies a bootloader to install.
Attribute | Value |
---|---|
|
The bootloader to use; currently, the only supported values are |
|
If used for (U)EFI support; note that the install environment must be booted in UEFI mode and that |
|
This should be the absolute path (from within the newly installed system) to your ESP (if |
<scripts>
The /aif/scripts
element contains one or more script elements.
<script>
The /aif/scripts/script
elements specify scripts to be run at different stages during the install process. This is useful if you need to set up SSH pubkey authentication, for example, or configure mdadm so you can use that as a disk.
Attribute | Value |
---|---|
|
The URI to the script; can be an HTTP/HTTPS reference, an FTP/FTPS reference, or a local file reference ( |
|
A unique positive integer used to order the scripts during the run; note that e.g. pre- and post-scripts are executed at different points, so you can use the same |
|
Same behavior as |
|
Same behavior as |
|
Same behavior as |
|
Same behavior as |
|
(see below) |
There are several script types availabe for execution
. Currently, these are:
-
pre
-
pkg
-
post
pre scripts are run (in numerical order
) before the disks are even formatted. pkg scripts are run (in numerical order
) right before the packages are installed (this allows you to configure an alternate packager such as apacman) — these are run inside the chroot of the new install. pre scripts are run inside the chroot like pkg, but are executed very last thing, just before the reboot.
Further Information
Here you will find further info, other resources, and such relating to AIF-NG.
Bug Reports/Feature Requests
Note
|
It is possible to submit a bug or feature request without registering in my bugtracker. One of my pet peeves is needing to create an account/register on a bugtracker simply to report a bug! The following links only require an email address to file a bug (which is necessary in case I need any further clarification from you or to keep you updated on the status of the bug/feature request — so please be sure to use a valid email address). |
Bugs
If you encounter any bugs in AIF-NG, you can file a bug report here.
If you encounter any bugs (inaccurate information, typos, misformatting, etc.) in this documentation, you can file a bug report here.
Feature Requests
If you have any features you’d like to see or you think would help AIF-NG become even more useful, please file a feature request here.
If you have any suggestions on how to improve this documentation or feel it’s missing information that could be useful, please file a feature request here.
Patches
I gladly welcome patches, but I deplore using GitHub (even though I have a mirror there). For this reason, please follow the same patch/pull request process for the Linux kernel and email it to bts@square-r00t.net.
Alternatively, you may attach a patch to a bug report/feature request.
Contact the Author
If you have any questions, comments, or concerns, you can use the following information to get in touch with me.
I am available via email. If you use GPG, you can find my pubkey and other related info here (and on most keyservers).
I occasionally write howto articles, brief tips, and other information in my dev blog.
I am on IRC as r00t^2, and am usually in the Sysadministrivia channel on Freenode. Which reminds me, I run a podcast called Sysadministrivia.
I am on Twitter as @brentsaner, though I don’t tweet very often. (I usually tweet from my podcast’s twitter.)