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
The debootstrap tool which is required by the installer, might not be installed.
sudo apt-get install debootstrap
This tool can be installed by calling the following command:
sudo ./install.sh
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 Ubuntu on physical machines or virtual machines.
-
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.
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"
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"
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.
command line parameter / environment variable | used in this tasks | description |
---|---|---|
|
|
If enabled the help text is shown and other arguments are ignored. |
|
|
This option allows logging into the shell for diagnostic purposes directly at the end of the installation. |
|
|
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. |
|
|
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. |
|
|
The hostname of the system to be created. If unspecified the hostname of the running system is used. |
|
|
The username for the first user of the system to be created. If unspecified the username of the current shell session is used. |
|
|
The mirror used to resolve software packages. |
|
|
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. |
|
|
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. |
|
|
The firmware partition used by the Raspberry Pi should be specified as block device file, required to have a bootable system. |
|
|
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. |
|
|
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). |
|
|
Used inside the fstab file to specify the size of the in-memory |
|
|
An optional comma separated list that allows installing additional software. See the topic "Software bundles" below. |
|
|
The path to an optional file that contains information about bundles and related packages. |
|
|
The path to an optional file that allows to pre-seed the debconf database. |
|
|
The path to an optional file that overwrites the GNOME dconf defaults. |
|
|
A user-specific command that will be executed at the end of the installation. |
|
|
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. |
|
|
The time zone (e.g. UTC, Europe/Berlin) of the system to be created. If unspecified the installer will ask interactively. |
|
|
Additional GECOS information for the first user of the system to be created. |
|
|
The password for the first user of the system to be created. If unspecified the installer will ask interactively. |
|
|
The keyboard model. If unspecified the installer will ask interactively. See file "/etc/default/keyboard" of another system to find matching values. |
|
|
The keyboard layout. If unspecified the installer will ask interactively. See file "/etc/default/keyboard" of another system to find matching values. |
|
|
The keyboard variant. If unspecified the installer will ask interactively. See file "/etc/default/keyboard" of another system to find matching values. |
|
|
The keyboard options. If unspecified the installer will ask interactively. See file "/etc/default/keyboard" of another system to find matching values. |
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)
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/.