Skip to content

brettaufheber/ubuntu-headless-installer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ubuntu Headless Installer

Introducing the ultimate lightweight tool for installing Ubuntu Linux from the command line: A Bash script that is only using debootstrap and chroot to get the job done.

Because the installation does not require any user interaction if fully configured, this solution is ideal for realising an automated server setup. Install Ubuntu directly on free partitions of the target hardware or create a USB live system and use it as a recovery solution.

What makes this installer special?
The installer is a headless tool, which means that no graphical user interface is required. It builds the system from scratch without using any pre-packaged OS image. Because each installation step can be seen in the script, this solution is very transparent and highly adaptable for personal needs.

Download new versions from the Git repository: https://github.com/brettaufheber/ubuntu-headless-installer

Dependencies

The debootstrap tool which is required by the installer, might not be installed.

sudo apt-get install debootstrap

Usage

This tool can be installed by calling the following command:

sudo ./install.sh

Tasks

Designed for flexibility, the installer supports direct installation on physical machines as well as virtual machines. Additionally, it provides support for generating LXC/LXD and Docker container images.

install-system

Install Ubuntu on physical machines or virtual machines.

Preparation: partitioning and formatting
  • Partitioning must be done before installation because the installer requires the system partition and optionally the home partition and boot specific partitions as block device files.

  • The block device file for the system partition must be unmounted before starting the installer.

  • The system partition is formatted during installation.

  • The home partition is not formatted during installation to keep the user data. Also, the boot specific partitions are not formatted during installation.

  • If the home partition or boot specific partitions are already mounted, the installer will use a bind-mount to build the whole directory tree for an installation inside a chroot environment. In case of a new home partition, formatting must be done manually.

Before installation, it must be clear which boot mode is used for the target hardware. Most computers nowadays use the UEFI (Unified Extensible Firmware Interface) standard but often support the legacy BIOS (Basic Input/Output System) what can be enabled in the boot settings. Both firmware interfaces are supported by the installer.

Examples
Example installation for UEFI boot mode
sudo ubuntu-installer install-system \
  -c <Ubuntu codename: bionic|focal|jammy|noble|...> \
  -n <hostname> \
  -u <your username> \
  --dev-root "/dev/nvme0n1p2" \
  --dev-boot-efi "/dev/nvme0n1p1" \
  --dev-home "/dev/nvme0n1p3"
Example installation for legacy BIOS boot mode
sudo ubuntu-installer install-system \
  -c <Ubuntu codename: bionic|focal|jammy|noble|...> \
  -n <hostname> \
  -u <your username> \
  --dev-root "/dev/sda1" \
  --dev-home "/dev/sda2" \
  --dev-mbr-legacy "/dev/sda"

install-system-raspi-lts

This task allows installation on a Raspberry Pi. Unlike the other tasks, which work via debootstrap, this one uses an official image to migrate all hardware-specific customizations.

At the moment only LTS versions of Ubuntu are supported for installation on the Raspberry Pi.

Preparation: partitioning and formatting

Please note the instructions from the install-system task.

Examples
Example installation
sudo ubuntu-installer install-system-raspi-lts \
  -c <Ubuntu codename: bionic|focal|jammy|noble|...> \
  -n <hostname> \
  -u <your username> \
  --dev-root "/dev/sda2" \
  --dev-boot-firmware "/sda1" \
  --dev-home "/dev/sda3"

Overview parameters and variables

command line parameter / environment variable used in this tasks description

‑‑help
‑h

  • install‑system

  • install‑system‑raspi‑lts

  • build‑lxc‑image

  • build‑docker‑image

If enabled the help text is shown and other arguments are ignored.

‑‑shell‑login
‑l

  • install‑system

  • install‑system‑raspi‑lts

This option allows logging into the shell for diagnostic purposes directly at the end of the installation.

‑‑copy‑network‑settings
‑k

  • install‑system

  • install‑system‑raspi‑lts

Allows copying network settings from the currently used system to the target medium. This is particularly useful for installations behind a proxy because it makes the network available out-of-the-box within the chroot environment.

‑‑codename < >
‑c < >

CODENAME

  • install‑system

  • install‑system‑raspi‑lts

  • build‑lxc‑image

  • build‑docker‑image

The first word of an Ubuntu codename in lowercase must be defined to refer to a specific Ubuntu version. See here to choose from available releases.
Required: yes

‑‑hostname‑new < >
‑n < >

HOSTNAME_NEW

  • install‑system

  • install‑system‑raspi‑lts

The hostname of the system to be created. If unspecified the hostname of the running system is used.
Default: The hostname of the running system

‑‑username‑new < >
‑u < >

USERNAME_NEW

  • install‑system

  • install‑system‑raspi‑lts

The username for the first user of the system to be created. If unspecified the username of the current shell session is used.
Default: The name of the current user

‑‑mirror < >

MIRROR

  • install‑system

  • install‑system‑raspi‑lts

  • build‑lxc‑image

  • build‑docker‑image

The mirror used to resolve software packages.
Default: http://archive.ubuntu.com/ubuntu

‑‑dev‑root < >

DEV_ROOT

  • install‑system

  • install‑system‑raspi‑lts

The path to the block device file of the system partition must be specified. This block device file must be unmounted during installation. See here for more information about device file names.
Required: yes

‑‑dev‑boot‑efi < >

DEV_BOOT_EFI

  • install‑system

To enable EFI boot, the path to the block device file of the EFI partition must be specified. It does not matter whether the EFI partition is mounted during installation.

‑‑dev‑boot‑firmware < >

DEV_BOOT_FIRMWARE

  • install‑system‑raspi‑lts

The firmware partition used by the Raspberry Pi should be specified as block device file, required to have a bootable system.

‑‑dev‑home < >

DEV_HOME

  • install‑system

  • install‑system‑raspi‑lts

To use a separate home partition, the path to the block device file of the home partition must be specified. It does not matter whether the home partition is mounted during installation.

‑‑dev‑mbr‑legacy < >

DEV_MBR_LEGACY

  • install‑system

To enable the legacy boot, the path to the block device file for the whole disk must be specified to address the master boot record (MBR).

‑‑tmp‑size < >

TMP_SIZE

  • install‑system

  • install‑system‑raspi‑lts

Used inside the fstab file to specify the size of the in-memory /tmp directory.
Default: 40% (of the available RAM)

‑‑bundles < >

BUNDLES

  • install‑system

  • install‑system‑raspi‑lts

  • build‑lxc‑image

  • build‑docker‑image

An optional comma separated list that allows installing additional software. See the topic "Software bundles" below.

‑‑bundles‑file < >

BUNDLES_FILE

  • install‑system

  • install‑system‑raspi‑lts

  • build‑lxc‑image

  • build‑docker‑image

The path to an optional file that contains information about bundles and related packages.

‑‑debconf‑file < >

DEBCONF_FILE

  • install‑system

  • install‑system‑raspi‑lts

  • build‑lxc‑image

  • build‑docker‑image

The path to an optional file that allows to pre-seed the debconf database.

‑‑dconf‑file < >

DCONF_FILE

  • install‑system

  • install‑system‑raspi‑lts

The path to an optional file that overwrites the GNOME dconf defaults.

‑‑post‑install‑cmd < >

POST_INSTALL_CMD

  • install‑system

  • install‑system‑raspi‑lts

  • build‑lxc‑image

  • build‑docker‑image

A user-specific command that will be executed at the end of the installation.

‑‑locales < >

LOCALES

  • install‑system

  • install‑system‑raspi‑lts

The locales (e.g. C.UTF-8, en_US.UTF-8, de_DE.UTF-8) of the system to be created. If unspecified the installer will ask interactively.

‑‑time‑zone < >

TIME_ZONE

  • install‑system

  • install‑system‑raspi‑lts

The time zone (e.g. UTC, Europe/Berlin) of the system to be created. If unspecified the installer will ask interactively.

‑‑user‑gecos < >

USER_GECOS

  • install‑system

  • install‑system‑raspi‑lts

Additional GECOS information for the first user of the system to be created.

‑‑password < >

PASSWORD

  • install‑system

  • install‑system‑raspi‑lts

The password for the first user of the system to be created. If unspecified the installer will ask interactively.

‑‑keyboard‑model < >

KEYBOARD_MODEL

  • install‑system

  • install‑system‑raspi‑lts

The keyboard model. If unspecified the installer will ask interactively. See file "/etc/default/keyboard" of another system to find matching values.

‑‑keyboard‑layout < >

KEYBOARD_LAYOUT

  • install‑system

  • install‑system‑raspi‑lts

The keyboard layout. If unspecified the installer will ask interactively. See file "/etc/default/keyboard" of another system to find matching values.

‑‑keyboard‑variant < >

KEYBOARD_VARIANT

  • install‑system

  • install‑system‑raspi‑lts

The keyboard variant. If unspecified the installer will ask interactively. See file "/etc/default/keyboard" of another system to find matching values.

‑‑keyboard‑options < >

KEYBOARD_OPTIONS

  • install‑system

  • install‑system‑raspi‑lts

The keyboard options. If unspecified the installer will ask interactively. See file "/etc/default/keyboard" of another system to find matching values.

Software bundles

Optionally, bundles (collection of software packages) can be installed together with the system. See the configuration files to get an overview of the used packages.

  • net: network tooling

  • virt: QEMU/KVM with tooling

  • dev: basic equipment for software developers

  • desktop: minimal GNOME desktop

  • laptop: power saving tools for mobile devices

  • x86: architecture specific tools and libraries (requires dev)

License

Copyright (c) 2018 Eric Löffler

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

install Ubuntu from command line via debootstrap and chroot

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages