Skip to content

Instantly share code, notes, and snippets.

@s3rj1k
Last active March 6, 2024 12:12
Star You must be signed in to star a gist
Save s3rj1k/55b10cd20f31542046018fcce32f103e to your computer and use it in GitHub Desktop.
Ubuntu 20.04.3 AutoInstall
# For recent versions of Ubuntu:
- https://www.pugetsystems.com/labs/hpc/ubuntu-22-04-server-autoinstall-iso/
# Docs:
- https://wiki.ubuntu.com/FoundationsTeam/AutomatedServerInstalls
- https://wiki.ubuntu.com/FoundationsTeam/AutomatedServerInstalls/ConfigReference
- https://cloudinit.readthedocs.io/en/latest/topics/datasources/nocloud.html
- https://discourse.ubuntu.com/t/please-test-autoinstalls-for-20-04/15250/53
# Download ISO Installer:
wget https://ubuntu.volia.net/ubuntu-releases/20.04.3/ubuntu-20.04.3-live-server-amd64.iso
# Create ISO distribution dirrectory:
mkdir -p iso/nocloud/
# Extract ISO using 7z:
7z x ubuntu-20.04.3-live-server-amd64.iso -x'![BOOT]' -oiso
# Or extract ISO using xorriso and fix permissions:
xorriso -osirrox on -indev "ubuntu-20.04.3-live-server-amd64.iso" -extract / iso && chmod -R +w iso
# Create empty meta-data file:
touch iso/nocloud/meta-data
# Copy user-data file:
cp user-data iso/nocloud/user-data
# Update boot flags with cloud-init autoinstall:
## Should look similar to this: initrd=/casper/initrd quiet autoinstall ds=nocloud;s=/cdrom/nocloud/ ---
sed -i 's|---|autoinstall ds=nocloud\\\;s=/cdrom/nocloud/ ---|g' iso/boot/grub/grub.cfg
sed -i 's|---|autoinstall ds=nocloud;s=/cdrom/nocloud/ ---|g' iso/isolinux/txt.cfg
# Disable mandatory md5 checksum on boot:
md5sum iso/.disk/info > iso/md5sum.txt
sed -i 's|iso/|./|g' iso/md5sum.txt
# (Optionally) Regenerate md5:
# The find will warn 'File system loop detected' and return non-zero exit status on the 'ubuntu' symlink to '.'
# To avoid that, temporarily move it out of the way
mv iso/ubuntu .
(cd iso; find '!' -name "md5sum.txt" '!' -path "./isolinux/*" -follow -type f -exec "$(which md5sum)" {} \; > ../md5sum.txt)
mv md5sum.txt iso/
mv ubuntu iso
# Create Install ISO from extracted dir (ArchLinux):
xorriso -as mkisofs -r \
-V Ubuntu\ custom\ amd64 \
-o ubuntu-20.04.3-live-server-amd64-autoinstall.iso \
-J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot \
-boot-load-size 4 -boot-info-table \
-eltorito-alt-boot -e boot/grub/efi.img -no-emul-boot \
-isohybrid-gpt-basdat -isohybrid-apm-hfsplus \
-isohybrid-mbr /usr/lib/syslinux/bios/isohdpfx.bin \
iso/boot iso
# Create Install ISO from extracted dir (Ubuntu):
xorriso -as mkisofs -r \
-V Ubuntu\ custom\ amd64 \
-o ubuntu-20.04.3-live-server-amd64-autoinstall.iso \
-J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot \
-boot-load-size 4 -boot-info-table \
-eltorito-alt-boot -e boot/grub/efi.img -no-emul-boot \
-isohybrid-gpt-basdat -isohybrid-apm-hfsplus \
-isohybrid-mbr /usr/lib/ISOLINUX/isohdpfx.bin \
iso/boot iso
# After install:
- login with 'root:root' and change root user password
- set correct hostname with 'hostnamectl'
#cloud-config
autoinstall:
version: 1
interactive-sections:
- network
- storage
locale: en_US.UTF-8
keyboard:
layout: us
ssh:
allow-pw: true
install-server: false
late-commands:
- curtin in-target --target=/target -- apt-get --purge -y --quiet=2 remove apport bcache-tools btrfs-progs byobu cloud-guest-utils cloud-initramfs-copymods cloud-initramfs-dyn-netconf friendly-recovery fwupd landscape-common lxd-agent-loader ntfs-3g open-vm-tools plymouth plymouth-theme-ubuntu-text popularity-contest rsync screen snapd sosreport tmux ufw
- curtin in-target --target=/target -- apt-get --purge -y --quiet=2 autoremove
- curtin in-target --target=/target -- apt-get clean
- sed -i 's/ENABLED=1/ENABLED=0/' /target/etc/default/motd-news
- sed -i 's|# en_US.UTF-8 UTF-8|en_US.UTF-8 UTF-8|' /target/etc/locale.gen
- curtin in-target --target=/target -- locale-gen
- ln -fs /dev/null /target/etc/systemd/system/connman.service
- ln -fs /dev/null /target/etc/systemd/system/display-manager.service
- ln -fs /dev/null /target/etc/systemd/system/motd-news.service
- ln -fs /dev/null /target/etc/systemd/system/motd-news.timer
- ln -fs /dev/null /target/etc/systemd/system/plymouth-quit-wait.service
- ln -fs /dev/null /target/etc/systemd/system/plymouth-start.service
- ln -fs /dev/null /target/etc/systemd/system/systemd-resolved.service
- ln -fs /usr/share/zoneinfo/Europe/Kiev /target/etc/localtime
- rm -f /target/etc/resolv.conf
- printf 'nameserver 8.8.8.8\nnameserver 1.1.1.1\noptions timeout:1\noptions attempts:1\noptions rotate\n' > /target/etc/resolv.conf
- rm -f /target/etc/update-motd.d/10-help-text
- rm -rf /target/root/snap
- rm -rf /target/snap
- rm -rf /target/var/lib/snapd
- rm -rf /target/var/snap
- curtin in-target --target=/target -- passwd -q -u root
- curtin in-target --target=/target -- passwd -q -x -1 root
- curtin in-target --target=/target -- passwd -q -e root
- sed -i 's|^root:.:|root:$6$3b873df474b55246$GIpSsujar7ihMzG8urUKpzF9/2yZJhR.msyFRa5ouGXOKRCVszsc4aBcE2yi3IuFVxtAGwrPKin2WAzK3qOtB.:|' /target/etc/shadow
user-data:
disable_root: false
#cloud-config
autoinstall:
version: 1
interactive-sections:
- network
- storage
locale: en_US.UTF-8
keyboard:
layout: us
ssh:
allow-pw: true
install-server: false
late-commands:
- curtin in-target --target=/target -- apt-get --purge -y --quiet=2 remove apport bcache-tools btrfs-progs byobu cloud-guest-utils cloud-initramfs-copymods cloud-initramfs-dyn-netconf friendly-recovery fwupd landscape-common lxd-agent-loader ntfs-3g open-vm-tools plymouth plymouth-theme-ubuntu-text popularity-contest screen snapd sosreport tmux ufw
- curtin in-target --target=/target -- apt-get -qq update
- curtin in-target --target=/target -- apt-get -y install wget gnupg python2.7 openssh-server
- curtin in-target --target=/target -- apt-get -qq update
- curtin in-target --target=/target -- apt-get -y dist-upgrade
- curtin in-target --target=/target -- apt-get --purge -y --quiet=2 autoremove
- sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /target/etc/ssh/sshd_config
- sed -i 's/ENABLED=1/ENABLED=0/' /target/etc/default/motd-news
- sed -i 's|# en_US.UTF-8 UTF-8|en_US.UTF-8 UTF-8|' /target/etc/locale.gen
- curtin in-target --target=/target -- locale-gen
- ln -fs /dev/null /target/etc/systemd/system/connman.service
- ln -fs /dev/null /target/etc/systemd/system/display-manager.service
- ln -fs /dev/null /target/etc/systemd/system/motd-news.service
- ln -fs /dev/null /target/etc/systemd/system/motd-news.timer
- ln -fs /dev/null /target/etc/systemd/system/plymouth-quit-wait.service
- ln -fs /dev/null /target/etc/systemd/system/plymouth-start.service
- ln -fs /dev/null /target/etc/systemd/system/systemd-resolved.service
- ln -fs /usr/share/zoneinfo/Europe/Kiev /target/etc/localtime
- rm -f /target/etc/resolv.conf
- printf 'nameserver 8.8.8.8\nnameserver 1.1.1.1\noptions timeout:1\noptions attempts:1\noptions rotate\n' > /target/etc/resolv.conf
- rm -f /target/etc/update-motd.d/10-help-text
- rm -rf /target/root/snap
- rm -rf /target/snap
- rm -rf /target/var/lib/snapd
- rm -rf /target/var/snap
- curtin in-target --target=/target -- passwd -q -u root
- curtin in-target --target=/target -- passwd -q -x -1 root
- curtin in-target --target=/target -- passwd -q -e root
- sed -i 's|^root:.:|root:$6$3b873df474b55246$GIpSsujar7ihMzG8urUKpzF9/2yZJhR.msyFRa5ouGXOKRCVszsc4aBcE2yi3IuFVxtAGwrPKin2WAzK3qOtB.:|' /target/etc/shadow
- sed -i 's/ext4 defaults/ext4 prjquota,lazytime/g' /target/etc/fstab
- findmnt --real -U -n -t ext4 -o source | awk '{system("umount -l "$1)}'
- blkid -t TYPE="ext4" -o device | awk '{system("tune2fs -O project,quota -Q prjquota "$1)}'
user-data:
disable_root: false
@s3rj1k
Copy link
Author

s3rj1k commented Jan 23, 2022

@iondulgheru needs to be adopted for that release, will do when I'll have some free time.

@dushyanthkumaryd
Copy link

dushyanthkumaryd commented Jan 28, 2022

I am also trying to create a customized iso with 21.10 using the above procedure but there is no /isolinux folder and boot/grub/efi.img file inside the extracted folder and these folder/files even not there in 20.10, 21.04, and 21.10. can anyone help if someone already did?

@dpflick
Copy link

dpflick commented Feb 1, 2022

I tried the following but it fails. I am new to this and I can't figure out what is wrong.
xorriso -as mkisofs -r \

-V Ubuntu\ custom\ amd64
-o ubuntu-20.04.3-live-server-amd64-autoinstall.iso
-J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot
-boot-load-size 4 -boot-info-table
-eltorito-alt-boot -e boot/grub/efi.img -no-emul-boot
-isohybrid-gpt-basdat -isohybrid-apm-hfsplus
-isohybrid-mbr /usr/lib/ISOLINUX/isohdpfx.bin
iso/boot iso
xorriso 1.5.2 : RockRidge filesystem manipulator, libburnia project.

Drive current: -outdev 'stdio:ubuntu-20.04.3-live-server-amd64-autoinstall.iso'
Media current: stdio file, overwriteable
Media status : is blank
Media summary: 0 sessions, 0 data blocks, 0 data, 37.1g free
xorriso : WARNING : -volid text problematic as automatic mount point name
xorriso : WARNING : -volid text does not comply to ISO 9660 / ECMA 119 rules
Added to ISO image: directory '/'='/home/devops/iso/boot'
xorriso : UPDATE : 261 files added in 1 seconds
Added to ISO image: directory '/'='/home/devops/iso'
xorriso : FAILURE : Given path does not exist on disk: -boot_image system_area='/usr/lib/ISOLINUX/isohdpfx.bin'
xorriso : UPDATE : 1005 files added in 1 seconds
xorriso : aborting : -abort_on 'FAILURE' encountered 'FAILURE'

Any idea where to start looking? I can't find isohdpfx.bin anywhere in the iso folder.

@liuyueying-nx
Copy link

Can the network&storage be set up automatically?

@pat0s
Copy link

pat0s commented Feb 10, 2022

@dpflick
I was trying to solve your problem and finally, I found this issue on Github.
tadas-s/custom-ubuntu-install#5 (comment)

@pat0s
Copy link

pat0s commented Feb 10, 2022

Yes, you can set up network and storage automatically @liuyueying-nx. You have to remove network and storage from interactive-sections: in a user-data file. Then configure everything you want in sections storage: and network:.

autoinstall:
  version: 1
  interactive-sections:
    - network
    - storage

Check out the documentation -> https://ubuntu.com/server/docs/install/autoinstall-reference

@liuyueying-nx
Copy link

I did but it doesn't seem to work
network:
version: 2
ethernets:
enpls0:
dhcp6: yes
storage:
layout:
name: direct

@pat0s
Copy link

pat0s commented Feb 10, 2022

@liuyueying-nx
Are the sections still interactive or is there an error?

@liuyueying-nx
Copy link

@pat0s still interactive. I want to modify the root password through the code of cloud-init, is this OK?

@Kipjr
Copy link

Kipjr commented Feb 14, 2022

@dushyanthkumaryd ,
I've got an USB-key with /nocloud , /iso and required stuff to boot (server iso-> usb-key and remove distro files)

In the user-data file i've got references to the usb-key defined by /isodevice/

is your /boot/grub/grub.cfg configured like this?

menuentry "ISO - Ubuntu Server 21.10 {
	set gfxpayload=keep
    set isofile="/iso/ubuntu-21.10-live-server-amd64.iso"
    loopback loop (hd0,msdos1)$isofile
	linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile noprompt noeject "ds=nocloud;s=/isodevice/nocloud/"  quiet autoinstall --- 
	initrd (loop)/casper/initrd
}

@zero-pytagoras
Copy link

is there a way to choose arbitrary disk to deploy LVM afters.
I used match: {} but it did not work. Has anyone ever had something like this ?

@utkonos
Copy link

utkonos commented Jun 19, 2022

I wrote a Python script that is a boiled-down simplification of the process here, and it's current for 22.04 LTS.

import io
import pathlib

import pycdlib

ubuntu = pathlib.Path('ubuntu-22.04-live-server-amd64.iso')
new_iso_path = pathlib.Path('ubuntu-22.04-live-server-amd64-auto.iso')

iso = pycdlib.PyCdlib()
iso.open(ubuntu)

extracted = io.BytesIO()
iso.get_file_from_iso_fp(extracted, iso_path='/BOOT/GRUB/GRUB.CFG;1')
extracted.seek(0)
data = extracted.read()
print(data.decode())

new = data.replace(b' ---', b'quiet autoinstall ds=nocloud\;s=/cdrom/nocloud/ ---').replace(b'timeout=30', b'timeout=1')
print(new.decode())

iso.rm_file(iso_path='/BOOT/GRUB/GRUB.CFG;1', rr_name='grub.cfg')
iso.add_fp(io.BytesIO(new), len(new), '/BOOT/GRUB/GRUB.CFG;1', rr_name='grub.cfg')

iso.add_directory('/NOCLOUD', rr_name='nocloud')

