GithubHelp home page GithubHelp logo

autoinstall-desktop's Introduction

Using Ubuntu Live-Server to automate Desktop installation

Abstract

This document describes the procedure to perform an automated install of Ubuntu 22.04.x LTS Desktop. This is implemented by using the Ubuntu 22.04.x LTS Server ISO, installing Desktop on top, and removing unneeded default Server packages.

Introduction

The Ubuntu 22.04 LTS live-server ISO uses Subiquity, which means that the Subiquity Autoinstall format is used for automation.

This document was written for, and is up to date with, Ubuntu 22.04.1.

As a quick introduction to Autoinstall, it is a YAML format where the installer has default values for almost all of the configuration. As such, simple Autoinstalls can be very short, if the default configuration is acceptable.

This document covers just enough Autoinstall to get a Desktop experience. It's highly likely that the Autoinstall will need further configuration to meet practical installation requirements.

All sample configuration files and scripts can be found in this git repository.

For more information on Autoinstall, please see:

Autoinstall

Below is an almost-ready-to-use autoinstall.yaml. Please adjust the identity section to set a password hash and confirm the desired user information.

#cloud-config
autoinstall:
  # version is an Autoinstall required field.
  version: 1

  # This adds the default ubuntu-desktop packages to the system.
  # Any desired additional packages may also be listed here.
  packages:
    - ubuntu-desktop

  # This adds the default snaps found on a 22.04 Ubuntu Desktop system.
  # Any desired additional snaps may also be listed here.
  snaps:
    - name: firefox
    - name: gnome-3-38-2004
    - name: gtk-common-themes
    - name: snap-store
    - name: snapd-desktop-integration

  # User creation can occur in one of 3 ways:
  # 1. Create a user using this `identity` section.
  # 2. Create users as documented in cloud-init inside the user-data section,
  #    which means this single-user identity section may be removed.
  # 3. Prompt for user configuration on first boot.  Remove this identity
  #    section and see the "Installation without a default user" section.
  identity:
    realname: ''
    username: ubuntu
    # A password hash is needed. `mkpasswd --method=SHA-512` can help.
    # mkpasswd can be found in the package 'whois'
    password: '<password hash>'
    hostname: ubuntu-desktop

  # Subiquity will, by default, configure a partition layout using LVM.
  # The 'direct' layout method shown here will produce a non-LVM result.
  storage:
    layout:
      name: direct

  # Ubuntu Desktop uses the hwe flavor kernel by default.
  early-commands:
    - echo 'linux-generic-hwe-22.04' > /run/kernel-meta-package

  # The live-server ISO does not contain some of the required packages,
  # such as ubuntu-desktop or the hwe kernel (or most of their depdendencies).
  # The system being installed will need some sort of apt access.
  # proxy: http://192.168.0.1:3142

  late-commands:
    # Enable the boot splash
    - >-
      curtin in-target --
      sed -i /etc/default/grub -e
      's/GRUB_CMDLINE_LINUX_DEFAULT=".*/GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"/'
    - curtin in-target -- update-grub

    # Let NetworkManager handle network
    - rm /target/etc/netplan/00-installer-config*yaml
    - >-
      printf "network:\n  version: 2\n  renderer: NetworkManager"
      > /target/etc/netplan/01-network-manager-all.yaml

    # Remove default filesystem and related tools not used with the suggested
    # 'direct' storage layout.  These may yet be required if different
    # partitioning schemes are used.
    - >-
      curtin in-target -- apt-get remove -y
      btrfs-progs cryptsetup* lvm2 xfsprogs

    # Remove other packages present by default in Ubuntu Server but not
    # normally present in Ubuntu Desktop.
    - >-
      curtin in-target -- apt-get remove -y
      ubuntu-server ubuntu-server-minimal
      binutils byobu curl dmeventd finalrd gawk
      kpartx mdadm ncurses-term needrestart open-iscsi openssh-server
      sg3-utils ssh-import-id sssd thin-provisioning-tools vim tmux
      sosreport screen open-vm-tools motd-news-config lxd-agent-loader
      landscape-common htop git fonts-ubuntu-console ethtool

    # Keep cloud-init, as it performs some of the installation on first boot.
    - curtin in-target -- apt-get install -y cloud-init

    # Finally, remove things only installed as dependencies of other things
    # we have already removed.
    - curtin in-target -- apt-get autoremove -y

    # A postinstall script may optionally be used for further install
    # customization. Deploy this postinstall.sh script on the webserver.
    # - wget -O /target/postinstall.sh http://192.168.0.2/postinstall.sh
    # - curtin in-target -- bash /postinstall.sh
    # - rm /target/postinstall.sh

  # Additional cloud-init configuration affecting the target
  # system can be supplied underneath a user-data section inside of
  # autoinstall.
  # user-data:
  #

Postinstall script

At the end of the sample autoinstall.yaml is an example of downloading and calling an external postinstall script. Here is one such example script, replicating the default language pack installation found on Ubuntu Desktop.

#!/bin/sh

# Install language packs for English
apt install -y $(check-language-support -l en)

Installation without a default user

It is possible to install the system without a default user. In this situation on first boot of the system, Gnome Initial Setup will start and ask to create a user, its regional settings and a few default options.

To do so, entirely remove the "identity" section from the seed file and add to the end an empty "users" entry in a user-data section as follows:

  # This inhibits user creation, which for Desktop images means that
  # gnome-initial-setup will prompt for user creation on first boot.
  user-data:
    users: ['']

Registration with Landscape

To register the installed system with Landscape, cloud-init’s Landscape support can be used. Please ensure that a user-data section is present in the autoinstall data, and supply the appropriate values. See also man landscape-config.

  user-data:
    landscape:
      client:
        url: "https://landscape.canonical.com/message-system"
        ping_url: "http://landscape.canonical.com/ping"
        

Netboot

The procedure for netboot is equivalent to what is documented in the "Netbooting the live server installer" document. That procedure has been updated for Ubuntu 22.04.x and adjusted to deliver the Autoinstall to the install environment.

dnsmasq

Assuming dnsmasq will be used to serve the netboot binaries:

  1. apt install dnsmasq
  2. Configure /etc/dnsmasq.d/pxe.conf. Adjust as appropriate for the installation network:
interface=<your interface>,lo
bind-interfaces
dhcp-range=<your interface>,192.168.0.100,192.168.0.200
dhcp-boot=pxelinux.0
enable-tftp
tftp-root=/srv/tftp
  1. Ensure that the /srv/tftp directory exists mkdir -p /srv/tftp
  2. systemctl restart dnsmasq.service

Hosting the Autoinstall and the ISO

We need to host the Autoinstall YAML somewhere the netboot can get to it. This is a good opportunity to host the ISO, which should reduce the download time for the largest component.

  1. Download the 22.04.1 Live Server ISO
  2. Install a web server.
  3. Copy the configured autoinstall.yaml and the Live Server ISO to the appropriate directory being served by the web server.

PXE Configuration

  1. Download pxelinux.0 and put it into place:
wget http://archive.ubuntu.com/ubuntu/dists/focal/main/installer-amd64/current/legacy-images/netboot/pxelinux.0
mv pxelinux.0 /srv/tftp/
  1. Mount the Live Server ISO.
mount ubuntu-22.04.1-live-server-amd64.iso /mnt
  1. Copy the kernel, initrd, and ldlinux.c32 to where the dnsmasq serves tftp from:
cp /mnt/casper/{vmlinuz,initrd} /srv/tftp/
apt install syslinux-common
cp /usr/lib/syslinux/modules/bios/ldlinux.c32 /srv/tftp/
  1. Create /srv/tftp/pxelinux.cfg/default as below. Note that the APPEND and all following items should be on a single line, and that the configured URLs should point to the previous setup http server.
DEFAULT install
LABEL install
 KERNEL vmlinuz
 INITRD initrd
 APPEND root=/dev/ram0 ramdisk_size=1500000 ip=dhcp cloud-config-url=http://192.168.0.2/autoinstall.yaml url=http://192.168.0.2/ubuntu-22.04.1-live-server-amd64.iso autoinstall

Install

At this point everything needed should be in place. Boot the target system. It will perform the PXE netboot, download the ISO, use the Autoinstall configuration, and finally reboot to the installed environment.

autoinstall-desktop's People

Contributors

dbungert avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

autoinstall-desktop's Issues

Storage Layouts - custom partitions with interactive selection for easy of update.

We are looking to get below preseed file converted into autoinstall.

PRESEED Used for Ubuntu 18.04 LTS
d-i partman-auto/method string lvm

d-i partman-lvm/device_remove_lvm boolean true
d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm_nooverwrite boolean true
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-auto-lvm/guided_size string max
d-i partman-basicfilesystems/no_swap boolean false

For LVM partitioning, you can select how much of the volume group to use

for logical volumes.

d-i partman-auto/choose_recipe select boot-root

