-
-
Save robinsmidsrod/a2ed8756f1eff61c74227fa15ec7d564 to your computer and use it in GitHub Desktop.
:ubuntu-autoinstall | |
echo Starting Ubuntu ${ubuntu-version} ${archl} autoinstaller for ${initiator-iqn} | |
sanhook ${base-iscsi}:${hostname}.boot.ubuntu || sleep 1 | |
#sanhook ${base-iscsi}:${hostname}.boot.ubuntu && set ubuntu-cc-iscsi storage: { layout: { name: lvm }, config: [{type: disk, path: ${base-iscsi}:${hostname}.boot.ubuntu }] } || sleep 1 | |
#sanhook ${base-iscsi}:${hostname}.boot.ubuntu && set ubuntu-iscsi ISCSI_INITIATOR=${initiator-iqn} ISCSI_TARGET_NAME=${base-iqn}:${hostname}.boot.ubuntu ISCSI_TARGET_IP=${iscsi-server} ISCSI_TARGET_PORT=3260 || sleep 1 | |
# https://medium.com/@tlhakhan/ubuntu-server-20-04-autoinstall-2e5f772b655a | |
# https://ubuntu.com/server/docs/install/autoinstall | |
# https://github.com/canonical/cloud-init/blob/master/doc/examples/kernel-cmdline.txt | |
# https://matt.olan.me/raspberry-pi-iscsi-root-on-ubuntu-20-04/ | |
# https://askubuntu.com/questions/1235723/automated-20-04-server-installation-using-pxe-and-live-server-image | |
# casper NFS config: nfsroot=[<server-ip>:]<root-dir>[,<nfs-options>] | |
set ubuntu-installer-base ubuntu-${ubuntu-version}-live-server-${archl} | |
set base-url ubuntu/${ubuntu-installer-base}/ | |
kernel ${base-url}casper/vmlinuz | |
initrd ${base-url}casper/initrd | |
# h=${hostname};i=i-${uuid}; | |
# , ${ubuntu-cc-iscsi} | |
# ${ubuntu-iscsi} | |
imgargs vmlinuz initrd=initrd \ | |
ip=dhcp \ | |
url=${sanboot-url}ubuntu/${ubuntu-installer-base}.iso \ | |
autoinstall \ | |
ds=nocloud-net;s=${sanboot-url}ubuntu/autoinstall-${ubuntu-installer-base}/ \ | |
cc: autoinstall: { identity: { hostname: ${hostname} } } | |
# disk-detect/ibft/enable=true partman-iscsi/iscsi_auto=true \ | |
# netboot=nfs \ | |
# nfsroot=${nfs-server}:${nfs-root}${base-url} \ | |
# net.ifnames=0 \ | |
# biosdevname=0 \ | |
# ipv6.disable=1 \ | |
boot || goto failed | |
goto start |
#cloud-config | |
autoinstall: | |
version: 1 | |
interactive-sections: | |
- network | |
- storage | |
early-commands: | |
- [/sbin/modprobe, iscsi_ibft] | |
- | | |
test ! -z /sys/firmware/ibft/initiator/initiator-name \ | |
&& sed -ie "s/InitiatorName=.*/InitiatorName=$(cat /sys/firmware/ibft/initiator/initiator-name)/" /etc/iscsi/initiatorname.iscsi \ | |
&& touch /etc/iscsi/iscsi.initramfs \ | |
&& /usr/sbin/iscsistart -b \ | |
|| /bin/true | |
locale: en_US.UTF-8 | |
refresh-installer: | |
update: no | |
keyboard: | |
layout: "no" | |
apt: | |
geoip: true | |
preserve_sources_list: false | |
primary: | |
- arches: | |
- amd64 | |
- i386 | |
uri: http://no.archive.ubuntu.com/ubuntu | |
- arches: | |
- default | |
uri: http://ports.ubuntu.com/ubuntu-ports | |
storage: | |
layout: | |
name: lvm | |
identity: | |
#hostname: ubuntu-server # must be commented out for ipxe setting to win out | |
password: $6$14qo8c1...z1rA4CWSi. | |
realname: Robin Smidsrød | |
username: robin | |
ssh: | |
install-server: true | |
allow-pw: true | |
authorized-keys: | |
- "ssh-ed25519 AAAAC...mRBlzLtA robin...639 # ssh-import-id gh:robinsmidsrod" | |
packages: | |
- joe | |
late-commands: | |
# Sets iSCSI Initiator IQN from iBFT and enables iSCSI boot in initrd | |
- | | |
test ! -z /sys/firmware/ibft/initiator/initiator-name \ | |
&& sed -ie "s/InitiatorName=.*/InitiatorName=$(cat /sys/firmware/ibft/initiator/initiator-name)/" /target/etc/iscsi/initiatorname.iscsi \ | |
&& touch /target/etc/iscsi/iscsi.initramfs \ | |
&& curtin in-target -- iscsiadm -m node --op=update -n node.startup -v automatic \ | |
&& curtin in-target -- systemctl enable open-iscsi \ | |
&& curtin in-target -- update-initramfs -v -k $(uname -r) -c \ | |
&& curtin in-target -- update-grub2 \ | |
|| /bin/true |
Just curious, do you happen to know if you can ipxe boot, a customized Ubuntu 20.04 squashfs image and run it in memory (For servers without hard disks)? I know there are cloud images here, but can't seem to ipxe boot them to run in memory: https://cloud-images.ubuntu.com/focal/current/
Here is an example I used to boot a live Ubuntu desktop 20.04.3 with iPXE. Not sure whether this is what you are looking for.
:ubuntu-live-2004
kerne vmlinuz
initrd initrd
imgargs vmlinuz initrd=initrd ip=dhcp url=http://1.2.3.4/ubuntu-20.04.3-desktop-amd64.iso
Thanks but I'm looking to boot a live Ubuntu server OS into memory. (Without running the installer) I already can boot the desktop too
Hi Robin,
I don't understand "cc: autoinstall: { identity: { hostname: ${hostname} } }" even it works for me.
I googled it but nothing found related with "cc: autoinstall:".
Could you explain a bit or share with me some reference pages?Many thanks!
-Jerry
Just realized Robin had already put the reference link in the code. 👍
https://github.com/canonical/cloud-init/blob/master/doc/examples/kernel-cmdline.txt
Hi Robin,
I don't understand "cc: autoinstall: { identity: { hostname: ${hostname} } }" even it works for me.
I googled it but nothing found related with "cc: autoinstall:".
Could you explain a bit or share with me some reference pages?
Many thanks!
-Jerry