user_data = b"""#cloud-config
autoinstall:
  version: 1
  identity:
    hostname: ubuntu-server
    password: "$6$exDY1mhS4KUYCE/2$zmn9ToZwTKLhCw.b4/b.ZRTIZM30JZ4QrOQ2aOXJ8yk96xpcCof0kxKwuX1kqLG/ygbJ1f8wxED22bTL4F46P0"
    username: ubuntu
"""

iso.add_fp(io.BytesIO(user_data), len(user_data), '/NOCLOUD/USER_DATA;1', rr_name='user-data')
iso.add_fp(io.BytesIO(b''), len(b''), '/NOCLOUD/META_DATA;1', rr_name='meta-data')
iso.write(new_iso_path)
iso.close()

Here's the gist:

https://gist.github.com/utkonos/718b150de4f86054c37ac798c02b54c6

@utkonos
Copy link

utkonos commented Jun 19, 2022

The username/password for the above is ubuntu/ubuntu

Also, this creates a really dangerous ISO. It will destroy whatever boots it, if possible. Only boot from this if you want an automatic install with no user interaction.

@utkonos
Copy link

utkonos commented Jun 19, 2022

You can split this into two different ISOs also. One which is the Ubuntu installer ISO which has been edited to just do quiet autoinstall. And the other that contains the user-data file. You then boot from the installer ISO and have the other ISO attached as a second CDROM.

First ISO

import io
import pathlib

import pycdlib

ubuntu = pathlib.Path('ubuntu-22.04-live-server-amd64.iso')
new_iso = pathlib.Path('ubuntu-22.04-live-server-amd64-auto.iso')

iso = pycdlib.PyCdlib()
iso.open(ubuntu)

extracted = io.BytesIO()
iso.get_file_from_iso_fp(extracted, iso_path='/BOOT/GRUB/GRUB.CFG;1')
extracted.seek(0)
data = extracted.read()
print(data.decode())

new = data.replace(b' ---', b'quiet autoinstall ---').replace(b'timeout=30', b'timeout=1')
print(new.decode())

iso.rm_file(iso_path='/BOOT/GRUB/GRUB.CFG;1', rr_name='grub.cfg')
iso.add_fp(io.BytesIO(new), len(new), '/BOOT/GRUB/GRUB.CFG;1', rr_name='grub.cfg')

iso.write(new_iso)
iso.close()

Second ISO

import io
import pathlib

import pycdlib

new_iso = pathlib.Path('ubuntu-22.04-auto.iso')

iso = pycdlib.PyCdlib()
iso.new(rock_ridge='1.09', vol_ident='CIDATA')

user_data = b"""#cloud-config
autoinstall:
  version: 1
  identity:
    hostname: ubuntu-server
    password: "$6$exDY1mhS4KUYCE/2$zmn9ToZwTKLhCw.b4/b.ZRTIZM30JZ4QrOQ2aOXJ8yk96xpcCof0kxKwuX1kqLG/ygbJ1f8wxED22bTL4F46P0"
    username: ubuntu
"""

iso.add_fp(io.BytesIO(user_data), len(user_data), '/USERDATA;1', rr_name='user-data')
iso.add_fp(io.BytesIO(b''), len(b''), '/METADATA;1', rr_name='meta-data')

iso.write(new_iso)
iso.close()

@daniconil
Copy link

@s3rj1k
Copy link
Author

s3rj1k commented Jun 30, 2022

Hi!

Is this URL still alive?

https://ubuntu.volia.net/ubuntu-releases/20.04.3/ubuntu-20.04.3-live-server-amd64.iso

I have downloaded the ISO from the official releases site.

https://releases.ubuntu.com/20.04.3/ubuntu-20.04.3-live-server-amd64.iso

should be ok also

@Quixus
Copy link

Quixus commented Nov 8, 2022

@aconte31 please add curtin in-target --target=/target -- before each command as you are now running the commands in the install environment, not the target environment

Does the /target part in curtin in-target --target=/target -- need to be customized in some way or is it literally /target?

@c0nsaw
Copy link

c0nsaw commented Nov 8, 2022

@aconte31 please add curtin in-target --target=/target -- before each command as you are now running the commands in the install environment, not the target environment

Does the /target part in curtin in-target --target=/target -- need to be customized in some way or is it literally /target?

as is....literally target

@subinznz
Copy link