d-i partman-auto/expert_recipe string
boot-root ::
512 2000 2048 ext4
$primary{ } $bootable{ }
method{ format } format{ }
use_filesystem{ } filesystem{ ext4 }
mountpoint{ /boot }
.
2048 128 8192 linux-swap
$lvmok{ }
method{ swap } format{ }
.
5120 10000 -1 ext4
$lvmok{ }
method{ format } format{ }
use_filesystem{ } filesystem{ ext4 }
mountpoint{ / }
.
5120 30000 25600 ext4
$lvmok{ }
method{ format } format{ }
use_filesystem{ } filesystem{ ext4 }
mountpoint{ /home }
.
1024 5000 4096 ext4
$lvmok{ }
method{ format } format{ }
use_filesystem{ } filesystem{ ext4 }
mountpoint{ /usr/local/safesquid }
.
5120 10000 8192 ext4
$lvmok{ }
method{ format } format{ }
use_filesystem{ } filesystem{ ext4 }
mountpoint{ /var/lib/safesquid }
.
512 5000 4096 ext4
$lvmok{ }
method{ format } format{ }
use_filesystem{ } filesystem{ ext4 }
mountpoint{ /opt/safesquid }
.
1024 5000 -1 ext4
$lvmok{ }
method{ format } format{ }
use_filesystem{ } filesystem{ ext4 }
mountpoint{ /var/cache/safesquid }
.
1024 45000 -1 ext4
$lvmok{ }
method{ format } format{ }
use_filesystem{ } filesystem{ ext4 }
mountpoint{ /var/log/safesquid }
.
512 16000 15360 ext4
$lvmok{ }
method{ format } format{ }
use_filesystem{ } filesystem{ ext4 }
mountpoint{ /var/www/safesquid }
.
2048 35000 -1 ext4
$lvmok{ }
method{ format } format{ }
use_filesystem{ } filesystem{ ext4 }
mountpoint{ /var/db/safesquid }
.
Does autoinstall provides an option wherein the partition size for custom storage layout can be modified using interactive menu.

subiquity/Proxy/load_autoinstall_data http_proxy is not of type 'string', 'null'

Following the proxy section in the curtin doc: https://curtin.readthedocs.io/en/latest/topics/config.html and using Ubuntu 22.04.4, I have added the following section underneath the # proxy: comment in autoinstall.yaml:

proxy:
  http_proxy: 'http://myproxy.mydomain.com:8080/'
  https_proxy: 'http://myproxy.mydomain.com:8080/'
  no_proxy: 'some_exception,.mydomain.com'

But this is not parsing correctly. I am receiving the following errors:

connecting...
waiting for cloud-init...
running early commands
  running echo 'linux-generic-hwe-22.94' > /run/kernel-meta-package
finish: subiquity/Proxy/load_autoinstall_data: {'http_proxy': 'http://myproxy.mydomain.com:8080/', 'https_proxy': 'http://myproxy.mydomain.com:8080/', 'no_proxy': 'some_exception,.mydomain.com'} is not of type 'string', 'null'

Failed validating 'type' in schema:
    {'format': 'uri', 'type': ['string', 'null']}

Am I forming this correctly? I have gone over the curtin doc several times and am not seeing the problem.

Add tag "iso"?

Add tag "iso" for autoinstall-desktop and guides machines ubuntu on how to work with them.

iso: 'https://releases.ubuntu.com/24.04/ubuntu-24.04-desktop-amd64.iso.torrent'

Read here

apt remove ubuntu-server

Per documentation "curtin in-target -- apt-get remove -y ubuntu-server" will remove the cryptsetup!
If the OS was installed with LUKS encryption, this command will make the OS unbootable as no cryptsetup to decrypt the disk....
As a result fault state of OS

Ubuntu 23.04 configuration

Hello!

I have a question regarding the upcoming release of Ubuntu 23.04.

Will this repository be updated with the corresponding configuration for the newer Ubuntu Desktop version's packages? If so, when can we expect to see this?

Thank you!

Documentation for meta-data and vendor-data

We could not find any document related to meta-data and vendor-data used in autoinstall, when to use one or the other.
Please share any relevant documentation related to autoinstall's meta-data and vendor-data with appropriate examples for each of the autoinstall files.

languages

I am now testing the new installer for autoinstall, but on gnome user setup (because no user exists), end user cannot choose language and there is only a few keyboard layouts to choose from.
Is there a way to autointall all keyboard layouts and languages via the autoinstall.yaml file?

Autoinstall storage config- storage size limits

We are using below storage configuration for autoinstall

storage:
config:
#Select Disk
- {ptable: gpt, match: {}, wipe: superblock-recursive,
preserve: false, name: '', grub_device: true, type: disk, id: disk-sda}
#Grub Disk
- {device: disk-sda, size: 1M, flag: bios_grub, number: 1, preserve: false,
grub_device: false, type: partition, id: partition-0}
#/boot partition
- {device: disk-sda, size: 2G, wipe: superblock, flag: '', number: 2,
preserve: false, grub_device: false, type: partition, id: partition-1}
#Partition to be used for LVM
- {fstype: ext4, volume: partition-1, preserve: false, type: format, id: format-0}
- {device: disk-sda, size: -1, wipe: superblock, flag: '', number: 3,
preserve: false, grub_device: false, type: partition, id: partition-2}
#Creating Volume groups
- name: system
devices: [partition-2]
preserve: false
type: lvm_volgroup
id: lvm_volgroup-0
#Make LVM partitions
##root partition
- {name: root, volgroup: lvm_volgroup-0, size: 10%, wipe: superblock,
preserve: false, type: lvm_partition, id: lvm_partition-1}
- {fstype: ext4, volume: lvm_partition-1, preserve: false, type: format, id: format-1}
- {path: /, device: format-1, type: mount, id: mount-1}
##home partition
- {name: home, volgroup: lvm_volgroup-0, size: 15%, wipe: superblock,
preserve: false, type: lvm_partition, id: lvm_partition-2}
- {fstype: ext4, volume: lvm_partition-2, preserve: false, type: format, id: format-2}
- {path: /home, device: format-2, type: mount, id: mount-2}
##opt+safesquid
- {name: opt+safesquid, volgroup: lvm_volgroup-0, size: 5%, wipe: superblock, preserve: false,
type: lvm_partition, id: lvm_partition-3}
- {fstype: ext4, volume: lvm_partition-3, preserve: false, type: format, id: format-3}
- {path: /opt/safesquid, device: format-3, type: mount, id: mount-3}
##usr+local+safesquid
- {name: usr+local+safesquid, volgroup: lvm_volgroup-0, size: 5%, wipe: superblock, preserve: false,
type: lvm_partition, id: lvm_partition-4}
- {fstype: ext4, volume: lvm_partition-4, preserve: false, type: format, id: format-4}
- {path: /usr/local/safesquid, device: format-4, type: mount, id: mount-4}
#var+log+safesquid
- {name: var+log+safesquid, volgroup: lvm_volgroup-0, size: 25%, wipe: superblock, preserve: false,
type: lvm_partition, id: lvm_partition-5}
- {fstype: ext4, volume: lvm_partition-5, preserve: false, type: format, id: format-5}
- {path: /var/log/safesquid, device: format-5, type: mount, id: mount-5}
#var+www+safesquid
- {name: var+www+safesquid, volgroup: lvm_volgroup-0, size: 2%, wipe: superblock,
preserve: false, type: lvm_partition, id: lvm_partition-6}
- {fstype: ext4, volume: lvm_partition-6, preserve: false, type: format, id: format-6}
- {path: /var/www/safesquid, device: format-6, type: mount, id: mount-6}
#var+cache+safesquid
- {name: var+cache+safesquid, volgroup: lvm_volgroup-0, size: 2%, wipe: superblock,
preserve: false, type: lvm_partition, id: lvm_partition-7}
- {fstype: ext4, volume: lvm_partition-7, preserve: false, type: format, id: format-7}
- {path: /var/cache/safesquid, device: format-7, type: mount, id: mount-7}
#var+lib+safesquid
- {name: var+lib+safesquid, volgroup: lvm_volgroup-0, size: 2%, wipe: superblock,
preserve: false, type: lvm_partition, id: lvm_partition-8}
- {fstype: ext4, volume: lvm_partition-8, preserve: false, type: format, id: format-8}
- {path: /var/lib/safesquid, device: format-8, type: mount, id: mount-8}
#var+db+safesquid
- {name: var+db+safesquid, volgroup: lvm_volgroup-0, size: 25%, wipe: superblock,
preserve: false, type: lvm_partition, id: lvm_partition-9}
- {fstype: ext4, volume: lvm_partition-9, preserve: false, type: format, id: format-9}
- {path: /var/db/safesquid, device: format-9, type: mount, id: mount-9}
#Swap storage
- {name: swap, volgroup: lvm_volgroup-0, size: 2G, wipe: superblock,
preserve: false, type: lvm_partition, id: lvm_partition-10}
- {fstype: swap, volume: lvm_partition-10, preserve: false, type: format, id: format-10}
- {path: '', device: format-10, type: mount, id: mount-10}
- {path: /boot, device: format-0, type: mount, id: mount-0}
swap: {swap: 0}

We would want the sizes of LVM partitions to not exceed a after a certain amount, For example the partition size for /opt/safesquid should not exceed 2G in a situation wherein 5% of actual LVM volume group is more than 2G

Offline installation

I have a necessity for making this autoinstall setup work offline. The only part I'd require to do so is by making the ubuntu-desktop package (and its dependencies) part of the cdrom source for apt, as well as the snaps. Everything else is available from the ISO already.

How do I go about making this possible?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.