Automate Ubuntu Desktop installation
4 January 2025
3 min read
Starting from Ubuntu 23.04 you can automate the desktop installation using the autoinstall format file.
Ubuntu autoinstall allows to almost fully automate the setup of a new development environment. When combined with my dotfiles bootstrap script, this process takes less than 30 minutes.
Autoinstall format file
Below is an example autoinstall file from my setup. It uses Ubuntu Desktop minimal with disk encryption and automatically install codecs, drivers and update the system packages.
You can customize the configuration using the autoinstall reference documentation.
Passwords
The storage encryption password (storage.layout.password
) is plain text so avoid to commit this file to version control.
User password (identity.password
) must be encrypted instead. Use openssl passwd -6
command to generate a SHA512-based encrypted password.
Interactive sections
There is one important configuration missing from the above file: network.
When you boot the Live Ubuntu image, you need to configure the network before starting the autoinstall so it was omitted from my configuration file.
Securing the autoinstall file
To avoid committing sensitive information (like storage encryption password), I created a bash script to generate the autoinstall file. This approach allows versioning without exposing sensitive data.
You can find my ubuntu-autoinstall.sh script in my dotfiles. If you plan to use it, remember to update the hardcoded configuration options according to your preferences.
How to use the autoinstall file
- Boot into Live Ubuntu image
- Configure Language, Accessibility, Keyboard, Network and then select Try Ubuntu
- Verify that the system works as expected
- Download/create the autoinstall file or generated it with the above script
- Open Install Ubuntu app and proceed to Type of installation section
- Select Automated Install and provide the autoinstall file URI (e.g
file:///home/ubuntu/ubuntu-autoinstall.yaml
) - Wait for validation, review the configuration file and proceed with the installation
Bonus: validate autoinstall format file
You can validate the autoinstall file before booting Live Ubuntu image, using subiquity’s validate-autoinstall-user-data.py
script.
Note that the validation process has limitations, as mentioned in the Validator Limitations section of the documentation.
I created a Docker container to run the script:
Build the Docker image:
Generate the autoinstall file and then validate it by running the Docker container: