Skip to content

Instantly share code, notes, and snippets.

@robinsmidsrod
Last active July 4, 2023 09:11
Show Gist options
  • Save robinsmidsrod/21a15a562bc45d4ce25dcde507fb3100 to your computer and use it in GitHub Desktop.
Save robinsmidsrod/21a15a562bc45d4ce25dcde507fb3100 to your computer and use it in GitHub Desktop.
iPXE script entries for booting Ubuntu 18.04 in different ways
# boot-url points to an nfs URL
# sanboot-url points to an http URL
# ubuntu-version contains 18.04.3
# ubuntu-release contains bionic
:ubuntu
echo Booting Ubuntu from iSCSI for ${initiator-iqn}
set root-path ${base-iscsi}:${hostname}.boot.ubuntu
sanboot ${root-path} || goto failed
goto start
:ubuntu-install-iscsi
echo Starting Ubuntu ${ubuntu-version} ${archl} installer for ${initiator-iqn}
# iBFT table not required for Ubuntu
#sanhook ${base-iscsi}:${hostname}.boot.ubuntu || sleep 1
# The partman-iscsi/initiatorname kernel paramter is saved in
# /etc/iscsi/initiatorname.iscsi during the installation.
# Preseed help: https://help.ubuntu.com/lts/installation-guide/amd64/apbs04.html
set ubuntu-installer-base ubuntu-${ubuntu-version}-server-${archl}
set base-url ubuntu/${ubuntu-installer-base}/
kernel ${base-url}install/netboot/ubuntu-installer/${archl}/linux
initrd ${base-url}install/netboot/ubuntu-installer/${archl}/initrd.gz
imgargs linux auto=true fb=false \
netcfg/get_hostname=${hostname} \
partman-iscsi/initiatorname=${initiator-iqn} \
partman-iscsi/login/username=${username} \
partman-iscsi/login/password=${password} \
partman-iscsi/login/address=${iscsi-server} \
partman-iscsi/login/targets=${base-iqn}:${hostname}.boot.ubuntu \
DEBCONF_DEBUG=5 url=${sanboot-url}ubuntu/${ubuntu-installer-base}.preseed
boot || goto failed
goto start
:ubuntu-install-local
echo Starting Ubuntu ${ubuntu-version} ${archl} local installer for ${initiator-iqn}
set ubuntu-installer-base ubuntu-${ubuntu-version}-server-${archl}
set base-url ubuntu/${ubuntu-installer-base}/
kernel ${base-url}install/netboot/ubuntu-installer/${archl}/linux
initrd ${base-url}install/netboot/ubuntu-installer/${archl}/initrd.gz
imgargs linux auto=true fb=false url=${sanboot-url}ubuntu/${ubuntu-installer-base}.preseed
boot || goto failed
goto start
:ubuntu-install-remote
echo Starting Ubuntu ${ubuntu-version} ${archl} installer for ${initiator-iqn}
set base-url http://no.archive.ubuntu.com/ubuntu/dists/${ubuntu-release}/main/installer-${archl}/current/
kernel ${base-url}images/netboot/ubuntu-installer/${archl}/linux
initrd ${base-url}images/netboot/ubuntu-installer/${archl}/initrd.gz
boot || goto failed
goto start
:ubuntu-live
# See http://manpages.ubuntu.com/manpages/precise/man7/casper.7.html for casper cmdline details
echo Booting Ubuntu Live ${ubuntu-version} ${archl} for ${initiator-iqn}
set ubuntu-installer-base ubuntu-${ubuntu-version}-desktop-${archl}
set base-url ubuntu/${ubuntu-installer-base}
kernel ${base-url}/casper/vmlinuz
initrd ${base-url}/casper/initrd
imgargs vmlinuz boot=casper \
root=/dev/nfs netboot=nfs nfsroot=${nfs-server}:${nfs-root}${base-url} \
locale=en_US.UTF-8 \
keyboard-configuration/layoutcode=no \
mirror/country=NO
boot || goto failed
goto start
@rikka0w0
Copy link

rikka0w0 commented Jan 7, 2021

To boot ubuntu-live 20.04, you need to:

  1. append ip=dhcp to imgargs, otherwise the initramfs won't obtain an IP address via DHCP for you. No IP no network access, and the nfs mounting cannot be done.
  2. Copy the .disk folder to your nfs server, the .disk should be at the same folder with the casper folder. You only need to keep the casper-uuid-generic inside .disk to make the whole thing work.

My folder structure look like this:

/srv/nfs/ubuntu2004/.disk/casper-uuid-generic
/srv/nfs/ubuntu2004/casper
/srv/nfs/ubuntu2004/initrd
/srv/nfs/ubuntu2004/vmlinuz

My IPXE entry looks like:

# Set NFS strings
set nfs-server          ${next-server}
set nfs-mountpt         /srv/nfs
set nfs-root-boot      nfs://${nfs-server}/${nfs-mountpt}/ubuntu2004/
set nfs-root-linux      ${nfs-server}:${nfs-mountpt}/ubuntu2004/

:ubuntu2004_live
kernel ${nfs-root-boot}/vmlinuz
initrd ${nfs-root-boot}/initrd
imgargs vmlinuz initrd=initrd nfsroot=${nfs-root-linux} netboot=nfs boot=casper ip=dhcp
boot
goto start

Hopefully this will help others.

Thanks

@robinsmidsrod
Copy link
Author

Thank you, @rikka0w0!

I'm sure this will come in hand for anyone else finding this snippet.

I haven't yet updated my network boot setup to support Ubuntu 20.04 yet, so I wasn't aware of what changes were needed, but I assumed some changes would be needed.

@cchalifo999
Copy link

Would it work with ubuntu 20.10 server

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