Hi is it possible to point the install environment apt packages e.g cdroom /pool and /dist to the target environment to install packages such as nano. This will be for the minimal server install. ( no internet connection so no apt server , apt address file:///cdrom or something like that

thanks

@dmuiX
Copy link

dmuiX commented Jan 7, 2023

Maybe somebody already wrote that. The late-commands do not work on current ubuntu-22.04.1-live-server-arm64
Screenshot 2023-01-07 at 01 14 34

For reference I was just using the first three:

  late-commands:
    - curtin in-target --target=/target -- apt-get --purge -y --quiet=2 remove snapd
    - curtin in-target --target=/target -- apt-get --purge -y --quiet=2 autoremove
    - curtin in-target --target=/target -- apt-get clean

@s3rj1k
Copy link
Author

s3rj1k commented Jan 7, 2023

Maybe somebody already wrote that. The late-commands do not work on current ubuntu-22.04.1-live-server-arm64

Hmm, could be a bug, https://ubuntu.com/server/docs/install/autoinstall-reference says that late-commands are supported

@zero-pytagoras
Copy link

@dmuiX ,
that is happening because you are trying to remove snapd, I had same issue with it on ubuntu20.04. You see, cloud-init is installed via snapd, and when you try to remove and purge snapd, all the packages, including cloud-init, are removed, thus due to self-preservation, your command fails.
I by passed it by moving the command to runcmd. that way the package will be removed on the first boot, without failing the system install.

@dmuiX
Copy link

dmuiX commented Jan 8, 2023

@dmuiX , that is happening because you are trying to remove snapd, I had same issue with it on ubuntu20.04. You see, cloud-init is installed via snapd, and when you try to remove and purge snapd, all the packages, including cloud-init, are removed, thus due to self-preservation, your command fails. I by passed it by moving the command to runcmd. that way the package will be removed on the first boot, without failing the system install.

:D :D. So a bit like canibalism^^. Thanks for sharing your solution.
Although: runcmd is not referenced in the documentation: https://ubuntu.com/server/docs/install/autoinstall-reference. have you just added it like the rest? Or where have you found this? Maybe it was removed at the current version 2204? Is there some other way to add commands like the above?

@zero-pytagoras
Copy link

@bashadude
Copy link

@s3rj1k I have tried [user-data_with_ssh_and_project_quota] with ubuntu 22.04 but it was not accessing or not auto installing can you please ping the guide for ubuntu 22.04 server in auto install method.

Thanks in advance

@bashadude
Copy link

Can you guys ping the working method for installing ubuntu 22.04 @s3rj1k @davosian @dmuiX @zero-pytagoras @zepx @dbkinghorn

@dmuiX
Copy link

dmuiX commented Mar 5, 2023

@dmuiX
Copy link

dmuiX commented Mar 5, 2023

Can you guys ping the working method for installing ubuntu 22.04 @s3rj1k @davosian @dmuiX @zero-pytagoras @zepx @dbkinghorn

I will look my one up and post it later

If you are interested i understanding the automated ubuntu installation a bit better this might be a good guide:
https://www.jimangel.io/posts/automate-ubuntu-22-04-lts-bare-metal/

Pretty basic. As I decided to install everything via commands. Might be because it was not working pretty well and I had no time or motivation. Switched now to cloud-init and mulitpass to make everything run as this was easier and works better. I think you can use cloud-init to install a ubuntu instance as well you just have to find a way to integrate it in an iso file or provide it via network.

#cloud-config
autoinstall:
  version: 1
  identity:
    hostname: k8s-cluster
    password: "$6$exDY1mhS4KUYCE/2$zmn9ToZwTKLhCw.b4/b.ZRTIZM30JZ4QrOQ2aOXJ8yk96xpcCof0kxKwuX1kqLG/ygbJ1f8wxED22bTL4F46P0"
    username: ubuntu
  locale: de_DE
  keyboard:
    layout: de
    variant: mac
  ssh:
    install-server: yes
    allow-pw: yes
  packages:
    - nala
  updates: all

@bashadude
Copy link

bashadude commented Mar 5, 2023

errorr

I am facing error while installing @s3rj1k @dmuiX

@zero-pytagoras
Copy link

you are trying to removing cloud-packages, which might be a reason for the errors

@bashadude
Copy link

you are trying to removing cloud-packages, which might be a reason for the errors

Hi @zero-pytagoras can you please ping me the exact working file of user-data to do complete autointall ubuntu 22.04. I have tried so many nothing is working completely.

@bashadude
Copy link

bashadude commented Mar 5, 2023

#cloud-config
autoinstall:
version: 1
interactive-sections:
- network
locale: en_US.UTF-8
keyboard:
layout: us
ssh:
allow-pw: true
install-server: false
storage: # should set the interactive default but doesn't seem to work??
layout:
name: lvm
late-commands:
- curtin in-target --target=/target -- apt-get --purge -y --quiet=2 remove apport bcache-tools btrfs-progs byobu cloud-guest-utils cloud-initramfs-copymods cloud-initramfs-dyn-netconf friendly-recovery fwupd landscape-common lxd-agent-loader ntfs-3g open-vm-tools plymouth plymouth-theme-ubuntu-text popularity-contest rsync screen snapd sosreport tmux ufw
- curtin in-target --target=/target -- apt-get --purge -y --quiet=2 autoremove
- curtin in-target --target=/target -- apt-get clean
- sed -i 's/ENABLED=1/ENABLED=0/' /target/etc/default/motd-news
- sed -i 's|# en_US.UTF-8 UTF-8|en_US.UTF-8 UTF-8|' /target/etc/locale.gen
- curtin in-target --target=/target -- locale-gen
- ln -fs /dev/null /target/etc/systemd/system/connman.service
- ln -fs /dev/null /target/etc/systemd/system/display-manager.service
- ln -fs /dev/null /target/etc/systemd/system/motd-news.service
- ln -fs /dev/null /target/etc/systemd/system/motd-news.timer
- ln -fs /dev/null /target/etc/systemd/system/plymouth-quit-wait.service
- ln -fs /dev/null /target/etc/systemd/system/plymouth-start.service
- ln -fs /dev/null /target/etc/systemd/system/systemd-resolved.service
- ln -fs /usr/share/zoneinfo/Europe/Kiev /target/etc/localtime
- rm -f /target/etc/resolv.conf
- printf 'nameserver 8.8.8.8\nnameserver 1.1.1.1\noptions timeout:1\noptions attempts:1\noptions rotate\n' > /target/etc/resolv.conf
- rm -f /target/etc/update-motd.d/10-help-text
- rm -rf /target/root/snap
- rm -rf /target/snap
- rm -rf /target/var/lib/snapd
- rm -rf /target/var/snap
- curtin in-target --target=/target -- passwd -q -u root
- curtin in-target --target=/target -- passwd -q -x -1 root
- curtin in-target --target=/target -- passwd -q -e root
- sed -i 's|^root:.:|root:$6$3b873df474b55246$GIpSsujar7ihMzG8urUKpzF9/2yZJhR.msyFRa5ouGXOKRCVszsc4aBcE2yi3IuFVxtAGwrPKin2WAzK3qOtB.:|' /target/etc/shadow
user-data:
disable_root: false

I am using this user-data file. can you please help me to find put correct late commands and early commands @dmuiX @s3rj1k @zero-pytagoras @daniconil @onedr0p @kukat @davosian @mcginty

@s3rj1k
Copy link
Author

s3rj1k commented Mar 5, 2023

@bashadude What do you see in error report?

@zero-pytagoras
Copy link

zero-pytagoras commented Mar 5, 2023

This should work

#cloud-config
autoinstall:
version: 1
interactive-sections:
- network
identity: {hostname: HOSTNAME, password: "ENCRYPTED-PASSWORD", username: USERNAME}
locale: en_US.UTF-8
keyboard:
layout: us
ssh:
allow-pw: true
install-server: true
storage: # should set the interactive default but doesn't seem to work??
layout:
name: lvm
late-commands:
- curtin in-target --target=/target -- apt-get --purge -y --quiet=2 remove apport bcache-tools btrfs-progs byobu  friendly-recovery fwupd landscape-common lxd-agent-loader ntfs-3g open-vm-tools plymouth plymouth-theme-ubuntu-text popularity-contest rsync screen sosreport tmux ufw
- curtin in-target --target=/target -- apt-get --purge -y --quiet=2 autoremove
- curtin in-target --target=/target -- apt-get clean
- sed -i 's/ENABLED=1/ENABLED=0/' /target/etc/default/motd-news
- sed -i 's|# en_US.UTF-8 UTF-8|en_US.UTF-8 UTF-8|' /target/etc/locale.gen
- curtin in-target --target=/target -- locale-gen
- ln -fs /dev/null /target/etc/systemd/system/connman.service
- ln -fs /dev/null /target/etc/systemd/system/display-manager.service
- ln -fs /dev/null /target/etc/systemd/system/motd-news.service
- ln -fs /dev/null /target/etc/systemd/system/motd-news.timer
- ln -fs /dev/null /target/etc/systemd/system/plymouth-quit-wait.service
- ln -fs /dev/null /target/etc/systemd/system/plymouth-start.service
- ln -fs /dev/null /target/etc/systemd/system/systemd-resolved.service
- ln -fs /usr/share/zoneinfo/Europe/Kiev /target/etc/localtime
- rm -f /target/etc/resolv.conf
- printf 'nameserver 8.8.8.8\nnameserver 1.1.1.1\noptions timeout:1\noptions attempts:1\noptions rotate\n' > /target/etc/resolv.conf
- rm -f /target/etc/update-motd.d/10-help-text
user-data:
disable_root: false

@dmuiX
Copy link

dmuiX commented Mar 5, 2023

Have a look above. I Had the same error ;)

@bashadude
Copy link

@bashadude What do you see in error report?

errorr

it was removing or purge the packages

@bashadude
Copy link

bashadude commented Mar 5, 2023

While booting i was appeared like this @s3rj1k @dmuiX @zero-pytagoras @soutrikand @sjerman @mcginty @onedr0p @SimplySeth

image

image

I am using this userdata file

#cloud-config
autoinstall:
refresh-installer:
update: yes
locale: en_US.UTF-8
interactive-sections
network:
ethernets:
eno8303:
dhcp4: true
eno8403:
dhcp4: true
enp2s0f0np0:
dhcp4: true
enp2s0f1np1:
dhcp4: true
version: 2
kernel:
package: linux-generic
keyboard:
layout: us
ssh:
allow-pw: true
install-server: true
storage:
config:
- ptable: gpt
serial: 362cea7f0bf55ec002a9f5df208c726db
wwn: '0x62cea7f0bf55ec002a9f5df208c726db'
path: /dev/sda
wipe: superblock-recursive
preserve: false
name: ''
grub_device: false
type: disk
id: disk-sda
- device: disk-sda
size: 1127219200
wipe: superblock
flag: boot
number: 1
preserve: false
grub_device: true
offset: 1048576
type: partition
id: partition-0
- fstype: fat32
volume: partition-0
preserve: false
type: format
id: format-0
- device: disk-sda
size: 2147483648
wipe: superblock
number: 2
preserve: false
grub_device: false
offset: 1128267776
type: partition
id: partition-1
- fstype: ext4
volume: partition-1
preserve: false
type: format
id: format-1
- device: disk-sda
size: 955843084288
wipe: superblock
number: 3
preserve: false
grub_device: false
offset: 3275751424
type: partition
id: partition-2
- name: ubuntu-vg
devices:
- partition-2
preserve: false
type: lvm_volgroup
id: lvm_volgroup-0
- name: ubuntu-lv
volgroup: lvm_volgroup-0
size: 107374182400B
wipe: superblock
preserve: false
type: lvm_partition
id: lvm_partition-0
fstype: ext4
volume: lvm_partition-0
preserve: false
type: format
id: format-2
- path: /
device: format-2
type: mount
id: mount-2
- path: /boot
device: format-1
type: mount
id: mount-1
- path: /boot/efi
device: format-0
type: mount
id: mount-0
updates: security
version: 1
late-commands:
#- curtin in-target --target=/target -- apt-get --purge -y --quiet=2 remove apport bcache-tools btrfs-progs byobu cloud-guest-utils cloud-initramfs-copymods cloud-initramfs-dyn-netconf friendly-recovery fwupd landscape-common lxd-agent-loader ntfs-3g open-vm-tools plymouth plymouth-theme-ubuntu-text popularity-contest rsync screen snapd sosreport tmux ufw
- curtin in-target --target=/target -- apt-get --purge -y --quiet=2 autoremove
- curtin in-target --target=/target -- apt-get clean
- sed -i 's/ENABLED=1/ENABLED=0/' /target/etc/default/motd-news
- sed -i 's|# en_US.UTF-8 UTF-8|en_US.UTF-8 UTF-8|' /target/etc/locale.gen
- curtin in-target --target=/target -- locale-gen
- ln -fs /dev/null /target/etc/systemd/system/connman.service
- ln -fs /dev/null /target/etc/systemd/system/display-manager.service
- ln -fs /dev/null /target/etc/systemd/system/motd-news.service
- ln -fs /dev/null /target/etc/systemd/system/motd-news.timer
- ln -fs /dev/null /target/etc/systemd/system/plymouth-quit-wait.service
- ln -fs /dev/null /target/etc/systemd/system/plymouth-start.service
- ln -fs /dev/null /target/etc/systemd/system/systemd-resolved.service
- ln -fs /usr/share/zoneinfo/Europe/Kiev /target/etc/localtime
- rm -f /target/etc/resolv.conf
- printf 'nameserver 8.8.8.8\nnameserver 1.1.1.1\noptions timeout:1\noptions attempts:1\noptions rotate\n' > /target/etc/resolv.conf
- rm -f /target/etc/update-motd.d/10-help-text
#- rm -rf /target/root/snap
#- rm -rf /target/snap
#- rm -rf /target/var/lib/snapd
#- rm -rf /target/var/snap
#- curtin in-target --target=/target -- passwd -q -u root
#- curtin in-target --target=/target -- passwd -q -x -1 root
#- curtin in-target --target=/target -- passwd -q -e root
#- sed -i 's|^root:.:|root:$6$3b873df474b55246$GIpSsujar7ihMzG8urUKpzF9/2yZJhR.msyFRa5ouGXOKRCVszsc4aBcE2yi3IuFVxtAGwrPKin2WAzK3qOtB.:|' /target/etc/shadow
user-data:
disable_root: false

@zero-pytagoras
Copy link

zero-pytagoras commented Mar 5, 2023

you are missing interactive with storage.

#cloud-config
autoinstall:
version: 1
interactive-sections:
- network
- storage
identity: {hostname: HOSTNAME, password: "ENCRYPTED-PASSWORD", username: USERNAME}
locale: en_US.UTF-8
keyboard:
layout: us
ssh:
allow-pw: true
install-server: true
layout:
name: lvm
late-commands:
- curtin in-target --target=/target -- apt-get --purge -y --quiet=2 remove apport bcache-tools btrfs-progs byobu  friendly-recovery fwupd landscape-common lxd-agent-loader ntfs-3g open-vm-tools plymouth plymouth-theme-ubuntu-text popularity-contest rsync screen sosreport tmux ufw
- curtin in-target --target=/target -- apt-get --purge -y --quiet=2 autoremove
- curtin in-target --target=/target -- apt-get clean
- sed -i 's/ENABLED=1/ENABLED=0/' /target/etc/default/motd-news
- sed -i 's|# en_US.UTF-8 UTF-8|en_US.UTF-8 UTF-8|' /target/etc/locale.gen
- curtin in-target --target=/target -- locale-gen
- ln -fs /dev/null /target/etc/systemd/system/connman.service
- ln -fs /dev/null /target/etc/systemd/system/display-manager.service
- ln -fs /dev/null /target/etc/systemd/system/motd-news.service
- ln -fs /dev/null /target/etc/systemd/system/motd-news.timer
- ln -fs /dev/null /target/etc/systemd/system/plymouth-quit-wait.service
- ln -fs /dev/null /target/etc/systemd/system/plymouth-start.service
- ln -fs /dev/null /target/etc/systemd/system/systemd-resolved.service
- ln -fs /usr/share/zoneinfo/Europe/Kiev /target/etc/localtime
- rm -f /target/etc/resolv.conf
- printf 'nameserver 8.8.8.8\nnameserver 1.1.1.1\noptions timeout:1\noptions attempts:1\noptions rotate\n' > /target/etc/resolv.conf
- rm -f /target/etc/update-motd.d/10-help-text
user-data:
disable_root: false

@bashadude
Copy link

zero

Is it possible to do without interacting anything network and storage

@zero-pytagoras
Copy link

zero-pytagoras commented Mar 5, 2023

you really need to read this

#cloud-config
autoinstall:
version: 1
identity: {hostname: HOSTNAME, password: "ENCRYPTED-PASSWORD", username: USERNAME}
locale: en_US.UTF-8
keyboard:
layout: us
ssh:
allow-pw: true
install-server: true
network:
  version: 2
  ethernets:
    eno1:
      match:
        name: en*
      dhcp4: true
storage:
    config:
      - {name: ubuntu-vg, devices:[partition-2], preserve: false, type: lvm_volgroup, id: lvm_volgroup-0 }
      - {name: ubuntu-lv, volgroup: lvm_volgroup-0, size: 10GB, wipe: superblock, preserve: false, type: lvm_partition, id: lvm_part-0}
      - {fstype: ext4, volume: lvm_part-0, preserve: false, type: format, id: fmt-2 }
      - {path: /, device: fmt-2, type: mount, id: mnt-2}
      - {path: /boot, device: fmt-1, type: mount, id: mnt-1}
      - {path: /boot/efi, device: fmt-0, type: mount, id: mnt-0}
late-commands:
- curtin in-target --target=/target -- apt-get --purge -y --quiet=2 remove apport bcache-tools btrfs-progs byobu  friendly-recovery fwupd landscape-common lxd-agent-loader ntfs-3g open-vm-tools plymouth plymouth-theme-ubuntu-text popularity-contest rsync screen sosreport tmux ufw
- curtin in-target --target=/target -- apt-get --purge -y --quiet=2 autoremove
- curtin in-target --target=/target -- apt-get clean
- sed -i 's/ENABLED=1/ENABLED=0/' /target/etc/default/motd-news
- sed -i 's|# en_US.UTF-8 UTF-8|en_US.UTF-8 UTF-8|' /target/etc/locale.gen
- curtin in-target --target=/target -- locale-gen
- ln -fs /dev/null /target/etc/systemd/system/connman.service
- ln -fs /dev/null /target/etc/systemd/system/display-manager.service
- ln -fs /dev/null /target/etc/systemd/system/motd-news.service
- ln -fs /dev/null /target/etc/systemd/system/motd-news.timer
- ln -fs /dev/null /target/etc/systemd/system/plymouth-quit-wait.service
- ln -fs /dev/null /target/etc/systemd/system/plymouth-start.service
- ln -fs /dev/null /target/etc/systemd/system/systemd-resolved.service
- ln -fs /usr/share/zoneinfo/Europe/Kiev /target/etc/localtime
- rm -f /target/etc/resolv.conf
- printf 'nameserver 8.8.8.8\nnameserver 1.1.1.1\noptions timeout:1\noptions attempts:1\noptions rotate\n' > /target/etc/resolv.conf
- rm -f /target/etc/update-motd.d/10-help-text
user-data:
disable_root: false

@bashadude
Copy link

you really need to read this

#cloud-config
autoinstall:
version: 1
identity: {hostname: HOSTNAME, password: "ENCRYPTED-PASSWORD", username: USERNAME}
locale: en_US.UTF-8
keyboard:
layout: us
ssh:
allow-pw: true
install-server: true
network:
  version: 2
  ethernets:
    eno1:
      match:
        name: en*
      dhcp4: true
storage:
    config:
      - {name: ubuntu-vg, devices:[partition-2], preserve: false, type: lvm_volgroup, id: lvm_volgroup-0 }
      - {name: ubuntu-lv, volgroup: lvm_volgroup-0, size: 10GB, wipe: superblock, preserve: false, type: lvm_partition, id: lvm_part-0}
      - {fstype: ext4, volume: lvm_part-0, preserve: false, type: format, id: fmt-2 }
      - {path: /, device: fmt-2, type: mount, id: mnt-2}
      - {path: /boot, device: fmt-1, type: mount, id: mnt-1}
      - {path: /boot/efi, device: fmt-0, type: mount, id: mnt-0}
late-commands:
- curtin in-target --target=/target -- apt-get --purge -y --quiet=2 remove apport bcache-tools btrfs-progs byobu  friendly-recovery fwupd landscape-common lxd-agent-loader ntfs-3g open-vm-tools plymouth plymouth-theme-ubuntu-text popularity-contest rsync screen sosreport tmux ufw
- curtin in-target --target=/target -- apt-get --purge -y --quiet=2 autoremove
- curtin in-target --target=/target -- apt-get clean
- sed -i 's/ENABLED=1/ENABLED=0/' /target/etc/default/motd-news
- sed -i 's|# en_US.UTF-8 UTF-8|en_US.UTF-8 UTF-8|' /target/etc/locale.gen
- curtin in-target --target=/target -- locale-gen
- ln -fs /dev/null /target/etc/systemd/system/connman.service
- ln -fs /dev/null /target/etc/systemd/system/display-manager.service
- ln -fs /dev/null /target/etc/systemd/system/motd-news.service
- ln -fs /dev/null /target/etc/systemd/system/motd-news.timer
- ln -fs /dev/null /target/etc/systemd/system/plymouth-quit-wait.service
- ln -fs /dev/null /target/etc/systemd/system/plymouth-start.service
- ln -fs /dev/null /target/etc/systemd/system/systemd-resolved.service
- ln -fs /usr/share/zoneinfo/Europe/Kiev /target/etc/localtime
- rm -f /target/etc/resolv.conf
- printf 'nameserver 8.8.8.8\nnameserver 1.1.1.1\noptions timeout:1\noptions attempts:1\noptions rotate\n' > /target/etc/resolv.conf
- rm -f /target/etc/update-motd.d/10-help-text
user-data:
disable_root: false

Thank you so much @zero-pytagoras
Let me try now

@dbkinghorn
Copy link

per request earlier here's my most recent post on this stuff.
https://www.pugetsystems.com/labs/hpc/ubuntu-22-04-server-autoinstall-iso/

@zero-pytagoras
Copy link

@bashadude you should thank @dbkinghorn : his initial tutorial and guidance led me to answers.... lemme know if t works for you.

@dmuiX
Copy link

dmuiX commented Mar 5, 2023

FYI:
Ubuntu autoinstall is not the same as cloud-Init. It is based on cloud-Init but uses some additional commands.

@zero-pytagoras
Copy link

@dmuiX mind sharing docs on ubuntu install ? I've used official ubuntu cloud-init docs but they are not very informative or clear.

@zero-pytagoras
Copy link

@bashadude - any success ?

you really need to read this

#cloud-config
autoinstall:
version: 1
identity: {hostname: HOSTNAME, password: "ENCRYPTED-PASSWORD", username: USERNAME}
locale: en_US.UTF-8
keyboard:
layout: us
ssh:
allow-pw: true
install-server: true
network:
  version: 2
  ethernets:
    eno1:
      match:
        name: en*
      dhcp4: true
storage:
    config:
      - {name: ubuntu-vg, devices:[partition-2], preserve: false, type: lvm_volgroup, id: lvm_volgroup-0 }
      - {name: ubuntu-lv, volgroup: lvm_volgroup-0, size: 10GB, wipe: superblock, preserve: false, type: lvm_partition, id: lvm_part-0}
      - {fstype: ext4, volume: lvm_part-0, preserve: false, type: format, id: fmt-2 }
      - {path: /, device: fmt-2, type: mount, id: mnt-2}
      - {path: /boot, device: fmt-1, type: mount, id: mnt-1}
      - {path: /boot/efi, device: fmt-0, type: mount, id: mnt-0}
late-commands:
- curtin in-target --target=/target -- apt-get --purge -y --quiet=2 remove apport bcache-tools btrfs-progs byobu  friendly-recovery fwupd landscape-common lxd-agent-loader ntfs-3g open-vm-tools plymouth plymouth-theme-ubuntu-text popularity-contest rsync screen sosreport tmux ufw
- curtin in-target --target=/target -- apt-get --purge -y --quiet=2 autoremove
- curtin in-target --target=/target -- apt-get clean
- sed -i 's/ENABLED=1/ENABLED=0/' /target/etc/default/motd-news
- sed -i 's|# en_US.UTF-8 UTF-8|en_US.UTF-8 UTF-8|' /target/etc/locale.gen
- curtin in-target --target=/target -- locale-gen
- ln -fs /dev/null /target/etc/systemd/system/connman.service
- ln -fs /dev/null /target/etc/systemd/system/display-manager.service
- ln -fs /dev/null /target/etc/systemd/system/motd-news.service
- ln -fs /dev/null /target/etc/systemd/system/motd-news.timer
- ln -fs /dev/null /target/etc/systemd/system/plymouth-quit-wait.service
- ln -fs /dev/null /target/etc/systemd/system/plymouth-start.service
- ln -fs /dev/null /target/etc/systemd/system/systemd-resolved.service
- ln -fs /usr/share/zoneinfo/Europe/Kiev /target/etc/localtime
- rm -f /target/etc/resolv.conf
- printf 'nameserver 8.8.8.8\nnameserver 1.1.1.1\noptions timeout:1\noptions attempts:1\noptions rotate\n' > /target/etc/resolv.conf
- rm -f /target/etc/update-motd.d/10-help-text
user-data:
disable_root: false

Thank you so much @zero-pytagoras Let me try now

@bashadude - any update ?

@dmuiX
Copy link

dmuiX commented Mar 5, 2023

@dmuiX mind sharing docs on ubuntu install ? I've used official ubuntu cloud-init docs but they are not very informative or clear.

I shared one link above.
Don’t think that I used anything else. I can look if I find something else.

But overall:
To me it the auto-install seemed like it did not work very well for what I wanted to do so I first switched to entering commands manual after install and then to multipass and cloud-Init.

If I remember it correctly I could not change the ipadress and set dns-resolving to a different nameserver via late-command. So I said fuckit i will make it manual or use something else. In cloud-Init this works actually pretty well.

@bashadude
Copy link

@bashadude - any success ?

you really need to read this

#cloud-config
autoinstall:
version: 1
identity: {hostname: HOSTNAME, password: "ENCRYPTED-PASSWORD", username: USERNAME}
locale: en_US.UTF-8
keyboard:
layout: us
ssh:
allow-pw: true
install-server: true
network:
  version: 2
  ethernets:
    eno1:
      match:
        name: en*
      dhcp4: true
storage:
    config:
      - {name: ubuntu-vg, devices:[partition-2], preserve: false, type: lvm_volgroup, id: lvm_volgroup-0 }
      - {name: ubuntu-lv, volgroup: lvm_volgroup-0, size: 10GB, wipe: superblock, preserve: false, type: lvm_partition, id: lvm_part-0}
      - {fstype: ext4, volume: lvm_part-0, preserve: false, type: format, id: fmt-2 }
      - {path: /, device: fmt-2, type: mount, id: mnt-2}
      - {path: /boot, device: fmt-1, type: mount, id: mnt-1}
      - {path: /boot/efi, device: fmt-0, type: mount, id: mnt-0}
late-commands:
- curtin in-target --target=/target -- apt-get --purge -y --quiet=2 remove apport bcache-tools btrfs-progs byobu  friendly-recovery fwupd landscape-common lxd-agent-loader ntfs-3g open-vm-tools plymouth plymouth-theme-ubuntu-text popularity-contest rsync screen sosreport tmux ufw
- curtin in-target --target=/target -- apt-get --purge -y --quiet=2 autoremove
- curtin in-target --target=/target -- apt-get clean
- sed -i 's/ENABLED=1/ENABLED=0/' /target/etc/default/motd-news
- sed -i 's|# en_US.UTF-8 UTF-8|en_US.UTF-8 UTF-8|' /target/etc/locale.gen
- curtin in-target --target=/target -- locale-gen
- ln -fs /dev/null /target/etc/systemd/system/connman.service
- ln -fs /dev/null /target/etc/systemd/system/display-manager.service
- ln -fs /dev/null /target/etc/systemd/system/motd-news.service
- ln -fs /dev/null /target/etc/systemd/system/motd-news.timer
- ln -fs /dev/null /target/etc/systemd/system/plymouth-quit-wait.service
- ln -fs /dev/null /target/etc/systemd/system/plymouth-start.service
- ln -fs /dev/null /target/etc/systemd/system/systemd-resolved.service
- ln -fs /usr/share/zoneinfo/Europe/Kiev /target/etc/localtime
- rm -f /target/etc/resolv.conf
- printf 'nameserver 8.8.8.8\nnameserver 1.1.1.1\noptions timeout:1\noptions attempts:1\noptions rotate\n' > /target/etc/resolv.conf
- rm -f /target/etc/update-motd.d/10-help-text
user-data:
disable_root: false

Thank you so much @zero-pytagoras Let me try now

@bashadude - any update ?

same error @zero-pytagoras
image

@bashadude
Copy link

ok please share me if you find to autoinstall of ubuntu 22.04 @dmuiX i am facing error and got an headache work on this please ping if you find something
image

@dmuiX
Copy link

dmuiX commented Mar 5, 2023

I can just repeat what i have written before. If it’s possible for you use cloud-Init. Works better in my opinion^^

@zero-pytagoras
Copy link

@bashadude can you show the output of crash report. it is in /var/crash folder
I've tested the yaml that i attached on virtual-box and it worked fine.
it seems you have some kind of problem with curtin that is implementing apt-config and also interface it finds is eno8303 or eno8403 so that also needs to be fixedmay be with crash report i could debug it better... eventually is should look like this:

#cloud-config
autoinstall:
version: 1
identity: {hostname: ubuntu22, password: $6$PiTL.ZmMVYG6U4q4$qa8lkOtlAAioKLKqt1q1Ci03HUAE4xRnhrvNd1x1oaSVoma2sTRCHtvt2/QV61tn0QQF6m2e/n0Uf1fQ/3yid0, username: ubuntu}
keyboard: 
    layout: us
  locale: En_Us.UTF-8
ssh:
allow-pw: true
install-server: true
network:
  version: 2
  ethernets:
    eno8303:
      match:
        name: en*
      dhcp4: true
storage:
    config:
      - {name: ubuntu-vg, devices:[partition-2], preserve: false, type: lvm_volgroup, id: lvm_volgroup-0 }
      - {name: ubuntu-lv, volgroup: lvm_volgroup-0, size: 10GB, wipe: superblock, preserve: false, type: lvm_partition, id: lvm_part-0}
      - {fstype: ext4, volume: lvm_part-0, preserve: false, type: format, id: fmt-2 }
      - {path: /, device: fmt-2, type: mount, id: mnt-2}
      - {path: /boot, device: fmt-1, type: mount, id: mnt-1}
      - {path: /boot/efi, device: fmt-0, type: mount, id: mnt-0}
late-commands:
- sed -i 's/ENABLED=1/ENABLED=0/' /target/etc/default/motd-news
- ln -fs /dev/null /target/etc/systemd/system/connman.service
- ln -fs /dev/null /target/etc/systemd/system/display-manager.service
- ln -fs /dev/null /target/etc/systemd/system/motd-news.service
- ln -fs /dev/null /target/etc/systemd/system/motd-news.timer
- ln -fs /dev/null /target/etc/systemd/system/plymouth-quit-wait.service
- ln -fs /dev/null /target/etc/systemd/system/plymouth-start.service
- ln -fs /dev/null /target/etc/systemd/system/systemd-resolved.service
- ln -fs /usr/share/zoneinfo/Europe/Kiev /target/etc/localtime
- rm -f /target/etc/resolv.conf
- printf 'nameserver 8.8.8.8\nnameserver 1.1.1.1\noptions timeout:1\noptions attempts:1\noptions rotate\n' > /target/etc/resolv.conf
- rm -f /target/etc/update-motd.d/10-help-text
user-data:
disable_root: false

@bashadude
Copy link

@zero-pytagoras In crash file "segmentation fault"
image

@zero-pytagoras
Copy link

seg-fault is usually default error meaning that something is missing
try going over on all variables in user-data file: use this tutorial as well https://www.jimangel.io/posts/automate-ubuntu-22-04-lts-bare-metal/

@bashadude
Copy link

Hi All @s3rj1k @dmuiX @zero-pytagoras @soutrikand @sjerman @mcginty @onedr0p @SimplySeth

subiquity/Errorreporter/162334394239423.block_probe_fail : written to /var/crash

image

#cloud-config
autoinstall:
version: 1
locale: en_US.UTF-8
identity:
hostname: amd
password: $6$my3sWAA0IHiGgCZB$8ZJXJn3WpHj3Q0grUkz9zrcLTdkn1pO5W.VYYbx/kfjPHIKeZvYLIwVQ2cWP8TAnDyi1XWvGZsVBDsw5fdFGM1
realname: ubuntu
username: amd
kernel:
package: linux-generic
network:
version: 2
ethernets:
eno1:
match:
name: en*
dhcp4: true

network:

ethernets:

eno8303:

#    dhcp4: true
 # eno8403:
  #  dhcp4: true
 # enp2s0f0np0:
#    dhcp4: true
 # enp2s0f1np1:
#    dhcp4: true

version: 2

kernel:
package: linux-generic
keyboard:
layout: us
ssh:
allow-pw: true
install-server: true
storage:
config:
- {name: ubuntu-vg, devices:[partition-2], preserve: false, type: lvm_volgroup, id: lvm_volgroup-0 }
- {name: ubuntu-lv, volgroup: lvm_volgroup-0, size: 10GB, wipe: superblock, preserve: false, type: lvm_partition, id: lvm_part-0}
- {fstype: ext4, volume: lvm_part-0, preserve: false, type: format, id: fmt-2 }
- {path: /, device: fmt-2, type: mount, id: mnt-2}
- {path: /boot, device: fmt-1, type: mount, id: mnt-1}
- {path: /boot/efi, device: fmt-0, type: mount, id: mnt-0}
updates: security
version: 1

late-commands:
- curtin in-target --target=/target -- apt-get --purge -y --quiet=2 remove apport bcache-tools btrfs-progs byobu cloud-guest-utils cloud-initramfs-copymods cloud-initramfs-dyn-netconf friendly-recovery fwupd landscape-common lxd-agent-loader ntfs-3g open-vm-tools plymouth plymouth-theme-ubuntu-text popularity-contest rsync screen snapd sosreport tmux ufw
- curtin in-target --target=/target -- apt-get --purge -y --quiet=2 autoremove
- curtin in-target --target=/target -- apt-get clean
- sed -i 's/ENABLED=1/ENABLED=0/' /target/etc/default/motd-news
- sed -i 's|# en_US.UTF-8 UTF-8|en_US.UTF-8 UTF-8|' /target/etc/locale.gen
- curtin in-target --target=/target -- locale-gen
- ln -fs /dev/null /target/etc/systemd/system/connman.service
- ln -fs /dev/null /target/etc/systemd/system/display-manager.service
- ln -fs /dev/null /target/etc/systemd/system/motd-news.service
- ln -fs /dev/null /target/etc/systemd/system/motd-news.timer
- ln -fs /dev/null /target/etc/systemd/system/plymouth-quit-wait.service
- ln -fs /dev/null /target/etc/systemd/system/plymouth-start.service
- ln -fs /dev/null /target/etc/systemd/system/systemd-resolved.service
- ln -fs /usr/share/zoneinfo/Europe/Kiev /target/etc/localtime
- rm -f /target/etc/resolv.conf
- printf 'nameserver 8.8.8.8\nnameserver 1.1.1.1\noptions timeout:1\noptions attempts:1\noptions rotate\n' > /target/etc/resolv.conf
- rm -f /target/etc/update-motd.d/10-help-text

- rm -rf /target/root/snap

- rm -rf /target/snap

- rm -rf /target/var/lib/snapd

#- rm -rf /target/var/snap
#- curtin in-target --target=/target -- passwd -q -u root

- curtin in-target --target=/target -- passwd -q -x -1 root

- curtin in-target --target=/target -- passwd -q -e root

- sed -i 's|^root:.:|root:$6$3b873df474b55246$GIpSsujar7ihMzG8urUKpzF9/2yZJhR.msyFRa5ouGXOKRCVszsc4aBcE2yi3IuFVxtAGwrPKin2WAzK3qOtB.:|' /target/etc/shadow

user-data:
disable_root: false

Please help me to debug guys

@onedr0p
Copy link

onedr0p commented Mar 6, 2023

Please stop typing direct mentions.

@bashadude
Copy link

Please stop typing direct mentions.

ok

@zero-pytagoras
Copy link

@bashadude
remove the curtin command listed below

- curtin in-target --target=/target -- apt-get --purge -y --quiet=2 remove apport bcache-tools btrfs-progs byobu cloud-guest-utils cloud-initramfs-copymods cloud-initramfs-dyn-netconf friendly-recovery fwupd landscape-common lxd-agent-loader ntfs-3g open-vm-tools plymouth plymouth-theme-ubuntu-text popularity-contest rsync screen snapd sosreport tmux ufw
- curtin in-target --target=/target -- apt-get --purge -y --quiet=2 autoremove
- curtin in-target --target=/target -- apt-get clean

@bashadude
Copy link

@bashadude remove the curtin command listed below

- curtin in-target --target=/target -- apt-get --purge -y --quiet=2 remove apport bcache-tools btrfs-progs byobu cloud-guest-utils cloud-initramfs-copymods cloud-initramfs-dyn-netconf friendly-recovery fwupd landscape-common lxd-agent-loader ntfs-3g open-vm-tools plymouth plymouth-theme-ubuntu-text popularity-contest rsync screen snapd sosreport tmux ufw
- curtin in-target --target=/target -- apt-get --purge -y --quiet=2 autoremove
- curtin in-target --target=/target -- apt-get clean

@zero-pytagoras Thanks for sharing

I will update after this

@s3rj1k
Copy link
Author

s3rj1k commented Mar 6, 2023

@dbkinghorn Can you maybe stop referring to your blog? One refer would have been enough, thanks.

P.S. I've added a link to your blog at the begging of howto, still if you want to contribute, please post full answers here.

@dbkinghorn
Copy link

Oh man, I'm so sorry! I've been getting questions in my email from more than one place on this. I've been careless about checking where I'm replying. Gist comments can get out of hand! I blew away my last comment. Wish you all the best --Don

@bashadude
Copy link

Hi All @s3rj1k @dbkinghorn @zero-pytagoras @dmuiX I am stuck in last step can you please help me to debug this
image

After running of my late commands i got this error
These are my late commands:

  • |
    set -ex
    EFI_DEV=$(awk '$2 == "/target/boot/efi" { print $1 }' /proc/mounts)
    ROOT_DEV=$(awk '$2 ~ "^/target$" { print $1 }' /proc/mounts)
    ROOT_UUID=$(blkid -o value $ROOT_DEV | head -n 1)
    awk '$2 ~ "^/target/" { print $2 }' /proc/mounts | xargs umount
    btrfs subvolume snapshot /target /target/rootfs
    mkdir /mnt/rootfs
    mount -o subvol=rootfs $ROOT_DEV /mnt/rootfs
    mount $EFI_DEV /mnt/rootfs/boot/efi
    mount -o bind /dev /mnt/rootfs/dev
    mount -o bind /sys /mnt/rootfs/sys
    mount -o bind /proc /mnt/rootfs/proc
    sed -i "/$ROOT_UUID/s/defaults/defaults,noatime,subvol=rootfs/" /mnt/rootfs/etc/fstab
    chroot /mnt/rootfs update-grub
    chroot /mnt/rootfs grub-install --efi-directory=/boot/efi
    find /target -mindepth 1 -maxdepth 1 -not -name rootfs -exec rm -rf '{}' ;
    btrfs subvolume create /target/home
    echo "/dev/disk/by-uuid/$ROOT_UUID /home btrfs defaults,noatime,subvol=home 0 0" >> /mnt/rootfs/etc/fstab

@zero-pytagoras
Copy link

TBH it is not clear what you are trying to do any more...
you do need to add /target to bunch of places if you wish to change partitions. for example:
/mnt/rootfs/etc/fstab is suppose to be /target/mnt/rootfs/etc/fstab

@surter
Copy link

surter commented May 26, 2023

The installation of ubuntu22.04 through uefi mode pxe is successful, but after restarting, it will enter the pxe network installation instead of booting from the local hard disk. The default hard disk booting is the first boot item. Is there any way to solve this problem?

@surter
Copy link

surter commented May 26, 2023

image

@surter
Copy link

surter commented May 26, 2023

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment