Skip to content

Parabola GNU/Linux or Arch GNU/Linux auto deploy tool - install, configure, generate ISO and more

Notifications You must be signed in to change notification settings

RegalisTechnologies/archinstall

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

archinstall

archinstall is a simple tool which allow you to automatically deploy Arch GNU/Linux systems. It is designed for automation, archinstall supports different schemes and hooks.

Basic usage

To install basic Arch GNU/Linux in /tmp/arch directory just type:

$ mkdir /tmp/arch 
$ archinstall -t /tmp/arch -s base

Script will download and install required packages, generate initramfs. Then, you can use cp, tar, rsync etc. to copy your new system to device of your choice. After this operation, you need to install bootloader and configure /etc/fstab.

Hooks

Hook is a special group of functions, each hook is responsible for doing only one thing. For example hook detect_architecture will set target architecture based on /proc/cpuinfo.

Function naming:

  • hook_NAME_preinstall - will be executed before install hook
  • hook_NAME_install - will be executed as a main install routine
  • hook_NAME_postinstall - will be executed after install hook
  • hook_NAME_desc - will be executed when help requested

Each hook must implement at least one function. For example, internal hook base is responsible only for adding base packages into installation queue and it looks like this:

hook_base_preinstall() {
		info "adding base packages"
		add_packages "base base-devel grub-bios vim openssh net-tools tree";
}

Since we don not need to do anything else after the installation, we can omit definition of hook_base_posstinstall().

Schemes

Scheme is an ordered list of hooks. It defines which hooks should be called. Example scheme:

SCHEME_base="detect_architecture base pacman prepare_chroot build_mkcinitcpio"

Tuning

You can easily integrate your own hooks into archinstall script. For example, if you want to package your system after successful installation you can create hook named package and define it like this:

hook_package_postinstall() {
	tar -C ${TARGET} -c . -vf /tmp/arch.tar
}

Note: we use postinstall here.

Then, the only one thing to do is to define new scheme:

SCHEME_base_package="detect_architecture base pacman prepare_chroot build_mkcinitcpio prepare_chroot_cleanup package"

and register it:

register_scheme base_package

Note: To generate initramfs, we need to mount /proc, /sys and /dev, that is why prepare_chroot hook is placed before build_mkinitcpio. We do not want to include /proc, /sys and /dev into our tarball so it is required to place prepare_chroot_cleanup before package hook.

Then, you can install Arch GNU/Linux and create package with one shot:

$ archinstall -t /tmp/arch -s base_package

Built-in variables, hooks and schemes

Special variables:

  • TARGET - target directory
  • ARCHITECTURE - new system architecture
  • HOOKS - hooks scheduled for execution
  • PACKAGES - packages scheduled for for installation
  • REGISTERED_SCHEMES - list of all registered schemes
  • INSTALL_HOOK - current install hook

Functions:

  • add_packages - schedule packages for installation
    • $1...$n - packages
  • set_install_hook - set new install hook
    • $1 - new install hook
  • chroot_exec - execute program inside target's chroot environment
    • $1 - program to execute
    • $2...$n - program args

Tips and tricks

You can easily integrate archinstall with your own scripts. For example, you can use the following solution to dynamically load hooks/schemes into your script.

Directory structure:

.
├── hooks.d/
│   ├── build_initramfs
│   └── build_kernel
├── schemes.d/
│   ├── arch_pxe
│   └── arch_usb_squashfs
├── archinstall
└── my_archinstall_wrapper

2 directories, 6 files

We will use my_archinstall_wrapper as a wrapper around original archinstall:

#!/bin/bash

# Load archinstall
. archinstall

# Load hooks
for X in hooks.d/*; do 
	[[ -f $X ]] && . $X
done

# Load and register schemes:
for X in schemes.d/*; do 
	[[ -f $X ]] && . $X
	register_scheme $X
done

# Call original main routine and pass all arguments

main $@

Note: schemes must have exactly the same name as file (with SCHEME_ prefix - see Schemes section). For example schemes.d/arch_pxe must define arch_pxe scheme like this:

SCHEME_arch_pxe="(...)"

License

GPLv3

Copyright (C) Patryk Jaworski <[email protected]>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses.

About

Parabola GNU/Linux or Arch GNU/Linux auto deploy tool - install, configure, generate ISO and more

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages